| 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 #if !defined(DART_IO_DISABLED) | 5 #if !defined(DART_IO_DISABLED) |
| 6 | 6 |
| 7 #include "bin/directory.h" | 7 #include "bin/directory.h" |
| 8 | 8 |
| 9 #include "bin/dartutils.h" | 9 #include "bin/dartutils.h" |
| 10 #include "bin/log.h" | 10 #include "bin/log.h" |
| 11 #include "include/dart_api.h" | 11 #include "include/dart_api.h" |
| 12 #include "platform/assert.h" | 12 #include "platform/assert.h" |
| 13 | 13 |
| 14 namespace dart { | 14 namespace dart { |
| 15 namespace bin { | 15 namespace bin { |
| 16 | 16 |
| 17 char* Directory::system_temp_path_override_ = NULL; |
| 18 |
| 17 void FUNCTION_NAME(Directory_Current)(Dart_NativeArguments args) { | 19 void FUNCTION_NAME(Directory_Current)(Dart_NativeArguments args) { |
| 18 const char* current = Directory::Current(); | 20 const char* current = Directory::Current(); |
| 19 if (current != NULL) { | 21 if (current != NULL) { |
| 20 Dart_SetReturnValue(args, DartUtils::NewString(current)); | 22 Dart_SetReturnValue(args, DartUtils::NewString(current)); |
| 21 } else { | 23 } else { |
| 22 Dart_SetReturnValue(args, DartUtils::NewDartOSError()); | 24 Dart_SetReturnValue(args, DartUtils::NewDartOSError()); |
| 23 } | 25 } |
| 24 } | 26 } |
| 25 | 27 |
| 26 | 28 |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 dart_this, | 182 dart_this, |
| 181 kAsyncDirectoryListerFieldIndex, | 183 kAsyncDirectoryListerFieldIndex, |
| 182 listing_pointer); | 184 listing_pointer); |
| 183 if (Dart_IsError(result)) { | 185 if (Dart_IsError(result)) { |
| 184 Log::PrintErr("SetAsyncDirectoryListerPointer failed\n"); | 186 Log::PrintErr("SetAsyncDirectoryListerPointer failed\n"); |
| 185 Dart_PropagateError(result); | 187 Dart_PropagateError(result); |
| 186 } | 188 } |
| 187 } | 189 } |
| 188 | 190 |
| 189 | 191 |
| 192 void Directory::SetSystemTemp(const char* path) { |
| 193 if (system_temp_path_override_ != NULL) { |
| 194 free(system_temp_path_override_); |
| 195 system_temp_path_override_ = NULL; |
| 196 } |
| 197 if (path != NULL) { |
| 198 system_temp_path_override_ = strdup(path); |
| 199 } |
| 200 } |
| 201 |
| 202 |
| 190 CObject* Directory::CreateRequest(const CObjectArray& request) { | 203 CObject* Directory::CreateRequest(const CObjectArray& request) { |
| 191 if ((request.Length() == 1) && request[0]->IsString()) { | 204 if ((request.Length() == 1) && request[0]->IsString()) { |
| 192 CObjectString path(request[0]); | 205 CObjectString path(request[0]); |
| 193 if (Directory::Create(path.CString())) { | 206 if (Directory::Create(path.CString())) { |
| 194 return CObject::True(); | 207 return CObject::True(); |
| 195 } else { | 208 } else { |
| 196 return CObject::NewOSError(); | 209 return CObject::NewOSError(); |
| 197 } | 210 } |
| 198 } | 211 } |
| 199 return CObject::IllegalArgumentError(); | 212 return CObject::IllegalArgumentError(); |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 listing->HandleDone(); | 498 listing->HandleDone(); |
| 486 } else { | 499 } else { |
| 487 while (ListNext(listing)) {} | 500 while (ListNext(listing)) {} |
| 488 } | 501 } |
| 489 } | 502 } |
| 490 | 503 |
| 491 } // namespace bin | 504 } // namespace bin |
| 492 } // namespace dart | 505 } // namespace dart |
| 493 | 506 |
| 494 #endif // !defined(DART_IO_DISABLED) | 507 #endif // !defined(DART_IO_DISABLED) |
| OLD | NEW |