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

Unified Diff: runtime/bin/file_win.cc

Issue 12617002: dart:io | Implement FileSystemEntity.typeSync on Windows, to identify symbolic links and junctions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Make new test a no-op on non-windows platforms. 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
Index: runtime/bin/file_win.cc
diff --git a/runtime/bin/file_win.cc b/runtime/bin/file_win.cc
index 5d78d197e69acccb7802a4b3ec9512ae298be337..1c22ededcf24a42cf4e9f11b88c82581a71948d3 100644
--- a/runtime/bin/file_win.cc
+++ b/runtime/bin/file_win.cc
@@ -272,7 +272,27 @@ File::StdioHandleType File::GetStdioHandleType(int fd) {
File::Type File::GetType(const char* pathname, bool follow_links) {
- return File::kDoesNotExist;
+ const wchar_t* name = StringUtils::Utf8ToWide(pathname);
+ WIN32_FIND_DATAW file_data;
+ HANDLE find_handle = FindFirstFileW(name, &file_data);
+ if (find_handle == INVALID_HANDLE_VALUE) {
+ // TODO(whesse): Distinguish other errors from does not exist.
+ return File::kDoesNotExist;
+ }
+ 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;
+ } else {
+ return File::kDoesNotExist;
+ }
+ } else if ((attributes & FILE_ATTRIBUTE_DIRECTORY) != 0) {
+ return File::kIsDirectory;
+ } else {
+ return File::kIsFile;
+ }
}
#endif // defined(TARGET_OS_WINDOWS)

Powered by Google App Engine
This is Rietveld 408576698