Chromium Code Reviews| Index: runtime/bin/directory.cc |
| diff --git a/runtime/bin/directory.cc b/runtime/bin/directory.cc |
| index 323b4a984383c81178602259874fb2089b8f7750..6aa4d09e1190296b68281b11bbeeff6b354fb4e3 100644 |
| --- a/runtime/bin/directory.cc |
| +++ b/runtime/bin/directory.cc |
| @@ -78,7 +78,14 @@ void FUNCTION_NAME(Directory_Create)(Dart_NativeArguments args) { |
| void FUNCTION_NAME(Directory_CreateTemp)(Dart_NativeArguments args) { |
| Dart_Handle path = Dart_GetNativeArgument(args, 0); |
| - char* result = Directory::CreateTemp(DartUtils::GetStringValue(path)); |
| + Dart_Handle system = Dart_GetNativeArgument(args, 1); |
| + if (!Dart_IsString(path)) { |
| + Dart_SetReturnValue(args, DartUtils::NewDartArgumentError( |
| + "Template argument of CreateSystemTempSync is not a String")); |
|
Bill Hesse
2013/10/01 13:27:27
Only CreateSystemTempSync can reach here, not Crea
|
| + return; |
| + } |
| + char* result = Directory::CreateTemp(DartUtils::GetStringValue(path), |
| + DartUtils::GetBooleanValue(system)); |
| if (result != NULL) { |
| Dart_SetReturnValue(args, DartUtils::NewString(result)); |
| free(result); |
| @@ -188,7 +195,7 @@ CObject* Directory::ExistsRequest(const CObjectArray& request) { |
| CObject* Directory::CreateTempRequest(const CObjectArray& request) { |
| if (request.Length() == 1 && request[0]->IsString()) { |
| CObjectString path(request[0]); |
| - char* result = Directory::CreateTemp(path.CString()); |
| + char* result = Directory::CreateTemp(path.CString(), false); |
| if (result != NULL) { |
| CObject* temp_dir = new CObjectString(CObject::NewString(result)); |
| free(result); |
| @@ -200,6 +207,23 @@ CObject* Directory::CreateTempRequest(const CObjectArray& request) { |
| return CObject::IllegalArgumentError(); |
| } |
| + |
| +CObject* Directory::CreateSystemTempRequest(const CObjectArray& request) { |
| + if (request.Length() == 1 && request[0]->IsString()) { |
| + CObjectString path(request[0]); |
| + char* result = Directory::CreateTemp(path.CString(), true); |
| + if (result != NULL) { |
| + CObject* temp_dir = new CObjectString(CObject::NewString(result)); |
| + free(result); |
| + return temp_dir; |
| + } else { |
| + return CObject::NewOSError(); |
| + } |
| + } |
| + return CObject::IllegalArgumentError(); |
| +} |
| + |
| + |
| static CObject* CreateIllegalArgumentError() { |
| // Respond with an illegal argument list error message. |
| CObjectArray* error = new CObjectArray(CObject::NewArray(3)); |
| @@ -210,6 +234,7 @@ static CObject* CreateIllegalArgumentError() { |
| return error; |
| } |
| + |
| CObject* Directory::ListStartRequest(const CObjectArray& request) { |
| if (request.Length() == 3 && |
| request[0]->IsString() && |