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

Unified Diff: runtime/bin/file_win.cc

Issue 12533008: dart:io | Add FileSystemEntity.typeSync to test for symbolic links. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add error-checking for arguments. Disable Windows implementation. 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 e18071aacae8c871336394e4b4c05ba85dca5e08..92c7c157fb94113d05f0c90342f71a64f026cce3 100644
--- a/runtime/bin/file_win.cc
+++ b/runtime/bin/file_win.cc
@@ -270,4 +270,24 @@ File::StdioHandleType File::GetStdioHandleType(int fd) {
return kPipe;
}
+
+File::Type File::GetType(const char* pathname, bool follow_links) {
+ struct _stat entry_info;
+ const wchar_t* system_name = StringUtils::Utf8ToWide(pathname);
+ // TODO(whesse): We need to use FileGetAttributes here, and more complex
+ // checks.
+ int stat_success = _wstat(system_name, &st);
+ free(const_cast<wchar_t*>(system_name));
+ if (stat_success == -1) return File::kDoesNotExist;
+ if (S_ISDIR(entry_info.st_mode)) return File::kIsDirectory;
+ if (S_ISREG(entry_info.st_mode)) return File::kIsFile;
+ // if (S_ISLNK(entry_info.st_mode)) return File::kIsLink;
Bob Nystrom 2013/03/06 19:02:52 What kind of symlinks does this detect? For what i
Bill Hesse 2013/03/07 09:53:12 The Windows implementation will report all types o
+ return File::kDoesNotExist;
+}
+
+ struct _stat st;
+ const wchar_t* system_name = StringUtils::Utf8ToWide(name);
+ int stat_status = _wstat(system_name, &st);
+ free(const_cast<wchar_t*>(system_name));
+
#endif // defined(TARGET_OS_WINDOWS)

Powered by Google App Engine
This is Rietveld 408576698