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

Unified Diff: runtime/bin/file_win.cc

Issue 12437017: dart:io | Make broken links report NOT_FOUND from FileSystemEntity.typeSync on Windows. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove TODO comment. 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 | « no previous file | tests/standalone/io/windows_file_system_links_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/file_win.cc
diff --git a/runtime/bin/file_win.cc b/runtime/bin/file_win.cc
index 2e255293e7bd632d4427bf20d81fb1c7c5f99e81..b23049dce5bfc7241347d89db5fae8060409d6d5 100644
--- a/runtime/bin/file_win.cc
+++ b/runtime/bin/file_win.cc
@@ -383,13 +383,31 @@ File::Type File::GetType(const char* pathname, bool follow_links) {
}
FindClose(find_handle);
DWORD attributes = file_data.dwFileAttributes;
- if (!follow_links && (attributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0) {
- DWORD reparse_tag = file_data.dwReserved0;
- if (reparse_tag == IO_REPARSE_TAG_SYMLINK ||
- reparse_tag == IO_REPARSE_TAG_MOUNT_POINT) {
- return File::kIsLink;
+ if ((attributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0) {
+ if (follow_links) {
+ HANDLE dir_handle = CreateFileW(
+ name,
+ 0,
+ FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
+ NULL,
+ OPEN_EXISTING,
+ FILE_FLAG_BACKUP_SEMANTICS,
+ NULL);
+ if (dir_handle == INVALID_HANDLE_VALUE) {
+ // TODO(whesse): Distinguish other errors from does not exist.
+ return File::kDoesNotExist;
+ } else {
+ CloseHandle(dir_handle);
+ return File::kIsDirectory;
+ }
} else {
- return File::kDoesNotExist;
+ DWORD reparse_tag = file_data.dwReserved0;
+ if (reparse_tag == IO_REPARSE_TAG_SYMLINK ||
+ reparse_tag == IO_REPARSE_TAG_MOUNT_POINT) {
+ return File::kIsLink;
+ } else {
+ return File::kDoesNotExist;
+ }
}
} else if ((attributes & FILE_ATTRIBUTE_DIRECTORY) != 0) {
return File::kIsDirectory;
« no previous file with comments | « no previous file | tests/standalone/io/windows_file_system_links_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698