| 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 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 | 256 |
| 257 if ((attributes & FILE_ATTRIBUTE_DIRECTORY) != 0) { | 257 if ((attributes & FILE_ATTRIBUTE_DIRECTORY) != 0) { |
| 258 return DeleteDir(find_file_data->cFileName, path); | 258 return DeleteDir(find_file_data->cFileName, path); |
| 259 } else { | 259 } else { |
| 260 return DeleteFile(find_file_data->cFileName, path); | 260 return DeleteFile(find_file_data->cFileName, path); |
| 261 } | 261 } |
| 262 } | 262 } |
| 263 | 263 |
| 264 | 264 |
| 265 static bool DeleteRecursively(PathBuffer* path) { | 265 static bool DeleteRecursively(PathBuffer* path) { |
| 266 DWORD attributes = GetFileAttributesW(path->data); |
| 267 if ((attributes == INVALID_FILE_ATTRIBUTES)) { |
| 268 return false; |
| 269 } |
| 266 // If the directory is a junction, it's pointing to some other place in the | 270 // If the directory is a junction, it's pointing to some other place in the |
| 267 // filesystem that we do not want to recurse into. | 271 // filesystem that we do not want to recurse into. |
| 268 DWORD attributes = GetFileAttributesW(path->data); | 272 if ((attributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0) { |
| 269 if ((attributes != INVALID_FILE_ATTRIBUTES) && | 273 // Just delete the junction itself. |
| 270 (attributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0) { | 274 return RemoveDirectoryW(path->data) != 0; |
| 271 if (IsBrokenLink(path->data)) { | 275 } |
| 272 return false; | 276 // If it's a file, remove it directly. |
| 273 } else { | 277 if ((attributes & FILE_ATTRIBUTE_DIRECTORY) == 0) { |
| 274 // Just delete the junction itself. | 278 return DeleteFile(L"", path); |
| 275 return RemoveDirectoryW(path->data) != 0; | |
| 276 } | |
| 277 } | 279 } |
| 278 | 280 |
| 279 if (!path->Add(L"\\*")) return false; | 281 if (!path->Add(L"\\*")) return false; |
| 280 | 282 |
| 281 WIN32_FIND_DATAW find_file_data; | 283 WIN32_FIND_DATAW find_file_data; |
| 282 HANDLE find_handle = FindFirstFileW(path->data, &find_file_data); | 284 HANDLE find_handle = FindFirstFileW(path->data, &find_file_data); |
| 283 | 285 |
| 284 // Adjust the path by removing the '*' used for the search. | 286 // Adjust the path by removing the '*' used for the search. |
| 285 int path_length = path->length - 1; | 287 int path_length = path->length - 1; |
| 286 path->Reset(path_length); | 288 path->Reset(path_length); |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 } | 460 } |
| 459 DWORD flags = MOVEFILE_WRITE_THROUGH; | 461 DWORD flags = MOVEFILE_WRITE_THROUGH; |
| 460 int move_status = | 462 int move_status = |
| 461 MoveFileExW(system_path, system_new_path, flags); | 463 MoveFileExW(system_path, system_new_path, flags); |
| 462 free(const_cast<wchar_t*>(system_path)); | 464 free(const_cast<wchar_t*>(system_path)); |
| 463 free(const_cast<wchar_t*>(system_new_path)); | 465 free(const_cast<wchar_t*>(system_new_path)); |
| 464 return (move_status != 0); | 466 return (move_status != 0); |
| 465 } | 467 } |
| 466 | 468 |
| 467 #endif // defined(TARGET_OS_WINDOWS) | 469 #endif // defined(TARGET_OS_WINDOWS) |
| OLD | NEW |