OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "bin/directory.h" | 5 #include "bin/directory.h" |
6 | 6 |
7 #include "bin/dartutils.h" | 7 #include "bin/dartutils.h" |
8 #include "bin/thread.h" | 8 #include "bin/thread.h" |
9 #include "include/dart_api.h" | 9 #include "include/dart_api.h" |
10 #include "platform/assert.h" | 10 #include "platform/assert.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 if (Directory::Create(DartUtils::GetStringValue(path))) { | 69 if (Directory::Create(DartUtils::GetStringValue(path))) { |
70 Dart_SetReturnValue(args, Dart_True()); | 70 Dart_SetReturnValue(args, Dart_True()); |
71 } else { | 71 } else { |
72 Dart_Handle err = DartUtils::NewDartOSError(); | 72 Dart_Handle err = DartUtils::NewDartOSError(); |
73 if (Dart_IsError(err)) Dart_PropagateError(err); | 73 if (Dart_IsError(err)) Dart_PropagateError(err); |
74 Dart_SetReturnValue(args, err); | 74 Dart_SetReturnValue(args, err); |
75 } | 75 } |
76 } | 76 } |
77 | 77 |
78 | 78 |
| 79 void FUNCTION_NAME(Directory_SystemTemp)( |
| 80 Dart_NativeArguments args) { |
| 81 char* result = Directory::SystemTemp(); |
| 82 Dart_SetReturnValue(args, DartUtils::NewString(result)); |
| 83 } |
| 84 |
| 85 |
79 void FUNCTION_NAME(Directory_CreateTemp)(Dart_NativeArguments args) { | 86 void FUNCTION_NAME(Directory_CreateTemp)(Dart_NativeArguments args) { |
80 Dart_Handle path = Dart_GetNativeArgument(args, 0); | 87 Dart_Handle path = Dart_GetNativeArgument(args, 0); |
81 Dart_Handle system = Dart_GetNativeArgument(args, 1); | |
82 if (!Dart_IsString(path)) { | 88 if (!Dart_IsString(path)) { |
83 Dart_SetReturnValue(args, DartUtils::NewDartArgumentError( | 89 Dart_SetReturnValue(args, DartUtils::NewDartArgumentError( |
84 "Template argument of CreateSystemTempSync is not a String")); | 90 "Prefix argument of CreateSystemTempSync is not a String")); |
85 return; | 91 return; |
86 } | 92 } |
87 char* result = Directory::CreateTemp(DartUtils::GetStringValue(path), | 93 char* result = Directory::CreateTemp(DartUtils::GetStringValue(path)); |
88 DartUtils::GetBooleanValue(system)); | |
89 if (result != NULL) { | 94 if (result != NULL) { |
90 Dart_SetReturnValue(args, DartUtils::NewString(result)); | 95 Dart_SetReturnValue(args, DartUtils::NewString(result)); |
91 free(result); | 96 free(result); |
92 } else { | 97 } else { |
93 Dart_Handle err = DartUtils::NewDartOSError(); | 98 Dart_Handle err = DartUtils::NewDartOSError(); |
94 if (Dart_IsError(err)) Dart_PropagateError(err); | 99 if (Dart_IsError(err)) Dart_PropagateError(err); |
95 Dart_SetReturnValue(args, err); | 100 Dart_SetReturnValue(args, err); |
96 } | 101 } |
97 } | 102 } |
98 | 103 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 return CObject::NewOSError(); | 193 return CObject::NewOSError(); |
189 } | 194 } |
190 } | 195 } |
191 return CObject::IllegalArgumentError(); | 196 return CObject::IllegalArgumentError(); |
192 } | 197 } |
193 | 198 |
194 | 199 |
195 CObject* Directory::CreateTempRequest(const CObjectArray& request) { | 200 CObject* Directory::CreateTempRequest(const CObjectArray& request) { |
196 if (request.Length() == 1 && request[0]->IsString()) { | 201 if (request.Length() == 1 && request[0]->IsString()) { |
197 CObjectString path(request[0]); | 202 CObjectString path(request[0]); |
198 char* result = Directory::CreateTemp(path.CString(), false); | 203 char* result = Directory::CreateTemp(path.CString()); |
199 if (result != NULL) { | 204 if (result != NULL) { |
200 CObject* temp_dir = new CObjectString(CObject::NewString(result)); | 205 CObject* temp_dir = new CObjectString(CObject::NewString(result)); |
201 free(result); | 206 free(result); |
202 return temp_dir; | |
203 } else { | |
204 return CObject::NewOSError(); | |
205 } | |
206 } | |
207 return CObject::IllegalArgumentError(); | |
208 } | |
209 | |
210 | |
211 CObject* Directory::CreateSystemTempRequest(const CObjectArray& request) { | |
212 if (request.Length() == 1 && request[0]->IsString()) { | |
213 CObjectString path(request[0]); | |
214 char* result = Directory::CreateTemp(path.CString(), true); | |
215 if (result != NULL) { | |
216 CObject* temp_dir = new CObjectString(CObject::NewString(result)); | |
217 free(result); | |
218 return temp_dir; | 207 return temp_dir; |
219 } else { | 208 } else { |
220 return CObject::NewOSError(); | 209 return CObject::NewOSError(); |
221 } | 210 } |
222 } | 211 } |
223 return CObject::IllegalArgumentError(); | 212 return CObject::IllegalArgumentError(); |
224 } | 213 } |
225 | 214 |
226 | 215 |
227 static CObject* CreateIllegalArgumentError() { | 216 static CObject* CreateIllegalArgumentError() { |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 if (listing->error()) { | 417 if (listing->error()) { |
429 listing->HandleError("Invalid path"); | 418 listing->HandleError("Invalid path"); |
430 listing->HandleDone(); | 419 listing->HandleDone(); |
431 } else { | 420 } else { |
432 while (ListNext(listing)) {} | 421 while (ListNext(listing)) {} |
433 } | 422 } |
434 } | 423 } |
435 | 424 |
436 } // namespace bin | 425 } // namespace bin |
437 } // namespace dart | 426 } // namespace dart |
OLD | NEW |