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

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: Few fixes 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 Dart_Handle results = Dart_GetNativeArgument(args, 0);
122 Dart_Handle path = Dart_GetNativeArgument(args, 1);
123 Dart_Handle recursive = Dart_GetNativeArgument(args, 2);
121 // Create the list to hold the directory listing here, and pass it to the 124 // Create the list to hold the directory listing here, and pass it to the
Florian Schneider 2016/05/10 08:19:10 This comment is out of date now since the list is
floitsch 2016/05/10 13:37:35 I thought I had deleted that comment. Thanks and d
122 // SyncDirectoryListing object, which adds elements to it. 125 // SyncDirectoryListing object, which adds elements to it.
123 Dart_Handle follow_links = Dart_GetNativeArgument(args, 2); 126 Dart_Handle follow_links = Dart_GetNativeArgument(args, 3);
124 // Create the list to hold the directory listing here, and pass it to the 127 // Pass the list that should hold the directory listing to the
125 // SyncDirectoryListing object, which adds elements to it. 128 // 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, 129 SyncDirectoryListing sync_listing(results,
135 DartUtils::GetStringValue(path), 130 DartUtils::GetStringValue(path),
136 DartUtils::GetBooleanValue(recursive), 131 DartUtils::GetBooleanValue(recursive),
137 DartUtils::GetBooleanValue(follow_links)); 132 DartUtils::GetBooleanValue(follow_links));
138 Directory::List(&sync_listing); 133 Directory::List(&sync_listing);
139 Dart_SetReturnValue(args, results);
140 } 134 }
141 135
142 136
143 static const int kAsyncDirectoryListerFieldIndex = 0; 137 static const int kAsyncDirectoryListerFieldIndex = 0;
144 138
145 139
146 void FUNCTION_NAME(Directory_GetAsyncDirectoryListerPointer)( 140 void FUNCTION_NAME(Directory_GetAsyncDirectoryListerPointer)(
147 Dart_NativeArguments args) { 141 Dart_NativeArguments args) {
148 AsyncDirectoryListing* listing; 142 AsyncDirectoryListing* listing;
149 Dart_Handle dart_this = ThrowIfError(Dart_GetNativeArgument(args, 0)); 143 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); 394 response->SetAt(2, err);
401 array_->SetAt(index_++, response); 395 array_->SetAt(index_++, response);
402 return index_ < length_; 396 return index_ < length_;
403 } 397 }
404 398
405 399
406 bool SyncDirectoryListing::HandleDirectory(const char* dir_name) { 400 bool SyncDirectoryListing::HandleDirectory(const char* dir_name) {
407 Dart_Handle dir_name_dart = DartUtils::NewString(dir_name); 401 Dart_Handle dir_name_dart = DartUtils::NewString(dir_name);
408 Dart_Handle dir = 402 Dart_Handle dir =
409 Dart_New(directory_type_, Dart_Null(), 1, &dir_name_dart); 403 Dart_New(directory_type_, Dart_Null(), 1, &dir_name_dart);
410 Dart_Invoke(results_, add_string_, 1, &dir); 404 Dart_Handle result = Dart_Invoke(results_, add_string_, 1, &dir);
405 if (Dart_IsError(result)) {
406 Dart_PropagateError(result);
407 }
411 return true; 408 return true;
412 } 409 }
413 410
414 411
415 bool SyncDirectoryListing::HandleLink(const char* link_name) { 412 bool SyncDirectoryListing::HandleLink(const char* link_name) {
416 Dart_Handle link_name_dart = DartUtils::NewString(link_name); 413 Dart_Handle link_name_dart = DartUtils::NewString(link_name);
417 Dart_Handle link = 414 Dart_Handle link =
418 Dart_New(link_type_, Dart_Null(), 1, &link_name_dart); 415 Dart_New(link_type_, Dart_Null(), 1, &link_name_dart);
419 Dart_Invoke(results_, add_string_, 1, &link); 416 Dart_Handle result = Dart_Invoke(results_, add_string_, 1, &link);
417 if (Dart_IsError(result)) {
418 Dart_PropagateError(result);
419 }
420 return true; 420 return true;
421 } 421 }
422 422
423 423
424 bool SyncDirectoryListing::HandleFile(const char* file_name) { 424 bool SyncDirectoryListing::HandleFile(const char* file_name) {
425 Dart_Handle file_name_dart = DartUtils::NewString(file_name); 425 Dart_Handle file_name_dart = DartUtils::NewString(file_name);
426 Dart_Handle file = 426 Dart_Handle file =
427 Dart_New(file_type_, Dart_Null(), 1, &file_name_dart); 427 Dart_New(file_type_, Dart_Null(), 1, &file_name_dart);
428 Dart_Invoke(results_, add_string_, 1, &file); 428 Dart_Handle result = Dart_Invoke(results_, add_string_, 1, &file);
429 if (Dart_IsError(result)) {
430 Dart_PropagateError(result);
431 }
429 return true; 432 return true;
430 } 433 }
431 434
432 435
433 bool SyncDirectoryListing::HandleError() { 436 bool SyncDirectoryListing::HandleError() {
434 Dart_Handle dart_os_error = DartUtils::NewDartOSError(); 437 Dart_Handle dart_os_error = DartUtils::NewDartOSError();
435 Dart_Handle args[3]; 438 Dart_Handle args[3];
436 args[0] = DartUtils::NewString("Directory listing failed"); 439 args[0] = DartUtils::NewString("Directory listing failed");
437 args[1] = DartUtils::NewString(error() ? "Invalid path" : CurrentPath()); 440 args[1] = DartUtils::NewString(error() ? "Invalid path" : CurrentPath());
438 args[2] = dart_os_error; 441 args[2] = dart_os_error;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 listing->HandleDone(); 487 listing->HandleDone();
485 } else { 488 } else {
486 while (ListNext(listing)) {} 489 while (ListNext(listing)) {}
487 } 490 }
488 } 491 }
489 492
490 } // namespace bin 493 } // namespace bin
491 } // namespace dart 494 } // namespace dart
492 495
493 #endif // !defined(DART_IO_DISABLED) 496 #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