Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: runtime/bin/directory.cc

Issue 17158003: Report async errors when they happend, in directory listing. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/bin/directory_macos.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "bin/directory.h" 5 #include "bin/directory.h"
6 6
7 #include "bin/dartutils.h" 7 #include "bin/dartutils.h"
8 #include "bin/thread.h" 8 #include "bin/thread.h"
9 #include "include/dart_api.h" 9 #include "include/dart_api.h"
10 #include "platform/assert.h" 10 #include "platform/assert.h"
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 request[1]->IsString() && 235 request[1]->IsString() &&
236 request[2]->IsBool() && 236 request[2]->IsBool() &&
237 request[3]->IsBool()) { 237 request[3]->IsBool()) {
238 CObjectString path(request[1]); 238 CObjectString path(request[1]);
239 CObjectBool recursive(request[2]); 239 CObjectBool recursive(request[2]);
240 CObjectBool follow_links(request[3]); 240 CObjectBool follow_links(request[3]);
241 AsyncDirectoryListing* dir_listing = 241 AsyncDirectoryListing* dir_listing =
242 new AsyncDirectoryListing(path.CString(), 242 new AsyncDirectoryListing(path.CString(),
243 recursive.Value(), 243 recursive.Value(),
244 follow_links.Value()); 244 follow_links.Value());
245 if (dir_listing->error()) {
246 // Report error now, so we capture the correct OSError.
247 CObject* err = CObject::NewOSError();
248 delete dir_listing;
249 CObjectArray* error = new CObjectArray(CObject::NewArray(3));
250 error->SetAt(0, new CObjectInt32(
251 CObject::NewInt32(AsyncDirectoryListing::kListError)));
252 error->SetAt(1, request[1]);
253 error->SetAt(2, err);
254 return error;
255 }
245 // TODO(ajohnsen): Consider returning the first few results. 256 // TODO(ajohnsen): Consider returning the first few results.
246 return new CObjectIntptr(CObject::NewIntptr( 257 return new CObjectIntptr(CObject::NewIntptr(
247 reinterpret_cast<intptr_t>(dir_listing))); 258 reinterpret_cast<intptr_t>(dir_listing)));
248 } 259 }
249 return CreateIllegalArgumentError(); 260 return CreateIllegalArgumentError();
250 } 261 }
251 262
252 263
253 static CObject* DirectoryListNextRequest(const CObjectArray& request) { 264 static CObject* DirectoryListNextRequest(const CObjectArray& request) {
254 if (request.Length() == 2 && 265 if (request.Length() == 2 &&
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 bool AsyncDirectoryListing::HandleLink(char* link_name) { 393 bool AsyncDirectoryListing::HandleLink(char* link_name) {
383 return AddFileSystemEntityToResponse(kListLink, link_name); 394 return AddFileSystemEntityToResponse(kListLink, link_name);
384 } 395 }
385 396
386 void AsyncDirectoryListing::HandleDone() { 397 void AsyncDirectoryListing::HandleDone() {
387 AddFileSystemEntityToResponse(kListDone, NULL); 398 AddFileSystemEntityToResponse(kListDone, NULL);
388 } 399 }
389 400
390 401
391 bool AsyncDirectoryListing::HandleError(const char* dir_name) { 402 bool AsyncDirectoryListing::HandleError(const char* dir_name) {
403 CObject* err = CObject::NewOSError();
392 array_->SetAt(index_++, new CObjectInt32(CObject::NewInt32(kListError))); 404 array_->SetAt(index_++, new CObjectInt32(CObject::NewInt32(kListError)));
393 CObject* err = CObject::NewOSError();
394 CObjectArray* response = new CObjectArray(CObject::NewArray(3)); 405 CObjectArray* response = new CObjectArray(CObject::NewArray(3));
395 response->SetAt(0, new CObjectInt32(CObject::NewInt32(kListError))); 406 response->SetAt(0, new CObjectInt32(CObject::NewInt32(kListError)));
396 response->SetAt(1, new CObjectString(CObject::NewString(dir_name))); 407 response->SetAt(1, new CObjectString(CObject::NewString(dir_name)));
397 response->SetAt(2, err); 408 response->SetAt(2, err);
398 array_->SetAt(index_++, response); 409 array_->SetAt(index_++, response);
399 return index_ < length_; 410 return index_ < length_;
400 } 411 }
401 412
402 bool SyncDirectoryListing::HandleDirectory(char* dir_name) { 413 bool SyncDirectoryListing::HandleDirectory(char* dir_name) {
403 Dart_Handle dir_name_dart = DartUtils::NewString(dir_name); 414 Dart_Handle dir_name_dart = DartUtils::NewString(dir_name);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 if (listing->error()) { 485 if (listing->error()) {
475 listing->HandleError("Invalid path"); 486 listing->HandleError("Invalid path");
476 listing->HandleDone(); 487 listing->HandleDone();
477 } else { 488 } else {
478 while (ListNext(listing)) {} 489 while (ListNext(listing)) {}
479 } 490 }
480 } 491 }
481 492
482 } // namespace bin 493 } // namespace bin
483 } // namespace dart 494 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/bin/directory_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698