OLD | NEW |
---|---|
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 #include <limits.h> |
11 | 11 |
12 #include "bin/builtin.h" | 12 #include "bin/builtin.h" |
13 #include "bin/file.h" | 13 #include "bin/file.h" |
Ivan Posva
2012/01/13 23:22:06
ditto.
Søren Gjesse
2012/01/16 08:58:00
Done.
| |
14 | 14 |
15 class FileHandle { | 15 class FileHandle { |
16 public: | 16 public: |
17 explicit FileHandle(int fd) : fd_(fd) { } | 17 explicit FileHandle(int fd) : fd_(fd) { } |
18 ~FileHandle() { } | 18 ~FileHandle() { } |
19 int fd() const { return fd_; } | 19 int fd() const { return fd_; } |
20 void set_fd(int fd) { fd_ = fd; } | 20 void set_fd(int fd) { fd_ = fd; } |
21 | 21 |
22 private: | 22 private: |
23 int fd_; | 23 int fd_; |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
158 if (pathname != NULL) { | 158 if (pathname != NULL) { |
159 // On some older MacOs versions the default behaviour of realpath allocating | 159 // On some older MacOs versions the default behaviour of realpath allocating |
160 // space for the resolved_path when a NULL is passed in does not seem to | 160 // space for the resolved_path when a NULL is passed in does not seem to |
161 // work, so we explicitly allocate space. The caller is responsible for | 161 // work, so we explicitly allocate space. The caller is responsible for |
162 // freeing this space as in a regular realpath call. | 162 // freeing this space as in a regular realpath call. |
163 char* resolved_path = reinterpret_cast<char*>(malloc(PATH_MAX + 1)); | 163 char* resolved_path = reinterpret_cast<char*>(malloc(PATH_MAX + 1)); |
164 ASSERT(resolved_path != NULL); | 164 ASSERT(resolved_path != NULL); |
165 do { | 165 do { |
166 abs_path = realpath(pathname, NULL); | 166 abs_path = realpath(pathname, NULL); |
167 } while (abs_path == NULL && errno == EINTR); | 167 } while (abs_path == NULL && errno == EINTR); |
168 assert(abs_path == NULL || IsAbsolutePath(abs_path)); | 168 ASSERT(abs_path == NULL || IsAbsolutePath(abs_path)); |
169 } | 169 } |
170 return abs_path; | 170 return abs_path; |
171 } | 171 } |
172 | 172 |
173 | 173 |
174 const char* File::PathSeparator() { | 174 const char* File::PathSeparator() { |
175 return "/"; | 175 return "/"; |
176 } | 176 } |
177 | 177 |
178 | 178 |
179 const char* File::StringEscapedPathSeparator() { | 179 const char* File::StringEscapedPathSeparator() { |
180 return "/"; | 180 return "/"; |
181 } | 181 } |
OLD | NEW |