| OLD | NEW |
| 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 | 10 |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 | 122 |
| 123 bool File::Create(const char* name) { | 123 bool File::Create(const char* name) { |
| 124 int fd = open(name, O_RDONLY | O_CREAT, 0666); | 124 int fd = open(name, O_RDONLY | O_CREAT, 0666); |
| 125 if (fd < 0) { | 125 if (fd < 0) { |
| 126 return false; | 126 return false; |
| 127 } | 127 } |
| 128 return (close(fd) == 0); | 128 return (close(fd) == 0); |
| 129 } | 129 } |
| 130 | 130 |
| 131 | 131 |
| 132 bool File::Delete(const char* name) { |
| 133 int status = remove(name); |
| 134 if (status == -1) { |
| 135 return false; |
| 136 } |
| 137 return true; |
| 138 } |
| 139 |
| 140 |
| 132 bool File::IsAbsolutePath(const char* pathname) { | 141 bool File::IsAbsolutePath(const char* pathname) { |
| 133 return (pathname != NULL && pathname[0] == '/'); | 142 return (pathname != NULL && pathname[0] == '/'); |
| 134 } | 143 } |
| 135 | 144 |
| 136 | 145 |
| 137 char* File::GetCanonicalPath(const char* pathname) { | 146 char* File::GetCanonicalPath(const char* pathname) { |
| 138 char* abs_path = NULL; | 147 char* abs_path = NULL; |
| 139 if (pathname != NULL) { | 148 if (pathname != NULL) { |
| 140 abs_path = realpath(pathname, NULL); | 149 abs_path = realpath(pathname, NULL); |
| 141 assert(abs_path == NULL || IsAbsolutePath(abs_path)); | 150 assert(abs_path == NULL || IsAbsolutePath(abs_path)); |
| 142 } | 151 } |
| 143 return abs_path; | 152 return abs_path; |
| 144 } | 153 } |
| 145 | 154 |
| 146 | 155 |
| 147 const char* File::PathSeparator() { | 156 const char* File::PathSeparator() { |
| 148 return "/"; | 157 return "/"; |
| 149 } | 158 } |
| 150 | 159 |
| 151 | 160 |
| 152 const char* File::StringEscapedPathSeparator() { | 161 const char* File::StringEscapedPathSeparator() { |
| 153 return "/"; | 162 return "/"; |
| 154 } | 163 } |
| OLD | NEW |