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

Unified Diff: runtime/bin/directory.cc

Issue 25279003: dart:io | Add Directory.CreateSystemTemp(template) and change Directory.CreateTemp(template). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add check of "TMP" environment variable if "TMPDIR" is missing. Created 7 years, 3 months 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_android.cc » ('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 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"));
+ 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() &&
« no previous file with comments | « runtime/bin/directory.h ('k') | runtime/bin/directory_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698