Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Unified Diff: runtime/bin/directory_win.cc

Issue 13578003: Fix directory-listing, directory-deletion and file deletion, when links are involved. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Use Link for Link removal. Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/directory_macos.cc ('k') | runtime/bin/file_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/directory_win.cc
diff --git a/runtime/bin/directory_win.cc b/runtime/bin/directory_win.cc
index 857739ac872b65b9a019dfa41c439108e10b6f6c..d4b0aafa6d2bebed3e53f598f40afcc0f6eac44b 100644
--- a/runtime/bin/directory_win.cc
+++ b/runtime/bin/directory_win.cc
@@ -118,9 +118,25 @@ static bool HandleEntry(LPWIN32_FIND_DATAW find_file_data,
bool follow_links,
DirectoryListing* listing) {
DWORD attributes = find_file_data->dwFileAttributes;
- if (!follow_links && (attributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0) {
- return HandleLink(find_file_data->cFileName, path, listing);
- } else if ((attributes & FILE_ATTRIBUTE_DIRECTORY) != 0) {
+ if ((attributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0) {
+ if (!follow_links) {
+ return HandleLink(find_file_data->cFileName, path, listing);
+ }
+ // Attempt to list the directory, to see if it's a valid link or not.
+ int path_length = path->length;
+ if (!path->Add(find_file_data->cFileName)) return false;
+ if (!path->Add(L"\\*")) return false;
+ WIN32_FIND_DATAW tmp_file_data;
+ HANDLE find_handle = FindFirstFileW(path->data, &tmp_file_data);
+ path->Reset(path_length);
+ if (find_handle == INVALID_HANDLE_VALUE) {
+ // Invalid handle, report as (broken) link.
+ return HandleLink(find_file_data->cFileName, path, listing);
+ } else {
+ FindClose(find_handle);
+ }
+ }
+ if ((attributes & FILE_ATTRIBUTE_DIRECTORY) != 0) {
return HandleDir(find_file_data->cFileName,
path,
recursive,
« no previous file with comments | « runtime/bin/directory_macos.cc ('k') | runtime/bin/file_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698