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

Unified Diff: runtime/bin/directory.cc

Issue 8934004: Add support for getting OS error information for creating temporary directories (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Added path to exception messages Created 9 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/directory.h ('k') | runtime/bin/directory.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/directory.cc
diff --git a/runtime/bin/directory.cc b/runtime/bin/directory.cc
index 6b6b0cc5d77b39a88b6f040aec66340110695635..ece92ae9caa6586248fb30b54b14f28e83ab44f2 100644
--- a/runtime/bin/directory.cc
+++ b/runtime/bin/directory.cc
@@ -80,13 +80,40 @@ void FUNCTION_NAME(Directory_CreateTemp)(Dart_NativeArguments args) {
Dart_EnterScope();
Dart_Handle path = Dart_GetNativeArgument(args, 0);
Dart_Handle number = Dart_GetNativeArgument(args, 1);
- if (Dart_IsString(path) && Dart_IsInteger(number)) {
- char* result = Directory::CreateTemp(DartUtils::GetStringValue(path),
- DartUtils::GetIntegerValue(number));
+ Dart_Handle status_handle = Dart_GetNativeArgument(args, 2);
+ static const int kMaxChildOsErrorMessageLength = 256;
+ char os_error_message[kMaxChildOsErrorMessageLength];
+ if (!Dart_IsString(path) || !Dart_IsInteger(number)) {
+ DartUtils::SetIntegerInstanceField(status_handle, "_errorCode", 0);
+ DartUtils::SetStringInstanceField(
+ status_handle, "_errorMessage", "Invalid arguments");
+ Dart_SetReturnValue(args, Dart_Null());
+ Dart_ExitScope();
+ return;
+ }
+
+ char* result = NULL;
+ int error_code = Directory::CreateTemp(DartUtils::GetStringValue(path),
+ DartUtils::GetIntegerValue(number),
+ &result,
+ os_error_message,
+ kMaxChildOsErrorMessageLength);
+ if (error_code == 0) {
Dart_SetReturnValue(args, Dart_NewString(result));
free(result);
} else {
- Dart_SetReturnValue(args, Dart_NewString(""));
+ ASSERT(result == NULL);
+ if (error_code == -1) {
+ DartUtils::SetIntegerInstanceField(status_handle, "_errorCode", 0);
+ DartUtils::SetStringInstanceField(
+ status_handle, "_errorMessage", "Invalid arguments");
+ } else {
+ DartUtils::SetIntegerInstanceField(
+ status_handle, "_errorCode", error_code);
+ DartUtils::SetStringInstanceField(
+ status_handle, "_errorMessage", os_error_message);
+ }
+ Dart_SetReturnValue(args, Dart_Null());
}
Dart_ExitScope();
}
« no previous file with comments | « runtime/bin/directory.h ('k') | runtime/bin/directory.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698