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(HOST_OS_WINDOWS) | 6 #if defined(HOST_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 #include "bin/utils.h" | 10 #include "bin/utils.h" |
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 | 485 |
486 | 486 |
487 bool Directory::Rename(const char* path, const char* new_path) { | 487 bool Directory::Rename(const char* path, const char* new_path) { |
488 Utf8ToWideScope system_path(path); | 488 Utf8ToWideScope system_path(path); |
489 Utf8ToWideScope system_new_path(new_path); | 489 Utf8ToWideScope system_new_path(new_path); |
490 ExistsResult exists = ExistsHelper(system_path.wide()); | 490 ExistsResult exists = ExistsHelper(system_path.wide()); |
491 if (exists != EXISTS) { | 491 if (exists != EXISTS) { |
492 return false; | 492 return false; |
493 } | 493 } |
494 ExistsResult new_exists = ExistsHelper(system_new_path.wide()); | 494 ExistsResult new_exists = ExistsHelper(system_new_path.wide()); |
495 // MoveFile does not allow replacing exising directories. Therefore, | 495 // MoveFile does not allow replacing existing directories. Therefore, |
496 // if the new_path is currently a directory we need to delete it | 496 // if the new_path is currently a directory we need to delete it |
497 // first. | 497 // first. |
498 if (new_exists == EXISTS) { | 498 if (new_exists == EXISTS) { |
499 bool success = Delete(new_path, true); | 499 bool success = Delete(new_path, true); |
500 if (!success) { | 500 if (!success) { |
501 return false; | 501 return false; |
502 } | 502 } |
503 } | 503 } |
504 DWORD flags = MOVEFILE_WRITE_THROUGH; | 504 DWORD flags = MOVEFILE_WRITE_THROUGH; |
505 int move_status = | 505 int move_status = |
506 MoveFileExW(system_path.wide(), system_new_path.wide(), flags); | 506 MoveFileExW(system_path.wide(), system_new_path.wide(), flags); |
507 return (move_status != 0); | 507 return (move_status != 0); |
508 } | 508 } |
509 | 509 |
510 } // namespace bin | 510 } // namespace bin |
511 } // namespace dart | 511 } // namespace dart |
512 | 512 |
513 #endif // defined(HOST_OS_WINDOWS) | 513 #endif // defined(HOST_OS_WINDOWS) |
OLD | NEW |