| 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 "platform/globals.h" | 5 #include "platform/globals.h" |
| 6 #if defined(TARGET_OS_WINDOWS) | 6 #if defined(TARGET_OS_WINDOWS) |
| 7 | 7 |
| 8 #include "bin/directory.h" | 8 #include "bin/directory.h" |
| 9 #include "bin/file.h" | 9 #include "bin/file.h" |
| 10 | 10 |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 } | 423 } |
| 424 | 424 |
| 425 | 425 |
| 426 bool Directory::Delete(const char* dir_name, bool recursive) { | 426 bool Directory::Delete(const char* dir_name, bool recursive) { |
| 427 bool result = false; | 427 bool result = false; |
| 428 const wchar_t* system_dir_name = StringUtils::Utf8ToWide(dir_name); | 428 const wchar_t* system_dir_name = StringUtils::Utf8ToWide(dir_name); |
| 429 if (!recursive) { | 429 if (!recursive) { |
| 430 if (File::GetType(dir_name, true) == File::kIsDirectory) { | 430 if (File::GetType(dir_name, true) == File::kIsDirectory) { |
| 431 result = (RemoveDirectoryW(system_dir_name) != 0); | 431 result = (RemoveDirectoryW(system_dir_name) != 0); |
| 432 } else { | 432 } else { |
| 433 SetLastError(ERROR_DIRECTORY); | 433 SetLastError(ERROR_FILE_NOT_FOUND); |
| 434 } | 434 } |
| 435 } else { | 435 } else { |
| 436 PathBuffer path; | 436 PathBuffer path; |
| 437 if (path.Add(system_dir_name)) { | 437 if (path.Add(system_dir_name)) { |
| 438 result = DeleteRecursively(&path); | 438 result = DeleteRecursively(&path); |
| 439 } | 439 } |
| 440 } | 440 } |
| 441 free(const_cast<wchar_t*>(system_dir_name)); | 441 free(const_cast<wchar_t*>(system_dir_name)); |
| 442 return result; | 442 return result; |
| 443 } | 443 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 458 } | 458 } |
| 459 DWORD flags = MOVEFILE_WRITE_THROUGH; | 459 DWORD flags = MOVEFILE_WRITE_THROUGH; |
| 460 int move_status = | 460 int move_status = |
| 461 MoveFileExW(system_path, system_new_path, flags); | 461 MoveFileExW(system_path, system_new_path, flags); |
| 462 free(const_cast<wchar_t*>(system_path)); | 462 free(const_cast<wchar_t*>(system_path)); |
| 463 free(const_cast<wchar_t*>(system_new_path)); | 463 free(const_cast<wchar_t*>(system_new_path)); |
| 464 return (move_status != 0); | 464 return (move_status != 0); |
| 465 } | 465 } |
| 466 | 466 |
| 467 #endif // defined(TARGET_OS_WINDOWS) | 467 #endif // defined(TARGET_OS_WINDOWS) |
| OLD | NEW |