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

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..2abc5f4e60d995074f5dd750b06d1848e3420c5e 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 = 1024;
Søren Gjesse 2013/05/22 14:39:34 Use an initial size of PATH_MAX?
podivilov 2013/05/22 17:05:13 Done.
+ 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