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

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

Issue 1904553006: Fix strong mode errors in dart:io. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fix directory_list rename for dartium. Created 4 years, 7 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
« no previous file with comments | « no previous file | runtime/bin/directory_patch.dart » ('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 #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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 Dart_Handle newPath = Dart_GetNativeArgument(args, 1); 108 Dart_Handle newPath = Dart_GetNativeArgument(args, 1);
109 if (Directory::Rename(DartUtils::GetStringValue(path), 109 if (Directory::Rename(DartUtils::GetStringValue(path),
110 DartUtils::GetStringValue(newPath))) { 110 DartUtils::GetStringValue(newPath))) {
111 Dart_SetReturnValue(args, Dart_True()); 111 Dart_SetReturnValue(args, Dart_True());
112 } else { 112 } else {
113 Dart_SetReturnValue(args, DartUtils::NewDartOSError()); 113 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
114 } 114 }
115 } 115 }
116 116
117 117
118 void FUNCTION_NAME(Directory_List)(Dart_NativeArguments args) { 118 void FUNCTION_NAME(Directory_FillWithDirectoryListing)(
119 Dart_Handle path = Dart_GetNativeArgument(args, 0); 119 Dart_NativeArguments args) {
120 Dart_Handle recursive = Dart_GetNativeArgument(args, 1); 120 // The list that we should fill.
121 // Create the list to hold the directory listing here, and pass it to the 121 Dart_Handle results = Dart_GetNativeArgument(args, 0);
122 Dart_Handle path = Dart_GetNativeArgument(args, 1);
123 Dart_Handle recursive = Dart_GetNativeArgument(args, 2);
124 Dart_Handle follow_links = Dart_GetNativeArgument(args, 3);
125 // Pass the list that should hold the directory listing to the
122 // SyncDirectoryListing object, which adds elements to it. 126 // SyncDirectoryListing object, which adds elements to it.
123 Dart_Handle follow_links = Dart_GetNativeArgument(args, 2);
124 // Create the list to hold the directory listing here, and pass it to the
125 // SyncDirectoryListing object, which adds elements to it.
126 Dart_Handle results =
127 Dart_New(DartUtils::GetDartType(DartUtils::kCoreLibURL, "List"),
128 Dart_Null(),
129 0,
130 NULL);
131 if (Dart_IsError(results)) {
132 Dart_PropagateError(results);
133 }
134 SyncDirectoryListing sync_listing(results, 127 SyncDirectoryListing sync_listing(results,
135 DartUtils::GetStringValue(path), 128 DartUtils::GetStringValue(path),
136 DartUtils::GetBooleanValue(recursive), 129 DartUtils::GetBooleanValue(recursive),
137 DartUtils::GetBooleanValue(follow_links)); 130 DartUtils::GetBooleanValue(follow_links));
138 Directory::List(&sync_listing); 131 Directory::List(&sync_listing);
139 Dart_SetReturnValue(args, results);
140 } 132 }
141 133
142 134
143 static const int kAsyncDirectoryListerFieldIndex = 0; 135 static const int kAsyncDirectoryListerFieldIndex = 0;
144 136
145 137
146 void FUNCTION_NAME(Directory_GetAsyncDirectoryListerPointer)( 138 void FUNCTION_NAME(Directory_GetAsyncDirectoryListerPointer)(
147 Dart_NativeArguments args) { 139 Dart_NativeArguments args) {
148 AsyncDirectoryListing* listing; 140 AsyncDirectoryListing* listing;
149 Dart_Handle dart_this = ThrowIfError(Dart_GetNativeArgument(args, 0)); 141 Dart_Handle dart_this = ThrowIfError(Dart_GetNativeArgument(args, 0));
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 response->SetAt(2, err); 392 response->SetAt(2, err);
401 array_->SetAt(index_++, response); 393 array_->SetAt(index_++, response);
402 return index_ < length_; 394 return index_ < length_;
403 } 395 }
404 396
405 397
406 bool SyncDirectoryListing::HandleDirectory(const char* dir_name) { 398 bool SyncDirectoryListing::HandleDirectory(const char* dir_name) {
407 Dart_Handle dir_name_dart = DartUtils::NewString(dir_name); 399 Dart_Handle dir_name_dart = DartUtils::NewString(dir_name);
408 Dart_Handle dir = 400 Dart_Handle dir =
409 Dart_New(directory_type_, Dart_Null(), 1, &dir_name_dart); 401 Dart_New(directory_type_, Dart_Null(), 1, &dir_name_dart);
410 Dart_Invoke(results_, add_string_, 1, &dir); 402 Dart_Handle result = Dart_Invoke(results_, add_string_, 1, &dir);
403 if (Dart_IsError(result)) {
404 Dart_PropagateError(result);
405 }
411 return true; 406 return true;
412 } 407 }
413 408
414 409
415 bool SyncDirectoryListing::HandleLink(const char* link_name) { 410 bool SyncDirectoryListing::HandleLink(const char* link_name) {
416 Dart_Handle link_name_dart = DartUtils::NewString(link_name); 411 Dart_Handle link_name_dart = DartUtils::NewString(link_name);
417 Dart_Handle link = 412 Dart_Handle link =
418 Dart_New(link_type_, Dart_Null(), 1, &link_name_dart); 413 Dart_New(link_type_, Dart_Null(), 1, &link_name_dart);
419 Dart_Invoke(results_, add_string_, 1, &link); 414 Dart_Handle result = Dart_Invoke(results_, add_string_, 1, &link);
415 if (Dart_IsError(result)) {
416 Dart_PropagateError(result);
417 }
420 return true; 418 return true;
421 } 419 }
422 420
423 421
424 bool SyncDirectoryListing::HandleFile(const char* file_name) { 422 bool SyncDirectoryListing::HandleFile(const char* file_name) {
425 Dart_Handle file_name_dart = DartUtils::NewString(file_name); 423 Dart_Handle file_name_dart = DartUtils::NewString(file_name);
426 Dart_Handle file = 424 Dart_Handle file =
427 Dart_New(file_type_, Dart_Null(), 1, &file_name_dart); 425 Dart_New(file_type_, Dart_Null(), 1, &file_name_dart);
428 Dart_Invoke(results_, add_string_, 1, &file); 426 Dart_Handle result = Dart_Invoke(results_, add_string_, 1, &file);
427 if (Dart_IsError(result)) {
428 Dart_PropagateError(result);
429 }
429 return true; 430 return true;
430 } 431 }
431 432
432 433
433 bool SyncDirectoryListing::HandleError() { 434 bool SyncDirectoryListing::HandleError() {
434 Dart_Handle dart_os_error = DartUtils::NewDartOSError(); 435 Dart_Handle dart_os_error = DartUtils::NewDartOSError();
435 Dart_Handle args[3]; 436 Dart_Handle args[3];
436 args[0] = DartUtils::NewString("Directory listing failed"); 437 args[0] = DartUtils::NewString("Directory listing failed");
437 args[1] = DartUtils::NewString(error() ? "Invalid path" : CurrentPath()); 438 args[1] = DartUtils::NewString(error() ? "Invalid path" : CurrentPath());
438 args[2] = dart_os_error; 439 args[2] = dart_os_error;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 listing->HandleDone(); 485 listing->HandleDone();
485 } else { 486 } else {
486 while (ListNext(listing)) {} 487 while (ListNext(listing)) {}
487 } 488 }
488 } 489 }
489 490
490 } // namespace bin 491 } // namespace bin
491 } // namespace dart 492 } // namespace dart
492 493
493 #endif // !defined(DART_IO_DISABLED) 494 #endif // !defined(DART_IO_DISABLED)
OLDNEW
« no previous file with comments | « no previous file | runtime/bin/directory_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698