| 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 #include "bin/utils.h" | 10 #include "bin/utils.h" |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 HANDLE find_handle = FindFirstFileW(path->AsStringW(), &find_file_data); | 303 HANDLE find_handle = FindFirstFileW(path->AsStringW(), &find_file_data); |
| 304 | 304 |
| 305 // Adjust the path by removing the '*' used for the search. | 305 // Adjust the path by removing the '*' used for the search. |
| 306 int path_length = path->length() - 1; | 306 int path_length = path->length() - 1; |
| 307 path->Reset(path_length); | 307 path->Reset(path_length); |
| 308 | 308 |
| 309 if (find_handle == INVALID_HANDLE_VALUE) { | 309 if (find_handle == INVALID_HANDLE_VALUE) { |
| 310 return false; | 310 return false; |
| 311 } | 311 } |
| 312 | 312 |
| 313 bool success = DeleteEntry(&find_file_data, path); | 313 do { |
| 314 | 314 if (!DeleteEntry(&find_file_data, path)) { |
| 315 while ((FindNextFileW(find_handle, &find_file_data) != 0) && success) { | 315 DWORD last_error = GetLastError(); |
| 316 FindClose(find_handle); |
| 317 SetLastError(last_error); |
| 318 return false; |
| 319 } |
| 316 path->Reset(path_length); // DeleteEntry adds to the path. | 320 path->Reset(path_length); // DeleteEntry adds to the path. |
| 317 success = success && DeleteEntry(&find_file_data, path); | 321 } while (FindNextFileW(find_handle, &find_file_data) != 0); |
| 318 } | |
| 319 | 322 |
| 320 path->Reset(path_length - 1); // Drop the "\" from the end of the path. | 323 path->Reset(path_length - 1); // Drop the "\" from the end of the path. |
| 321 if ((GetLastError() != ERROR_NO_MORE_FILES) || | 324 if ((GetLastError() != ERROR_NO_MORE_FILES) || |
| 322 (FindClose(find_handle) == 0) || | 325 (FindClose(find_handle) == 0) || |
| 323 (RemoveDirectoryW(path->AsStringW()) == 0)) { | 326 (RemoveDirectoryW(path->AsStringW()) == 0)) { |
| 324 return false; | 327 return false; |
| 325 } | 328 } |
| 326 | 329 |
| 327 return success; | 330 return true; |
| 328 } | 331 } |
| 329 | 332 |
| 330 | 333 |
| 331 static Directory::ExistsResult ExistsHelper(const wchar_t* dir_name) { | 334 static Directory::ExistsResult ExistsHelper(const wchar_t* dir_name) { |
| 332 DWORD attributes = GetFileAttributesW(dir_name); | 335 DWORD attributes = GetFileAttributesW(dir_name); |
| 333 if (attributes == INVALID_FILE_ATTRIBUTES) { | 336 if (attributes == INVALID_FILE_ATTRIBUTES) { |
| 334 DWORD last_error = GetLastError(); | 337 DWORD last_error = GetLastError(); |
| 335 if (last_error == ERROR_FILE_NOT_FOUND || | 338 if (last_error == ERROR_FILE_NOT_FOUND || |
| 336 last_error == ERROR_PATH_NOT_FOUND) { | 339 last_error == ERROR_PATH_NOT_FOUND) { |
| 337 return Directory::DOES_NOT_EXIST; | 340 return Directory::DOES_NOT_EXIST; |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 MoveFileExW(system_path, system_new_path, flags); | 477 MoveFileExW(system_path, system_new_path, flags); |
| 475 free(const_cast<wchar_t*>(system_path)); | 478 free(const_cast<wchar_t*>(system_path)); |
| 476 free(const_cast<wchar_t*>(system_new_path)); | 479 free(const_cast<wchar_t*>(system_new_path)); |
| 477 return (move_status != 0); | 480 return (move_status != 0); |
| 478 } | 481 } |
| 479 | 482 |
| 480 } // namespace bin | 483 } // namespace bin |
| 481 } // namespace dart | 484 } // namespace dart |
| 482 | 485 |
| 483 #endif // defined(TARGET_OS_WINDOWS) | 486 #endif // defined(TARGET_OS_WINDOWS) |
| OLD | NEW |