| 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 | 9 |
| 10 #include <errno.h> // NOLINT | 10 #include <errno.h> // NOLINT |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 return ok; | 111 return ok; |
| 112 } | 112 } |
| 113 | 113 |
| 114 | 114 |
| 115 static bool HandleEntry(LPWIN32_FIND_DATAW find_file_data, | 115 static bool HandleEntry(LPWIN32_FIND_DATAW find_file_data, |
| 116 PathBuffer* path, | 116 PathBuffer* path, |
| 117 bool recursive, | 117 bool recursive, |
| 118 bool follow_links, | 118 bool follow_links, |
| 119 DirectoryListing* listing) { | 119 DirectoryListing* listing) { |
| 120 DWORD attributes = find_file_data->dwFileAttributes; | 120 DWORD attributes = find_file_data->dwFileAttributes; |
| 121 if (!follow_links && (attributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0) { | 121 if ((attributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0) { |
| 122 return HandleLink(find_file_data->cFileName, path, listing); | 122 if (!follow_links) { |
| 123 } else if ((attributes & FILE_ATTRIBUTE_DIRECTORY) != 0) { | 123 return HandleLink(find_file_data->cFileName, path, listing); |
| 124 } |
| 125 // Attempt to list the directory, to see if it's a valid link or not. |
| 126 int path_length = path->length; |
| 127 if (!path->Add(find_file_data->cFileName)) return false; |
| 128 if (!path->Add(L"\\*")) return false; |
| 129 WIN32_FIND_DATAW tmp_file_data; |
| 130 HANDLE find_handle = FindFirstFileW(path->data, &tmp_file_data); |
| 131 path->Reset(path_length); |
| 132 if (find_handle == INVALID_HANDLE_VALUE) { |
| 133 // Invalid handle, report as (broken) link. |
| 134 return HandleLink(find_file_data->cFileName, path, listing); |
| 135 } else { |
| 136 FindClose(find_handle); |
| 137 } |
| 138 } |
| 139 if ((attributes & FILE_ATTRIBUTE_DIRECTORY) != 0) { |
| 124 return HandleDir(find_file_data->cFileName, | 140 return HandleDir(find_file_data->cFileName, |
| 125 path, | 141 path, |
| 126 recursive, | 142 recursive, |
| 127 follow_links, | 143 follow_links, |
| 128 listing); | 144 listing); |
| 129 } else { | 145 } else { |
| 130 return HandleFile(find_file_data->cFileName, path, listing); | 146 return HandleFile(find_file_data->cFileName, path, listing); |
| 131 } | 147 } |
| 132 } | 148 } |
| 133 | 149 |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 } | 435 } |
| 420 DWORD flags = MOVEFILE_WRITE_THROUGH; | 436 DWORD flags = MOVEFILE_WRITE_THROUGH; |
| 421 int move_status = | 437 int move_status = |
| 422 MoveFileExW(system_path, system_new_path, flags); | 438 MoveFileExW(system_path, system_new_path, flags); |
| 423 free(const_cast<wchar_t*>(system_path)); | 439 free(const_cast<wchar_t*>(system_path)); |
| 424 free(const_cast<wchar_t*>(system_new_path)); | 440 free(const_cast<wchar_t*>(system_new_path)); |
| 425 return (move_status != 0); | 441 return (move_status != 0); |
| 426 } | 442 } |
| 427 | 443 |
| 428 #endif // defined(TARGET_OS_WINDOWS) | 444 #endif // defined(TARGET_OS_WINDOWS) |
| OLD | NEW |