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

Unified Diff: runtime/bin/file_macos.cc

Issue 12812010: dart:io | Add Link.targetSync on all platforms. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix Windows failures. 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_macos.cc
diff --git a/runtime/bin/file_macos.cc b/runtime/bin/file_macos.cc
index 9d324579344f92817c82285914032a9fd362986e..cabd2c3328dda67d1862b540a7c3156ad3c138db 100644
--- a/runtime/bin/file_macos.cc
+++ b/runtime/bin/file_macos.cc
@@ -195,6 +195,23 @@ time_t File::LastModified(const char* name) {
}
+char* File::LinkTarget(const char* pathname) {
+ struct stat link_stats;
+ if (lstat(pathname, &link_stats) != 0) return NULL;
+ // TODO(whesse): return a better error than LinkIOException(OSError) here.
+ if (!S_ISLNK(link_stats.st_mode)) return NULL;
+ size_t target_size = link_stats.st_size;
+ char* target_name = reinterpret_cast<char*>(malloc(target_size + 1));
+ size_t read_size = readlink(pathname, target_name, target_size + 1);
+ if (read_size != target_size) {
+ free(target_name);
+ return NULL;
+ }
+ target_name[target_size] = '\0';
+ return target_name;
+}
+
+
bool File::IsAbsolutePath(const char* pathname) {
return (pathname != NULL && pathname[0] == '/');
}
« no previous file with comments | « runtime/bin/file_linux.cc ('k') | runtime/bin/file_patch.dart » ('j') | runtime/bin/file_win.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698