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

Side by Side Diff: bin/file_macos.cc

Issue 8400070: Allocate and pass a resolved_path buffer to realpath as older macos versions (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 9 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include <errno.h> 5 #include <errno.h>
6 #include <fcntl.h> 6 #include <fcntl.h>
7 #include <sys/stat.h> 7 #include <sys/stat.h>
8 #include <unistd.h> 8 #include <unistd.h>
9 #include <libgen.h> 9 #include <libgen.h>
10 #include <limits.h>
10 11
11 #include "bin/builtin.h" 12 #include "bin/builtin.h"
12 #include "bin/file.h" 13 #include "bin/file.h"
13 14
14 class FileHandle { 15 class FileHandle {
15 public: 16 public:
16 explicit FileHandle(int fd) : fd_(fd) { } 17 explicit FileHandle(int fd) : fd_(fd) { }
17 ~FileHandle() { } 18 ~FileHandle() { }
18 int fd() const { return fd_; } 19 int fd() const { return fd_; }
19 void set_fd(int fd) { fd_ = fd; } 20 void set_fd(int fd) { fd_ = fd; }
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 116
116 117
117 bool File::IsAbsolutePath(const char* pathname) { 118 bool File::IsAbsolutePath(const char* pathname) {
118 return (pathname != NULL && pathname[0] == '/'); 119 return (pathname != NULL && pathname[0] == '/');
119 } 120 }
120 121
121 122
122 char* File::GetCanonicalPath(const char* pathname) { 123 char* File::GetCanonicalPath(const char* pathname) {
123 char* abs_path = NULL; 124 char* abs_path = NULL;
124 if (pathname != NULL) { 125 if (pathname != NULL) {
125 abs_path = realpath(pathname, NULL); 126 // On some older MacOs versions the default behaviour of realpath allocating
127 // space for the resolved_path when a NULL is passed in does not seem to
128 // work, so we explicitly allocate space. The caller is responsible for
129 // freeing this space as in a regular realpath call.
130 char* resolved_path = reinterpret_cast<char*>(malloc(PATH_MAX+1));
131 ASSERT(resolved_path != NULL);
132 abs_path = realpath(pathname, resolved_path);
126 assert(abs_path == NULL || IsAbsolutePath(abs_path)); 133 assert(abs_path == NULL || IsAbsolutePath(abs_path));
127 } 134 }
128 return abs_path; 135 return abs_path;
129 } 136 }
130 137
131 138
132 const char* File::PathSeparator() { 139 const char* File::PathSeparator() {
133 return "/"; 140 return "/";
134 } 141 }
135 142
136 143
137 const char* File::StringEscapedPathSeparator() { 144 const char* File::StringEscapedPathSeparator() {
138 return "/"; 145 return "/";
139 } 146 }
OLDNEW
« 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