| OLD | NEW |
| 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 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 return CreateIllegalArgumentError(); | 255 return CreateIllegalArgumentError(); |
| 256 } | 256 } |
| 257 | 257 |
| 258 | 258 |
| 259 CObject* Directory::ListNextRequest(const CObjectArray& request) { | 259 CObject* Directory::ListNextRequest(const CObjectArray& request) { |
| 260 if (request.Length() == 1 && | 260 if (request.Length() == 1 && |
| 261 request[0]->IsIntptr()) { | 261 request[0]->IsIntptr()) { |
| 262 CObjectIntptr ptr(request[0]); | 262 CObjectIntptr ptr(request[0]); |
| 263 AsyncDirectoryListing* dir_listing = | 263 AsyncDirectoryListing* dir_listing = |
| 264 reinterpret_cast<AsyncDirectoryListing*>(ptr.Value()); | 264 reinterpret_cast<AsyncDirectoryListing*>(ptr.Value()); |
| 265 if (dir_listing->IsEmpty()) { |
| 266 return new CObjectArray(CObject::NewArray(0)); |
| 267 } |
| 265 const int kArraySize = 128; | 268 const int kArraySize = 128; |
| 266 CObjectArray* response = new CObjectArray(CObject::NewArray(kArraySize)); | 269 CObjectArray* response = new CObjectArray(CObject::NewArray(kArraySize)); |
| 267 dir_listing->SetArray(response, kArraySize); | 270 dir_listing->SetArray(response, kArraySize); |
| 268 Directory::List(dir_listing); | 271 Directory::List(dir_listing); |
| 269 // In case the listing ended before it hit the buffer length, we need to | 272 // In case the listing ended before it hit the buffer length, we need to |
| 270 // override the array length. | 273 // override the array length. |
| 271 response->AsApiCObject()->value.as_array.length = dir_listing->index(); | 274 response->AsApiCObject()->value.as_array.length = dir_listing->index(); |
| 272 return response; | 275 return response; |
| 273 } | 276 } |
| 274 return CreateIllegalArgumentError(); | 277 return CreateIllegalArgumentError(); |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 if (listing->error()) { | 421 if (listing->error()) { |
| 419 listing->HandleError("Invalid path"); | 422 listing->HandleError("Invalid path"); |
| 420 listing->HandleDone(); | 423 listing->HandleDone(); |
| 421 } else { | 424 } else { |
| 422 while (ListNext(listing)) {} | 425 while (ListNext(listing)) {} |
| 423 } | 426 } |
| 424 } | 427 } |
| 425 | 428 |
| 426 } // namespace bin | 429 } // namespace bin |
| 427 } // namespace dart | 430 } // namespace dart |
| OLD | NEW |