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 <errno.h> | 7 #include <errno.h> |
8 #include <sys/stat.h> | 8 #include <sys/stat.h> |
9 | 9 |
10 #include "bin/platform.h" | 10 #include "bin/platform.h" |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 return UNKNOWN; | 317 return UNKNOWN; |
318 } | 318 } |
319 ASSERT(errno == ENAMETOOLONG || | 319 ASSERT(errno == ENAMETOOLONG || |
320 errno == ENOENT || | 320 errno == ENOENT || |
321 errno == ENOTDIR); | 321 errno == ENOTDIR); |
322 return DOES_NOT_EXIST; | 322 return DOES_NOT_EXIST; |
323 } | 323 } |
324 } | 324 } |
325 | 325 |
326 | 326 |
| 327 char* Directory::Current() { |
| 328 char* result; |
| 329 int length = GetCurrentDirectory(0, NULL); |
| 330 result = reinterpret_cast<char*>(malloc(length + 1)); |
| 331 GetCurrentDirectory(length + 1, result); |
| 332 return result; |
| 333 } |
| 334 |
| 335 |
327 bool Directory::Create(const char* dir_name) { | 336 bool Directory::Create(const char* dir_name) { |
328 return (CreateDirectory(dir_name, NULL) != 0); | 337 return (CreateDirectory(dir_name, NULL) != 0); |
329 } | 338 } |
330 | 339 |
331 | 340 |
332 int Directory::CreateTemp(const char* const_template, | 341 int Directory::CreateTemp(const char* const_template, |
333 char** path, | 342 char** path, |
334 char* os_error_message, | 343 char* os_error_message, |
335 int os_error_message_len) { | 344 int os_error_message_len) { |
336 // Returns a new, unused directory name, modifying the contents of | 345 // Returns a new, unused directory name, modifying the contents of |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 } | 404 } |
396 | 405 |
397 | 406 |
398 bool Directory::Delete(const char* dir_name, bool recursive) { | 407 bool Directory::Delete(const char* dir_name, bool recursive) { |
399 if (!recursive) { | 408 if (!recursive) { |
400 return (RemoveDirectory(dir_name) != 0); | 409 return (RemoveDirectory(dir_name) != 0); |
401 } else { | 410 } else { |
402 return DeleteRecursively(dir_name); | 411 return DeleteRecursively(dir_name); |
403 } | 412 } |
404 } | 413 } |
OLD | NEW |