| 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 "bin/file.h" |
| 6 |
| 5 #include <errno.h> | 7 #include <errno.h> |
| 6 #include <fcntl.h> | 8 #include <fcntl.h> |
| 7 #include <sys/stat.h> | 9 #include <sys/stat.h> |
| 8 #include <unistd.h> | 10 #include <unistd.h> |
| 9 #include <libgen.h> | 11 #include <libgen.h> |
| 10 | 12 |
| 11 #include "bin/builtin.h" | 13 #include "bin/builtin.h" |
| 12 #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; } |
| 20 | 21 |
| 21 private: | 22 private: |
| 22 int fd_; | 23 int fd_; |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 return (pathname != NULL && pathname[0] == '/'); | 152 return (pathname != NULL && pathname[0] == '/'); |
| 152 } | 153 } |
| 153 | 154 |
| 154 | 155 |
| 155 char* File::GetCanonicalPath(const char* pathname) { | 156 char* File::GetCanonicalPath(const char* pathname) { |
| 156 char* abs_path = NULL; | 157 char* abs_path = NULL; |
| 157 if (pathname != NULL) { | 158 if (pathname != NULL) { |
| 158 do { | 159 do { |
| 159 abs_path = realpath(pathname, NULL); | 160 abs_path = realpath(pathname, NULL); |
| 160 } while (abs_path == NULL && errno == EINTR); | 161 } while (abs_path == NULL && errno == EINTR); |
| 161 assert(abs_path == NULL || IsAbsolutePath(abs_path)); | 162 ASSERT(abs_path == NULL || IsAbsolutePath(abs_path)); |
| 162 } | 163 } |
| 163 return abs_path; | 164 return abs_path; |
| 164 } | 165 } |
| 165 | 166 |
| 166 | 167 |
| 167 const char* File::PathSeparator() { | 168 const char* File::PathSeparator() { |
| 168 return "/"; | 169 return "/"; |
| 169 } | 170 } |
| 170 | 171 |
| 171 | 172 |
| 172 const char* File::StringEscapedPathSeparator() { | 173 const char* File::StringEscapedPathSeparator() { |
| 173 return "/"; | 174 return "/"; |
| 174 } | 175 } |
| OLD | NEW |