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

Unified Diff: runtime/bin/directory_linux.cc

Issue 15719002: Provide a POSIX-compliant implementation of Directory::Current. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: . Created 7 years, 7 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/directory_linux.cc
diff --git a/runtime/bin/directory_linux.cc b/runtime/bin/directory_linux.cc
index f3c1ec2fe5806dd527e31800a441894110d759fd..bd8475374be7f0430dd0dbb00214a01220f955f8 100644
--- a/runtime/bin/directory_linux.cc
+++ b/runtime/bin/directory_linux.cc
@@ -416,7 +416,18 @@ Directory::ExistsResult Directory::Exists(const char* dir_name) {
char* Directory::Current() {
- return getcwd(NULL, 0);
+ size_t size = PATH_MAX;
+ char* buffer = NULL;
+ for (char* result = NULL; result == NULL; size *= 2) {
+ if ((buffer = reinterpret_cast<char*>(realloc(buffer, size))) == NULL) {
+ return NULL;
+ }
+ result = getcwd(buffer, size);
+ if (result == NULL && errno != ERANGE) {
+ return NULL;
+ }
+ }
+ return buffer;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698