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

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

Issue 13896034: Add the ability to change the working directory (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixed tests Created 7 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 | Annotate | Revision Log
« no previous file with comments | « runtime/bin/directory.h ('k') | runtime/bin/directory_android.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 14 matching lines...) Expand all
25 Dart_EnterScope(); 25 Dart_EnterScope();
26 char* current = Directory::Current(); 26 char* current = Directory::Current();
27 if (current != NULL) { 27 if (current != NULL) {
28 Dart_SetReturnValue(args, DartUtils::NewString(current)); 28 Dart_SetReturnValue(args, DartUtils::NewString(current));
29 free(current); 29 free(current);
30 } 30 }
31 Dart_ExitScope(); 31 Dart_ExitScope();
32 } 32 }
33 33
34 34
35 void FUNCTION_NAME(Directory_SetCurrent)(Dart_NativeArguments args) {
36 Dart_EnterScope();
37 int argc = Dart_GetNativeArgumentCount(args);
38 Dart_Handle path;
39 if (argc == 1) {
40 path = Dart_GetNativeArgument(args, 0);
41 }
42 if (argc != 1 || !Dart_IsString(path)) {
43 Dart_SetReturnValue(args, DartUtils::NewDartArgumentError(NULL));
44 } else {
45 if (Directory::SetCurrent(DartUtils::GetStringValue(path))) {
46 Dart_SetReturnValue(args, Dart_True());
47 } else {
48 Dart_Handle err = DartUtils::NewDartOSError();
49 if (Dart_IsError(err)) Dart_PropagateError(err);
50 Dart_SetReturnValue(args, err);
51 }
52 }
53 Dart_ExitScope();
54 }
55
56
35 void FUNCTION_NAME(Directory_Exists)(Dart_NativeArguments args) { 57 void FUNCTION_NAME(Directory_Exists)(Dart_NativeArguments args) {
36 static const int kExists = 1; 58 static const int kExists = 1;
37 static const int kDoesNotExist = 0; 59 static const int kDoesNotExist = 0;
38 Dart_EnterScope(); 60 Dart_EnterScope();
39 Dart_Handle path = Dart_GetNativeArgument(args, 0); 61 Dart_Handle path = Dart_GetNativeArgument(args, 0);
40 Directory::ExistsResult result = 62 Directory::ExistsResult result =
41 Directory::Exists(DartUtils::GetStringValue(path)); 63 Directory::Exists(DartUtils::GetStringValue(path));
42 if (result == Directory::EXISTS) { 64 if (result == Directory::EXISTS) {
43 Dart_SetReturnValue(args, Dart_NewInteger(kExists)); 65 Dart_SetReturnValue(args, Dart_NewInteger(kExists));
44 } else if (result == Directory::DOES_NOT_EXIST) { 66 } else if (result == Directory::DOES_NOT_EXIST) {
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 Dart_ThrowException(Dart_New( 396 Dart_ThrowException(Dart_New(
375 DartUtils::GetDartClass(DartUtils::kIOLibURL, "DirectoryIOException"), 397 DartUtils::GetDartClass(DartUtils::kIOLibURL, "DirectoryIOException"),
376 Dart_Null(), 398 Dart_Null(),
377 3, 399 3,
378 args)); 400 args));
379 return true; 401 return true;
380 } 402 }
381 403
382 } // namespace bin 404 } // namespace bin
383 } // namespace dart 405 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/bin/directory.h ('k') | runtime/bin/directory_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698