| Index: runtime/bin/directory.cc
|
| diff --git a/runtime/bin/directory.cc b/runtime/bin/directory.cc
|
| index 5cb4296a395e510bd1da6038dbbd8466dcf23b74..24e1326cbc8f847323686302274d89dec8b4989a 100644
|
| --- a/runtime/bin/directory.cc
|
| +++ b/runtime/bin/directory.cc
|
| @@ -18,37 +18,47 @@ static intptr_t GetHandlerPort(Dart_Handle handle) {
|
| void FUNCTION_NAME(Directory_List)(Dart_NativeArguments args) {
|
| Dart_EnterScope();
|
| Dart_Handle path = Dart_GetNativeArgument(args, 1);
|
| - bool recursive = DartUtils::GetBooleanValue(Dart_GetNativeArgument(args, 2));
|
| + Dart_Handle recursive = Dart_GetNativeArgument(args, 2);
|
| Dart_Port dir_port = GetHandlerPort(Dart_GetNativeArgument(args, 3));
|
| Dart_Port file_port = GetHandlerPort(Dart_GetNativeArgument(args, 4));
|
| Dart_Port done_port = GetHandlerPort(Dart_GetNativeArgument(args, 5));
|
| Dart_Port error_port =
|
| GetHandlerPort(Dart_GetNativeArgument(args, 6));
|
| - ASSERT(Dart_IsString(path));
|
| - Directory::List(DartUtils::GetStringValue(path),
|
| - recursive,
|
| - dir_port,
|
| - file_port,
|
| - done_port,
|
| - error_port);
|
| + if (!Dart_IsString(path) || !Dart_IsBoolean(recursive)) {
|
| + Dart_SetReturnValue(args, Dart_NewBoolean(false));
|
| + } else {
|
| + Directory::List(DartUtils::GetStringValue(path),
|
| + DartUtils::GetBooleanValue(recursive),
|
| + dir_port,
|
| + file_port,
|
| + done_port,
|
| + error_port);
|
| + Dart_SetReturnValue(args, Dart_NewBoolean(true));
|
| + }
|
| Dart_ExitScope();
|
| }
|
|
|
|
|
| void FUNCTION_NAME(Directory_Exists)(Dart_NativeArguments args) {
|
| + static const int kError = -1;
|
| + static const int kExists = 1;
|
| + static const int kDoesNotExist = 0;
|
| Dart_EnterScope();
|
| Dart_Handle path = Dart_GetNativeArgument(args, 1);
|
| - ASSERT(Dart_IsString(path));
|
| - Directory::ExistsResult result =
|
| - Directory::Exists(DartUtils::GetStringValue(path));
|
| - int return_value = -1;
|
| - if (result == Directory::EXISTS) {
|
| - return_value = 1;
|
| - }
|
| - if (result == Directory::DOES_NOT_EXIST) {
|
| - return_value = 0;
|
| + if (Dart_IsString(path)) {
|
| + Directory::ExistsResult result =
|
| + Directory::Exists(DartUtils::GetStringValue(path));
|
| + int return_value = kError;
|
| + if (result == Directory::EXISTS) {
|
| + return_value = kExists;
|
| + }
|
| + if (result == Directory::DOES_NOT_EXIST) {
|
| + return_value = kDoesNotExist;
|
| + }
|
| + Dart_SetReturnValue(args, Dart_NewInteger(return_value));
|
| + } else {
|
| + Dart_SetReturnValue(args, Dart_NewInteger(kDoesNotExist));
|
| }
|
| - Dart_SetReturnValue(args, Dart_NewInteger(return_value));
|
| Dart_ExitScope();
|
| }
|
|
|
| @@ -56,9 +66,12 @@ void FUNCTION_NAME(Directory_Exists)(Dart_NativeArguments args) {
|
| 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));
|
| + if (Dart_IsString(path)) {
|
| + bool created = Directory::Create(DartUtils::GetStringValue(path));
|
| + Dart_SetReturnValue(args, Dart_NewBoolean(created));
|
| + } else {
|
| + Dart_SetReturnValue(args, Dart_NewBoolean(false));
|
| + }
|
| Dart_ExitScope();
|
| }
|
|
|
| @@ -66,8 +79,11 @@ void FUNCTION_NAME(Directory_Create)(Dart_NativeArguments args) {
|
| 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));
|
| + if (Dart_IsString(path)) {
|
| + bool deleted = Directory::Delete(DartUtils::GetStringValue(path));
|
| + Dart_SetReturnValue(args, Dart_NewBoolean(deleted));
|
| + } else {
|
| + Dart_SetReturnValue(args, Dart_NewBoolean(false));
|
| + }
|
| Dart_ExitScope();
|
| }
|
|
|