Chromium Code Reviews| Index: runtime/bin/directory.cc |
| diff --git a/runtime/bin/directory.cc b/runtime/bin/directory.cc |
| index d600f3df935d5fba08910b18008eceb2797c7328..6988b0ac212c4814c6e447ec73a638d5dcdd5a56 100644 |
| --- a/runtime/bin/directory.cc |
| +++ b/runtime/bin/directory.cc |
| @@ -9,7 +9,6 @@ |
| static intptr_t GetHandlerPort(Dart_Handle handle) { |
| if (Dart_IsNull(handle)) { |
| - // TODO(ager): Generalize this to Directory::kInvalidId. |
| return 0; |
| } |
| return DartUtils::GetIntegerInstanceField(handle, DartUtils::kIdFieldName); |
| @@ -34,3 +33,35 @@ void FUNCTION_NAME(Directory_List)(Dart_NativeArguments args) { |
| error_port); |
| Dart_ExitScope(); |
| } |
| + |
| + |
| +void FUNCTION_NAME(Directory_Exists)(Dart_NativeArguments args) { |
| + Dart_EnterScope(); |
| + Dart_Handle path = Dart_GetNativeArgument(args, 1); |
| + ASSERT(Dart_IsString(path)); |
| + bool exists = false; |
| + bool success = Directory::Exists(DartUtils::GetStringValue(path), &exists); |
|
Søren Gjesse
2011/10/14 11:44:14
How about returning an enum Yes/No/Don't know inst
Mads Ager (google)
2011/10/14 12:22:54
Done.
|
| + int return_value = success ? (exists ? 1 : 0) : -1; |
| + Dart_SetReturnValue(args, Dart_NewInteger(return_value)); |
| + Dart_ExitScope(); |
| +} |
| + |
| + |
| +void FUNCTION_NAME(Directory_Create)(Dart_NativeArguments args) { |
| + Dart_EnterScope(); |
| + Dart_Handle path = Dart_GetNativeArgument(args, 1); |
| + ASSERT(Dart_IsString(path)); |
| + bool created = Directory::Create(DartUtils::GetStringValue(path)); |
| + Dart_SetReturnValue(args, Dart_NewBoolean(created)); |
| + Dart_ExitScope(); |
| +} |
| + |
| + |
| +void FUNCTION_NAME(Directory_Delete)(Dart_NativeArguments args) { |
| + Dart_EnterScope(); |
| + Dart_Handle path = Dart_GetNativeArgument(args, 1); |
| + ASSERT(Dart_IsString(path)); |
| + bool deleted = Directory::Delete(DartUtils::GetStringValue(path)); |
| + Dart_SetReturnValue(args, Dart_NewBoolean(deleted)); |
| + Dart_ExitScope(); |
| +} |