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

Unified Diff: runtime/bin/file_linux.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_linux.cc
diff --git a/runtime/bin/file_linux.cc b/runtime/bin/file_linux.cc
index 459a69271a4f0055c0850da10d746ac525003ab3..ce0ef27bb26c5ea84f21e13424b345098c4d2f4e 100644
--- a/runtime/bin/file_linux.cc
+++ b/runtime/bin/file_linux.cc
@@ -246,4 +246,20 @@ File::StdioHandleType File::GetStdioHandleType(int fd) {
return kOther;
}
+
+File::Type File::GetType(const char* pathname, bool follow_links) {
+ struct stat entry_info;
+ int stat_success;
+ if (follow_links) {
+ stat_success = TEMP_FAILURE_RETRY(stat(pathname, &entry_info));
+ } else {
+ stat_success = TEMP_FAILURE_RETRY(lstat(pathname, &entry_info));
+ }
+ 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;
+ return File::kDoesNotExist;
+}
+
#endif // defined(TARGET_OS_LINUX)
« no previous file with comments | « runtime/bin/file_android.cc ('k') | runtime/bin/file_macos.cc » ('j') | runtime/bin/file_win.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698