| 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 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 // It's a junction(link), delete it. | 279 // It's a junction(link), delete it. |
| 280 result = (RemoveDirectoryW(system_name) != 0); | 280 result = (RemoveDirectoryW(system_name) != 0); |
| 281 } else { | 281 } else { |
| 282 SetLastError(ERROR_NOT_A_REPARSE_POINT); | 282 SetLastError(ERROR_NOT_A_REPARSE_POINT); |
| 283 } | 283 } |
| 284 free(const_cast<wchar_t*>(system_name)); | 284 free(const_cast<wchar_t*>(system_name)); |
| 285 return result; | 285 return result; |
| 286 } | 286 } |
| 287 | 287 |
| 288 | 288 |
| 289 bool File::Rename(const char* old_path, const char* new_path) { |
| 290 File::Type type = GetType(old_path, false); |
| 291 if (type == kIsFile) { |
| 292 const wchar_t* system_old_path = StringUtils::Utf8ToWide(old_path); |
| 293 const wchar_t* system_new_path = StringUtils::Utf8ToWide(new_path); |
| 294 DWORD flags = MOVEFILE_WRITE_THROUGH; |
| 295 int move_status = |
| 296 MoveFileExW(system_old_path, system_new_path, flags); |
| 297 free(const_cast<wchar_t*>(system_old_path)); |
| 298 free(const_cast<wchar_t*>(system_new_path)); |
| 299 return (move_status != 0); |
| 300 } else if (type == kIsDirectory) { |
| 301 SetLastError(ERROR_FILE_NOT_FOUND); |
| 302 } else { |
| 303 SetLastError(ERROR_FILE_NOT_FOUND); |
| 304 } |
| 305 return false; |
| 306 } |
| 307 |
| 308 |
| 289 off_t File::LengthFromPath(const char* name) { | 309 off_t File::LengthFromPath(const char* name) { |
| 290 struct _stat st; | 310 struct _stat st; |
| 291 const wchar_t* system_name = StringUtils::Utf8ToWide(name); | 311 const wchar_t* system_name = StringUtils::Utf8ToWide(name); |
| 292 int stat_status = _wstat(system_name, &st); | 312 int stat_status = _wstat(system_name, &st); |
| 293 free(const_cast<wchar_t*>(system_name)); | 313 free(const_cast<wchar_t*>(system_name)); |
| 294 if (stat_status == 0) { | 314 if (stat_status == 0) { |
| 295 return st.st_size; | 315 return st.st_size; |
| 296 } | 316 } |
| 297 return -1; | 317 return -1; |
| 298 } | 318 } |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 return kIdentical; | 560 return kIdentical; |
| 541 } else { | 561 } else { |
| 542 return kDifferent; | 562 return kDifferent; |
| 543 } | 563 } |
| 544 } | 564 } |
| 545 | 565 |
| 546 } // namespace bin | 566 } // namespace bin |
| 547 } // namespace dart | 567 } // namespace dart |
| 548 | 568 |
| 549 #endif // defined(TARGET_OS_WINDOWS) | 569 #endif // defined(TARGET_OS_WINDOWS) |
| OLD | NEW |