| 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 #if !defined(DART_IO_DISABLED) | 5 #if !defined(DART_IO_DISABLED) |
| 6 | 6 |
| 7 #include "bin/directory.h" | 7 #include "bin/directory.h" |
| 8 | 8 |
| 9 #include "bin/dartutils.h" | 9 #include "bin/dartutils.h" |
| 10 #include "bin/log.h" | 10 #include "bin/log.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 | 72 |
| 73 void FUNCTION_NAME(Directory_SystemTemp)(Dart_NativeArguments args) { | 73 void FUNCTION_NAME(Directory_SystemTemp)(Dart_NativeArguments args) { |
| 74 const char* result = Directory::SystemTemp(); | 74 const char* result = Directory::SystemTemp(); |
| 75 Dart_SetReturnValue(args, DartUtils::NewString(result)); | 75 Dart_SetReturnValue(args, DartUtils::NewString(result)); |
| 76 } | 76 } |
| 77 | 77 |
| 78 | 78 |
| 79 void FUNCTION_NAME(Directory_CreateTemp)(Dart_NativeArguments args) { | 79 void FUNCTION_NAME(Directory_CreateTemp)(Dart_NativeArguments args) { |
| 80 Dart_Handle path = Dart_GetNativeArgument(args, 0); | 80 Dart_Handle path = Dart_GetNativeArgument(args, 0); |
| 81 if (!Dart_IsString(path)) { | 81 if (!Dart_IsString(path)) { |
| 82 Dart_SetReturnValue(args, DartUtils::NewDartArgumentError( | 82 Dart_SetReturnValue( |
| 83 "Prefix argument of CreateSystemTempSync is not a String")); | 83 args, DartUtils::NewDartArgumentError( |
| 84 "Prefix argument of CreateSystemTempSync is not a String")); |
| 84 return; | 85 return; |
| 85 } | 86 } |
| 86 const char* result = | 87 const char* result = Directory::CreateTemp(DartUtils::GetStringValue(path)); |
| 87 Directory::CreateTemp(DartUtils::GetStringValue(path)); | |
| 88 if (result != NULL) { | 88 if (result != NULL) { |
| 89 Dart_SetReturnValue(args, DartUtils::NewString(result)); | 89 Dart_SetReturnValue(args, DartUtils::NewString(result)); |
| 90 } else { | 90 } else { |
| 91 Dart_SetReturnValue(args, DartUtils::NewDartOSError()); | 91 Dart_SetReturnValue(args, DartUtils::NewDartOSError()); |
| 92 } | 92 } |
| 93 } | 93 } |
| 94 | 94 |
| 95 | 95 |
| 96 void FUNCTION_NAME(Directory_Delete)(Dart_NativeArguments args) { | 96 void FUNCTION_NAME(Directory_Delete)(Dart_NativeArguments args) { |
| 97 Dart_Handle path = Dart_GetNativeArgument(args, 0); | 97 Dart_Handle path = Dart_GetNativeArgument(args, 0); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 119 | 119 |
| 120 void FUNCTION_NAME(Directory_FillWithDirectoryListing)( | 120 void FUNCTION_NAME(Directory_FillWithDirectoryListing)( |
| 121 Dart_NativeArguments args) { | 121 Dart_NativeArguments args) { |
| 122 // The list that we should fill. | 122 // The list that we should fill. |
| 123 Dart_Handle results = Dart_GetNativeArgument(args, 0); | 123 Dart_Handle results = Dart_GetNativeArgument(args, 0); |
| 124 Dart_Handle path = Dart_GetNativeArgument(args, 1); | 124 Dart_Handle path = Dart_GetNativeArgument(args, 1); |
| 125 Dart_Handle recursive = Dart_GetNativeArgument(args, 2); | 125 Dart_Handle recursive = Dart_GetNativeArgument(args, 2); |
| 126 Dart_Handle follow_links = Dart_GetNativeArgument(args, 3); | 126 Dart_Handle follow_links = Dart_GetNativeArgument(args, 3); |
| 127 // Pass the list that should hold the directory listing to the | 127 // Pass the list that should hold the directory listing to the |
| 128 // SyncDirectoryListing object, which adds elements to it. | 128 // SyncDirectoryListing object, which adds elements to it. |
| 129 SyncDirectoryListing sync_listing(results, | 129 SyncDirectoryListing sync_listing(results, DartUtils::GetStringValue(path), |
| 130 DartUtils::GetStringValue(path), | |
| 131 DartUtils::GetBooleanValue(recursive), | 130 DartUtils::GetBooleanValue(recursive), |
| 132 DartUtils::GetBooleanValue(follow_links)); | 131 DartUtils::GetBooleanValue(follow_links)); |
| 133 Directory::List(&sync_listing); | 132 Directory::List(&sync_listing); |
| 134 } | 133 } |
| 135 | 134 |
| 136 | 135 |
| 137 static const int kAsyncDirectoryListerFieldIndex = 0; | 136 static const int kAsyncDirectoryListerFieldIndex = 0; |
| 138 | 137 |
| 139 | 138 |
| 140 void FUNCTION_NAME(Directory_GetAsyncDirectoryListerPointer)( | 139 void FUNCTION_NAME(Directory_GetAsyncDirectoryListerPointer)( |
| 141 Dart_NativeArguments args) { | 140 Dart_NativeArguments args) { |
| 142 AsyncDirectoryListing* listing; | 141 AsyncDirectoryListing* listing; |
| 143 Dart_Handle dart_this = ThrowIfError(Dart_GetNativeArgument(args, 0)); | 142 Dart_Handle dart_this = ThrowIfError(Dart_GetNativeArgument(args, 0)); |
| 144 ASSERT(Dart_IsInstance(dart_this)); | 143 ASSERT(Dart_IsInstance(dart_this)); |
| 145 ThrowIfError(Dart_GetNativeInstanceField( | 144 ThrowIfError( |
| 146 dart_this, | 145 Dart_GetNativeInstanceField(dart_this, kAsyncDirectoryListerFieldIndex, |
| 147 kAsyncDirectoryListerFieldIndex, | 146 reinterpret_cast<intptr_t*>(&listing))); |
| 148 reinterpret_cast<intptr_t*>(&listing))); | |
| 149 if (listing != NULL) { | 147 if (listing != NULL) { |
| 150 intptr_t listing_pointer = reinterpret_cast<intptr_t>(listing); | 148 intptr_t listing_pointer = reinterpret_cast<intptr_t>(listing); |
| 151 // Increment the listing's reference count. This native should only be | 149 // Increment the listing's reference count. This native should only be |
| 152 // be called when we are about to send the AsyncDirectoryListing* to the | 150 // be called when we are about to send the AsyncDirectoryListing* to the |
| 153 // IO service. | 151 // IO service. |
| 154 listing->Retain(); | 152 listing->Retain(); |
| 155 Dart_SetReturnValue(args, Dart_NewInteger(listing_pointer)); | 153 Dart_SetReturnValue(args, Dart_NewInteger(listing_pointer)); |
| 156 } | 154 } |
| 157 } | 155 } |
| 158 | 156 |
| 159 | 157 |
| 160 static void ReleaseListing(void* isolate_callback_data, | 158 static void ReleaseListing(void* isolate_callback_data, |
| 161 Dart_WeakPersistentHandle handle, | 159 Dart_WeakPersistentHandle handle, |
| 162 void* peer) { | 160 void* peer) { |
| 163 AsyncDirectoryListing* listing = | 161 AsyncDirectoryListing* listing = |
| 164 reinterpret_cast<AsyncDirectoryListing*>(peer); | 162 reinterpret_cast<AsyncDirectoryListing*>(peer); |
| 165 listing->Release(); | 163 listing->Release(); |
| 166 } | 164 } |
| 167 | 165 |
| 168 | 166 |
| 169 void FUNCTION_NAME(Directory_SetAsyncDirectoryListerPointer)( | 167 void FUNCTION_NAME(Directory_SetAsyncDirectoryListerPointer)( |
| 170 Dart_NativeArguments args) { | 168 Dart_NativeArguments args) { |
| 171 Dart_Handle dart_this = ThrowIfError(Dart_GetNativeArgument(args, 0)); | 169 Dart_Handle dart_this = ThrowIfError(Dart_GetNativeArgument(args, 0)); |
| 172 intptr_t listing_pointer = | 170 intptr_t listing_pointer = |
| 173 DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 1)); | 171 DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 1)); |
| 174 AsyncDirectoryListing* listing = | 172 AsyncDirectoryListing* listing = |
| 175 reinterpret_cast<AsyncDirectoryListing*>(listing_pointer); | 173 reinterpret_cast<AsyncDirectoryListing*>(listing_pointer); |
| 176 Dart_NewWeakPersistentHandle( | 174 Dart_NewWeakPersistentHandle(dart_this, reinterpret_cast<void*>(listing), |
| 177 dart_this, | 175 sizeof(*listing), ReleaseListing); |
| 178 reinterpret_cast<void*>(listing), | |
| 179 sizeof(*listing), | |
| 180 ReleaseListing); | |
| 181 Dart_Handle result = Dart_SetNativeInstanceField( | 176 Dart_Handle result = Dart_SetNativeInstanceField( |
| 182 dart_this, | 177 dart_this, kAsyncDirectoryListerFieldIndex, listing_pointer); |
| 183 kAsyncDirectoryListerFieldIndex, | |
| 184 listing_pointer); | |
| 185 if (Dart_IsError(result)) { | 178 if (Dart_IsError(result)) { |
| 186 Log::PrintErr("SetAsyncDirectoryListerPointer failed\n"); | 179 Log::PrintErr("SetAsyncDirectoryListerPointer failed\n"); |
| 187 Dart_PropagateError(result); | 180 Dart_PropagateError(result); |
| 188 } | 181 } |
| 189 } | 182 } |
| 190 | 183 |
| 191 | 184 |
| 192 void Directory::SetSystemTemp(const char* path) { | 185 void Directory::SetSystemTemp(const char* path) { |
| 193 if (system_temp_path_override_ != NULL) { | 186 if (system_temp_path_override_ != NULL) { |
| 194 free(system_temp_path_override_); | 187 free(system_temp_path_override_); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 207 return CObject::True(); | 200 return CObject::True(); |
| 208 } else { | 201 } else { |
| 209 return CObject::NewOSError(); | 202 return CObject::NewOSError(); |
| 210 } | 203 } |
| 211 } | 204 } |
| 212 return CObject::IllegalArgumentError(); | 205 return CObject::IllegalArgumentError(); |
| 213 } | 206 } |
| 214 | 207 |
| 215 | 208 |
| 216 CObject* Directory::DeleteRequest(const CObjectArray& request) { | 209 CObject* Directory::DeleteRequest(const CObjectArray& request) { |
| 217 if ((request.Length() == 2) && | 210 if ((request.Length() == 2) && request[0]->IsString() && |
| 218 request[0]->IsString() && request[1]->IsBool()) { | 211 request[1]->IsBool()) { |
| 219 CObjectString path(request[0]); | 212 CObjectString path(request[0]); |
| 220 CObjectBool recursive(request[1]); | 213 CObjectBool recursive(request[1]); |
| 221 if (Directory::Delete(path.CString(), recursive.Value())) { | 214 if (Directory::Delete(path.CString(), recursive.Value())) { |
| 222 return CObject::True(); | 215 return CObject::True(); |
| 223 } else { | 216 } else { |
| 224 return CObject::NewOSError(); | 217 return CObject::NewOSError(); |
| 225 } | 218 } |
| 226 } | 219 } |
| 227 return CObject::IllegalArgumentError(); | 220 return CObject::IllegalArgumentError(); |
| 228 } | 221 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 258 } | 251 } |
| 259 } | 252 } |
| 260 return CObject::IllegalArgumentError(); | 253 return CObject::IllegalArgumentError(); |
| 261 } | 254 } |
| 262 | 255 |
| 263 | 256 |
| 264 static CObject* CreateIllegalArgumentError() { | 257 static CObject* CreateIllegalArgumentError() { |
| 265 // Respond with an illegal argument list error message. | 258 // Respond with an illegal argument list error message. |
| 266 CObjectArray* error = new CObjectArray(CObject::NewArray(3)); | 259 CObjectArray* error = new CObjectArray(CObject::NewArray(3)); |
| 267 error->SetAt(0, new CObjectInt32( | 260 error->SetAt(0, new CObjectInt32( |
| 268 CObject::NewInt32(AsyncDirectoryListing::kListError))); | 261 CObject::NewInt32(AsyncDirectoryListing::kListError))); |
| 269 error->SetAt(1, CObject::Null()); | 262 error->SetAt(1, CObject::Null()); |
| 270 error->SetAt(2, CObject::IllegalArgumentError()); | 263 error->SetAt(2, CObject::IllegalArgumentError()); |
| 271 return error; | 264 return error; |
| 272 } | 265 } |
| 273 | 266 |
| 274 | 267 |
| 275 CObject* Directory::ListStartRequest(const CObjectArray& request) { | 268 CObject* Directory::ListStartRequest(const CObjectArray& request) { |
| 276 if ((request.Length() == 3) && | 269 if ((request.Length() == 3) && request[0]->IsString() && |
| 277 request[0]->IsString() && | 270 request[1]->IsBool() && request[2]->IsBool()) { |
| 278 request[1]->IsBool() && | |
| 279 request[2]->IsBool()) { | |
| 280 CObjectString path(request[0]); | 271 CObjectString path(request[0]); |
| 281 CObjectBool recursive(request[1]); | 272 CObjectBool recursive(request[1]); |
| 282 CObjectBool follow_links(request[2]); | 273 CObjectBool follow_links(request[2]); |
| 283 AsyncDirectoryListing* dir_listing = | 274 AsyncDirectoryListing* dir_listing = new AsyncDirectoryListing( |
| 284 new AsyncDirectoryListing(path.CString(), | 275 path.CString(), recursive.Value(), follow_links.Value()); |
| 285 recursive.Value(), | |
| 286 follow_links.Value()); | |
| 287 if (dir_listing->error()) { | 276 if (dir_listing->error()) { |
| 288 // Report error now, so we capture the correct OSError. | 277 // Report error now, so we capture the correct OSError. |
| 289 CObject* err = CObject::NewOSError(); | 278 CObject* err = CObject::NewOSError(); |
| 290 dir_listing->Release(); | 279 dir_listing->Release(); |
| 291 CObjectArray* error = new CObjectArray(CObject::NewArray(3)); | 280 CObjectArray* error = new CObjectArray(CObject::NewArray(3)); |
| 292 error->SetAt(0, new CObjectInt32( | 281 error->SetAt(0, new CObjectInt32(CObject::NewInt32( |
| 293 CObject::NewInt32(AsyncDirectoryListing::kListError))); | 282 AsyncDirectoryListing::kListError))); |
| 294 error->SetAt(1, request[0]); | 283 error->SetAt(1, request[0]); |
| 295 error->SetAt(2, err); | 284 error->SetAt(2, err); |
| 296 return error; | 285 return error; |
| 297 } | 286 } |
| 298 // TODO(ajohnsen): Consider returning the first few results. | 287 // TODO(ajohnsen): Consider returning the first few results. |
| 299 return new CObjectIntptr(CObject::NewIntptr( | 288 return new CObjectIntptr( |
| 300 reinterpret_cast<intptr_t>(dir_listing))); | 289 CObject::NewIntptr(reinterpret_cast<intptr_t>(dir_listing))); |
| 301 } | 290 } |
| 302 return CreateIllegalArgumentError(); | 291 return CreateIllegalArgumentError(); |
| 303 } | 292 } |
| 304 | 293 |
| 305 | 294 |
| 306 CObject* Directory::ListNextRequest(const CObjectArray& request) { | 295 CObject* Directory::ListNextRequest(const CObjectArray& request) { |
| 307 if ((request.Length() == 1) && request[0]->IsIntptr()) { | 296 if ((request.Length() == 1) && request[0]->IsIntptr()) { |
| 308 CObjectIntptr ptr(request[0]); | 297 CObjectIntptr ptr(request[0]); |
| 309 AsyncDirectoryListing* dir_listing = | 298 AsyncDirectoryListing* dir_listing = |
| 310 reinterpret_cast<AsyncDirectoryListing*>(ptr.Value()); | 299 reinterpret_cast<AsyncDirectoryListing*>(ptr.Value()); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 339 // we don't delete the weak persistent handle. The file is closed here, but | 328 // we don't delete the weak persistent handle. The file is closed here, but |
| 340 // the memory for the listing will be cleaned up when the finalizer runs. | 329 // the memory for the listing will be cleaned up when the finalizer runs. |
| 341 dir_listing->PopAll(); | 330 dir_listing->PopAll(); |
| 342 return new CObjectBool(CObject::Bool(true)); | 331 return new CObjectBool(CObject::Bool(true)); |
| 343 } | 332 } |
| 344 return CreateIllegalArgumentError(); | 333 return CreateIllegalArgumentError(); |
| 345 } | 334 } |
| 346 | 335 |
| 347 | 336 |
| 348 CObject* Directory::RenameRequest(const CObjectArray& request) { | 337 CObject* Directory::RenameRequest(const CObjectArray& request) { |
| 349 if ((request.Length() == 2) && | 338 if ((request.Length() == 2) && request[0]->IsString() && |
| 350 request[0]->IsString() && | |
| 351 request[1]->IsString()) { | 339 request[1]->IsString()) { |
| 352 CObjectString path(request[0]); | 340 CObjectString path(request[0]); |
| 353 CObjectString new_path(request[1]); | 341 CObjectString new_path(request[1]); |
| 354 bool completed = Directory::Rename(path.CString(), new_path.CString()); | 342 bool completed = Directory::Rename(path.CString(), new_path.CString()); |
| 355 if (completed) { | 343 if (completed) { |
| 356 return CObject::True(); | 344 return CObject::True(); |
| 357 } | 345 } |
| 358 return CObject::NewOSError(); | 346 return CObject::NewOSError(); |
| 359 } | 347 } |
| 360 return CObject::IllegalArgumentError(); | 348 return CObject::IllegalArgumentError(); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 | 382 |
| 395 | 383 |
| 396 bool AsyncDirectoryListing::HandleError() { | 384 bool AsyncDirectoryListing::HandleError() { |
| 397 CObject* err = CObject::NewOSError(); | 385 CObject* err = CObject::NewOSError(); |
| 398 array_->SetAt(index_++, new CObjectInt32(CObject::NewInt32(kListError))); | 386 array_->SetAt(index_++, new CObjectInt32(CObject::NewInt32(kListError))); |
| 399 CObjectArray* response = new CObjectArray(CObject::NewArray(3)); | 387 CObjectArray* response = new CObjectArray(CObject::NewArray(3)); |
| 400 response->SetAt(0, new CObjectInt32(CObject::NewInt32(kListError))); | 388 response->SetAt(0, new CObjectInt32(CObject::NewInt32(kListError))); |
| 401 // Delay calling CurrentPath() until after CObject::NewOSError() in case | 389 // Delay calling CurrentPath() until after CObject::NewOSError() in case |
| 402 // CurrentPath() pollutes the OS error code. | 390 // CurrentPath() pollutes the OS error code. |
| 403 response->SetAt(1, new CObjectString(CObject::NewString( | 391 response->SetAt(1, new CObjectString(CObject::NewString( |
| 404 error() ? "Invalid path" : CurrentPath()))); | 392 error() ? "Invalid path" : CurrentPath()))); |
| 405 response->SetAt(2, err); | 393 response->SetAt(2, err); |
| 406 array_->SetAt(index_++, response); | 394 array_->SetAt(index_++, response); |
| 407 return index_ < length_; | 395 return index_ < length_; |
| 408 } | 396 } |
| 409 | 397 |
| 410 | 398 |
| 411 bool SyncDirectoryListing::HandleDirectory(const char* dir_name) { | 399 bool SyncDirectoryListing::HandleDirectory(const char* dir_name) { |
| 412 Dart_Handle dir_name_dart = DartUtils::NewString(dir_name); | 400 Dart_Handle dir_name_dart = DartUtils::NewString(dir_name); |
| 413 Dart_Handle dir = | 401 Dart_Handle dir = Dart_New(directory_type_, Dart_Null(), 1, &dir_name_dart); |
| 414 Dart_New(directory_type_, Dart_Null(), 1, &dir_name_dart); | |
| 415 Dart_Handle result = Dart_Invoke(results_, add_string_, 1, &dir); | 402 Dart_Handle result = Dart_Invoke(results_, add_string_, 1, &dir); |
| 416 if (Dart_IsError(result)) { | 403 if (Dart_IsError(result)) { |
| 417 Dart_PropagateError(result); | 404 Dart_PropagateError(result); |
| 418 } | 405 } |
| 419 return true; | 406 return true; |
| 420 } | 407 } |
| 421 | 408 |
| 422 | 409 |
| 423 bool SyncDirectoryListing::HandleLink(const char* link_name) { | 410 bool SyncDirectoryListing::HandleLink(const char* link_name) { |
| 424 Dart_Handle link_name_dart = DartUtils::NewString(link_name); | 411 Dart_Handle link_name_dart = DartUtils::NewString(link_name); |
| 425 Dart_Handle link = | 412 Dart_Handle link = Dart_New(link_type_, Dart_Null(), 1, &link_name_dart); |
| 426 Dart_New(link_type_, Dart_Null(), 1, &link_name_dart); | |
| 427 Dart_Handle result = Dart_Invoke(results_, add_string_, 1, &link); | 413 Dart_Handle result = Dart_Invoke(results_, add_string_, 1, &link); |
| 428 if (Dart_IsError(result)) { | 414 if (Dart_IsError(result)) { |
| 429 Dart_PropagateError(result); | 415 Dart_PropagateError(result); |
| 430 } | 416 } |
| 431 return true; | 417 return true; |
| 432 } | 418 } |
| 433 | 419 |
| 434 | 420 |
| 435 bool SyncDirectoryListing::HandleFile(const char* file_name) { | 421 bool SyncDirectoryListing::HandleFile(const char* file_name) { |
| 436 Dart_Handle file_name_dart = DartUtils::NewString(file_name); | 422 Dart_Handle file_name_dart = DartUtils::NewString(file_name); |
| 437 Dart_Handle file = | 423 Dart_Handle file = Dart_New(file_type_, Dart_Null(), 1, &file_name_dart); |
| 438 Dart_New(file_type_, Dart_Null(), 1, &file_name_dart); | |
| 439 Dart_Handle result = Dart_Invoke(results_, add_string_, 1, &file); | 424 Dart_Handle result = Dart_Invoke(results_, add_string_, 1, &file); |
| 440 if (Dart_IsError(result)) { | 425 if (Dart_IsError(result)) { |
| 441 Dart_PropagateError(result); | 426 Dart_PropagateError(result); |
| 442 } | 427 } |
| 443 return true; | 428 return true; |
| 444 } | 429 } |
| 445 | 430 |
| 446 | 431 |
| 447 bool SyncDirectoryListing::HandleError() { | 432 bool SyncDirectoryListing::HandleError() { |
| 448 Dart_Handle dart_os_error = DartUtils::NewDartOSError(); | 433 Dart_Handle dart_os_error = DartUtils::NewDartOSError(); |
| 449 Dart_Handle args[3]; | 434 Dart_Handle args[3]; |
| 450 args[0] = DartUtils::NewString("Directory listing failed"); | 435 args[0] = DartUtils::NewString("Directory listing failed"); |
| 451 args[1] = DartUtils::NewString(error() ? "Invalid path" : CurrentPath()); | 436 args[1] = DartUtils::NewString(error() ? "Invalid path" : CurrentPath()); |
| 452 args[2] = dart_os_error; | 437 args[2] = dart_os_error; |
| 453 Dart_ThrowException(Dart_New( | 438 Dart_ThrowException(Dart_New( |
| 454 DartUtils::GetDartType(DartUtils::kIOLibURL, "FileSystemException"), | 439 DartUtils::GetDartType(DartUtils::kIOLibURL, "FileSystemException"), |
| 455 Dart_Null(), | 440 Dart_Null(), 3, args)); |
| 456 3, | |
| 457 args)); | |
| 458 return true; | 441 return true; |
| 459 } | 442 } |
| 460 | 443 |
| 461 | 444 |
| 462 static bool ListNext(DirectoryListing* listing) { | 445 static bool ListNext(DirectoryListing* listing) { |
| 463 switch (listing->top()->Next(listing)) { | 446 switch (listing->top()->Next(listing)) { |
| 464 case kListFile: | 447 case kListFile: |
| 465 return listing->HandleFile(listing->CurrentPath()); | 448 return listing->HandleFile(listing->CurrentPath()); |
| 466 | 449 |
| 467 case kListLink: | 450 case kListLink: |
| (...skipping 22 matching lines...) Expand all Loading... |
| 490 } | 473 } |
| 491 return false; | 474 return false; |
| 492 } | 475 } |
| 493 | 476 |
| 494 | 477 |
| 495 void Directory::List(DirectoryListing* listing) { | 478 void Directory::List(DirectoryListing* listing) { |
| 496 if (listing->error()) { | 479 if (listing->error()) { |
| 497 listing->HandleError(); | 480 listing->HandleError(); |
| 498 listing->HandleDone(); | 481 listing->HandleDone(); |
| 499 } else { | 482 } else { |
| 500 while (ListNext(listing)) {} | 483 while (ListNext(listing)) { |
| 484 } |
| 501 } | 485 } |
| 502 } | 486 } |
| 503 | 487 |
| 504 } // namespace bin | 488 } // namespace bin |
| 505 } // namespace dart | 489 } // namespace dart |
| 506 | 490 |
| 507 #endif // !defined(DART_IO_DISABLED) | 491 #endif // !defined(DART_IO_DISABLED) |
| OLD | NEW |