| 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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 NULL); | 252 NULL); |
| 253 if (CloseHandle(dir_handle) == 0) return false; | 253 if (CloseHandle(dir_handle) == 0) return false; |
| 254 free(const_cast<wchar_t*>(target)); | 254 free(const_cast<wchar_t*>(target)); |
| 255 free(reparse_data_buffer); | 255 free(reparse_data_buffer); |
| 256 return (result != 0); | 256 return (result != 0); |
| 257 } | 257 } |
| 258 | 258 |
| 259 | 259 |
| 260 bool File::Delete(const char* name) { | 260 bool File::Delete(const char* name) { |
| 261 const wchar_t* system_name = StringUtils::Utf8ToWide(name); | 261 const wchar_t* system_name = StringUtils::Utf8ToWide(name); |
| 262 int status = _wremove(system_name); | 262 DWORD attributes = GetFileAttributesW(system_name); |
| 263 free(const_cast<wchar_t*>(system_name)); | 263 if ((attributes != INVALID_FILE_ATTRIBUTES) && |
| 264 if (status == -1) { | 264 (attributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0) { |
| 265 return false; | 265 // It's a junction(link), delete it. |
| 266 return RemoveDirectoryW(system_name) != 0; |
| 267 } else { |
| 268 int status = _wremove(system_name); |
| 269 free(const_cast<wchar_t*>(system_name)); |
| 270 if (status == -1) { |
| 271 return false; |
| 272 } |
| 273 return true; |
| 266 } | 274 } |
| 267 return true; | |
| 268 } | 275 } |
| 269 | 276 |
| 270 | 277 |
| 271 off_t File::LengthFromPath(const char* name) { | 278 off_t File::LengthFromPath(const char* name) { |
| 272 struct _stat st; | 279 struct _stat st; |
| 273 const wchar_t* system_name = StringUtils::Utf8ToWide(name); | 280 const wchar_t* system_name = StringUtils::Utf8ToWide(name); |
| 274 int stat_status = _wstat(system_name, &st); | 281 int stat_status = _wstat(system_name, &st); |
| 275 free(const_cast<wchar_t*>(system_name)); | 282 free(const_cast<wchar_t*>(system_name)); |
| 276 if (stat_status == 0) { | 283 if (stat_status == 0) { |
| 277 return st.st_size; | 284 return st.st_size; |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 549 if (file_info[0].dwVolumeSerialNumber == file_info[1].dwVolumeSerialNumber && | 556 if (file_info[0].dwVolumeSerialNumber == file_info[1].dwVolumeSerialNumber && |
| 550 file_info[0].nFileIndexHigh == file_info[1].nFileIndexHigh && | 557 file_info[0].nFileIndexHigh == file_info[1].nFileIndexHigh && |
| 551 file_info[0].nFileIndexLow == file_info[1].nFileIndexLow) { | 558 file_info[0].nFileIndexLow == file_info[1].nFileIndexLow) { |
| 552 return kIdentical; | 559 return kIdentical; |
| 553 } else { | 560 } else { |
| 554 return kDifferent; | 561 return kDifferent; |
| 555 } | 562 } |
| 556 } | 563 } |
| 557 | 564 |
| 558 #endif // defined(TARGET_OS_WINDOWS) | 565 #endif // defined(TARGET_OS_WINDOWS) |
| OLD | NEW |