Chromium Code Reviews| 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 14 matching lines...) Expand all Loading... | |
| 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 printf("XXX\n"); | |
|
Bill Hesse
2013/04/29 11:01:12
Remove debug printing.
Søren Gjesse
2013/04/29 11:59:15
Done.
| |
| 44 Dart_SetReturnValue(args, DartUtils::NewDartArgumentError(NULL)); | |
| 45 } else { | |
| 46 if (Directory::SetCurrent(DartUtils::GetStringValue(path))) { | |
| 47 Dart_SetReturnValue(args, Dart_True()); | |
| 48 } else { | |
| 49 Dart_Handle err = DartUtils::NewDartOSError(); | |
| 50 if (Dart_IsError(err)) Dart_PropagateError(err); | |
| 51 Dart_SetReturnValue(args, err); | |
| 52 } | |
| 53 } | |
| 54 Dart_ExitScope(); | |
| 55 } | |
| 56 | |
| 57 | |
| 35 void FUNCTION_NAME(Directory_Exists)(Dart_NativeArguments args) { | 58 void FUNCTION_NAME(Directory_Exists)(Dart_NativeArguments args) { |
| 36 static const int kExists = 1; | 59 static const int kExists = 1; |
| 37 static const int kDoesNotExist = 0; | 60 static const int kDoesNotExist = 0; |
| 38 Dart_EnterScope(); | 61 Dart_EnterScope(); |
| 39 Dart_Handle path = Dart_GetNativeArgument(args, 0); | 62 Dart_Handle path = Dart_GetNativeArgument(args, 0); |
| 40 Directory::ExistsResult result = | 63 Directory::ExistsResult result = |
| 41 Directory::Exists(DartUtils::GetStringValue(path)); | 64 Directory::Exists(DartUtils::GetStringValue(path)); |
| 42 if (result == Directory::EXISTS) { | 65 if (result == Directory::EXISTS) { |
| 43 Dart_SetReturnValue(args, Dart_NewInteger(kExists)); | 66 Dart_SetReturnValue(args, Dart_NewInteger(kExists)); |
| 44 } else if (result == Directory::DOES_NOT_EXIST) { | 67 } else if (result == Directory::DOES_NOT_EXIST) { |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 374 Dart_ThrowException(Dart_New( | 397 Dart_ThrowException(Dart_New( |
| 375 DartUtils::GetDartClass(DartUtils::kIOLibURL, "DirectoryIOException"), | 398 DartUtils::GetDartClass(DartUtils::kIOLibURL, "DirectoryIOException"), |
| 376 Dart_Null(), | 399 Dart_Null(), |
| 377 3, | 400 3, |
| 378 args)); | 401 args)); |
| 379 return true; | 402 return true; |
| 380 } | 403 } |
| 381 | 404 |
| 382 } // namespace bin | 405 } // namespace bin |
| 383 } // namespace dart | 406 } // namespace dart |
| OLD | NEW |