| 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/file.h" | 8 #include "bin/file.h" |
| 9 | 9 |
| 10 #include <fcntl.h> // NOLINT | 10 #include <fcntl.h> // NOLINT |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 File::Type type = GetType(old_path, false); | 290 File::Type type = GetType(old_path, false); |
| 291 if (type == kIsFile) { | 291 if (type == kIsFile) { |
| 292 const wchar_t* system_old_path = StringUtils::Utf8ToWide(old_path); | 292 const wchar_t* system_old_path = StringUtils::Utf8ToWide(old_path); |
| 293 const wchar_t* system_new_path = StringUtils::Utf8ToWide(new_path); | 293 const wchar_t* system_new_path = StringUtils::Utf8ToWide(new_path); |
| 294 DWORD flags = MOVEFILE_WRITE_THROUGH; | 294 DWORD flags = MOVEFILE_WRITE_THROUGH; |
| 295 int move_status = | 295 int move_status = |
| 296 MoveFileExW(system_old_path, system_new_path, flags); | 296 MoveFileExW(system_old_path, system_new_path, flags); |
| 297 free(const_cast<wchar_t*>(system_old_path)); | 297 free(const_cast<wchar_t*>(system_old_path)); |
| 298 free(const_cast<wchar_t*>(system_new_path)); | 298 free(const_cast<wchar_t*>(system_new_path)); |
| 299 return (move_status != 0); | 299 return (move_status != 0); |
| 300 } else if (type == kIsDirectory) { | |
| 301 SetLastError(ERROR_FILE_NOT_FOUND); | |
| 302 } else { | 300 } else { |
| 303 SetLastError(ERROR_FILE_NOT_FOUND); | 301 SetLastError(ERROR_FILE_NOT_FOUND); |
| 304 } | 302 } |
| 303 return false; |
| 304 } |
| 305 |
| 306 |
| 307 bool File::RenameLink(const char* old_path, const char* new_path) { |
| 308 File::Type type = GetType(old_path, false); |
| 309 if (type == kIsLink) { |
| 310 const wchar_t* system_old_path = StringUtils::Utf8ToWide(old_path); |
| 311 const wchar_t* system_new_path = StringUtils::Utf8ToWide(new_path); |
| 312 DWORD flags = MOVEFILE_WRITE_THROUGH; |
| 313 int move_status = |
| 314 MoveFileExW(system_old_path, system_new_path, flags); |
| 315 free(const_cast<wchar_t*>(system_old_path)); |
| 316 free(const_cast<wchar_t*>(system_new_path)); |
| 317 return (move_status != 0); |
| 318 } else { |
| 319 SetLastError(ERROR_FILE_NOT_FOUND); |
| 320 } |
| 305 return false; | 321 return false; |
| 306 } | 322 } |
| 307 | 323 |
| 308 | 324 |
| 309 off_t File::LengthFromPath(const char* name) { | 325 off_t File::LengthFromPath(const char* name) { |
| 310 struct _stat st; | 326 struct _stat st; |
| 311 const wchar_t* system_name = StringUtils::Utf8ToWide(name); | 327 const wchar_t* system_name = StringUtils::Utf8ToWide(name); |
| 312 int stat_status = _wstat(system_name, &st); | 328 int stat_status = _wstat(system_name, &st); |
| 313 free(const_cast<wchar_t*>(system_name)); | 329 free(const_cast<wchar_t*>(system_name)); |
| 314 if (stat_status == 0) { | 330 if (stat_status == 0) { |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 return kIdentical; | 576 return kIdentical; |
| 561 } else { | 577 } else { |
| 562 return kDifferent; | 578 return kDifferent; |
| 563 } | 579 } |
| 564 } | 580 } |
| 565 | 581 |
| 566 } // namespace bin | 582 } // namespace bin |
| 567 } // namespace dart | 583 } // namespace dart |
| 568 | 584 |
| 569 #endif // defined(TARGET_OS_WINDOWS) | 585 #endif // defined(TARGET_OS_WINDOWS) |
| OLD | NEW |