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 free(result); |
| 84 } |
| 85 |
| 86 |
79 void FUNCTION_NAME(Directory_CreateTemp)(Dart_NativeArguments args) { | 87 void FUNCTION_NAME(Directory_CreateTemp)(Dart_NativeArguments args) { |
80 Dart_Handle path = Dart_GetNativeArgument(args, 0); | 88 Dart_Handle path = Dart_GetNativeArgument(args, 0); |
81 Dart_Handle system = Dart_GetNativeArgument(args, 1); | |
82 if (!Dart_IsString(path)) { | 89 if (!Dart_IsString(path)) { |
83 Dart_SetReturnValue(args, DartUtils::NewDartArgumentError( | 90 Dart_SetReturnValue(args, DartUtils::NewDartArgumentError( |
84 "Template argument of CreateSystemTempSync is not a String")); | 91 "Prefix argument of CreateSystemTempSync is not a String")); |
85 return; | 92 return; |
86 } | 93 } |
87 char* result = Directory::CreateTemp(DartUtils::GetStringValue(path), | 94 char* result = Directory::CreateTemp(DartUtils::GetStringValue(path)); |
88 DartUtils::GetBooleanValue(system)); | |
89 if (result != NULL) { | 95 if (result != NULL) { |
90 Dart_SetReturnValue(args, DartUtils::NewString(result)); | 96 Dart_SetReturnValue(args, DartUtils::NewString(result)); |
91 free(result); | 97 free(result); |
92 } else { | 98 } else { |
93 Dart_Handle err = DartUtils::NewDartOSError(); | 99 Dart_Handle err = DartUtils::NewDartOSError(); |
94 if (Dart_IsError(err)) Dart_PropagateError(err); | 100 if (Dart_IsError(err)) Dart_PropagateError(err); |
95 Dart_SetReturnValue(args, err); | 101 Dart_SetReturnValue(args, err); |
96 } | 102 } |
97 } | 103 } |
98 | 104 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 return CObject::NewOSError(); | 194 return CObject::NewOSError(); |
189 } | 195 } |
190 } | 196 } |
191 return CObject::IllegalArgumentError(); | 197 return CObject::IllegalArgumentError(); |
192 } | 198 } |
193 | 199 |
194 | 200 |
195 CObject* Directory::CreateTempRequest(const CObjectArray& request) { | 201 CObject* Directory::CreateTempRequest(const CObjectArray& request) { |
196 if (request.Length() == 1 && request[0]->IsString()) { | 202 if (request.Length() == 1 && request[0]->IsString()) { |
197 CObjectString path(request[0]); | 203 CObjectString path(request[0]); |
198 char* result = Directory::CreateTemp(path.CString(), false); | 204 char* result = Directory::CreateTemp(path.CString()); |
199 if (result != NULL) { | 205 if (result != NULL) { |
200 CObject* temp_dir = new CObjectString(CObject::NewString(result)); | 206 CObject* temp_dir = new CObjectString(CObject::NewString(result)); |
201 free(result); | 207 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; | 208 return temp_dir; |
219 } else { | 209 } else { |
220 return CObject::NewOSError(); | 210 return CObject::NewOSError(); |
221 } | 211 } |
222 } | 212 } |
223 return CObject::IllegalArgumentError(); | 213 return CObject::IllegalArgumentError(); |
224 } | 214 } |
225 | 215 |
226 | 216 |
227 static CObject* CreateIllegalArgumentError() { | 217 static CObject* CreateIllegalArgumentError() { |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 if (listing->error()) { | 418 if (listing->error()) { |
429 listing->HandleError("Invalid path"); | 419 listing->HandleError("Invalid path"); |
430 listing->HandleDone(); | 420 listing->HandleDone(); |
431 } else { | 421 } else { |
432 while (ListNext(listing)) {} | 422 while (ListNext(listing)) {} |
433 } | 423 } |
434 } | 424 } |
435 | 425 |
436 } // namespace bin | 426 } // namespace bin |
437 } // namespace dart | 427 } // namespace dart |
OLD | NEW |