Chromium Code Reviews| 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" | 5 #include "bin/file.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <fcntl.h> | 8 #include <fcntl.h> |
| 9 #include <sys/stat.h> | 9 #include <sys/stat.h> |
| 10 #include <unistd.h> | 10 #include <unistd.h> |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 167 | 167 |
| 168 off_t File::LengthFromName(const char* name) { | 168 off_t File::LengthFromName(const char* name) { |
| 169 struct stat st; | 169 struct stat st; |
| 170 if (TEMP_FAILURE_RETRY(stat(name, &st)) == 0) { | 170 if (TEMP_FAILURE_RETRY(stat(name, &st)) == 0) { |
| 171 return st.st_size; | 171 return st.st_size; |
| 172 } | 172 } |
| 173 return -1; | 173 return -1; |
| 174 } | 174 } |
| 175 | 175 |
| 176 | 176 |
| 177 time_t File::LastModified(const char* name) { | |
|
Anders Johnsen
2012/05/24 12:05:42
intprt_t
| |
| 178 struct stat st; | |
| 179 if (TEMP_FAILURE_RETRY(stat(name, &st)) == 0) { | |
| 180 return st.st_mtime; | |
| 181 } | |
| 182 return -1; | |
| 183 } | |
| 184 | |
| 185 | |
| 177 bool File::IsAbsolutePath(const char* pathname) { | 186 bool File::IsAbsolutePath(const char* pathname) { |
| 178 return (pathname != NULL && pathname[0] == '/'); | 187 return (pathname != NULL && pathname[0] == '/'); |
| 179 } | 188 } |
| 180 | 189 |
| 181 | 190 |
| 182 char* File::GetCanonicalPath(const char* pathname) { | 191 char* File::GetCanonicalPath(const char* pathname) { |
| 183 char* abs_path = NULL; | 192 char* abs_path = NULL; |
| 184 if (pathname != NULL) { | 193 if (pathname != NULL) { |
| 185 do { | 194 do { |
| 186 abs_path = realpath(pathname, NULL); | 195 abs_path = realpath(pathname, NULL); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 226 int result = fstat(fd, &buf); | 235 int result = fstat(fd, &buf); |
| 227 if (result == -1) { | 236 if (result == -1) { |
| 228 FATAL2("Failed stat on file descriptor %d: %s", fd, strerror(errno)); | 237 FATAL2("Failed stat on file descriptor %d: %s", fd, strerror(errno)); |
| 229 } | 238 } |
| 230 if (S_ISCHR(buf.st_mode)) return kTerminal; | 239 if (S_ISCHR(buf.st_mode)) return kTerminal; |
| 231 if (S_ISFIFO(buf.st_mode)) return kPipe; | 240 if (S_ISFIFO(buf.st_mode)) return kPipe; |
| 232 if (S_ISSOCK(buf.st_mode)) return kSocket; | 241 if (S_ISSOCK(buf.st_mode)) return kSocket; |
| 233 if (S_ISREG(buf.st_mode)) return kFile; | 242 if (S_ISREG(buf.st_mode)) return kFile; |
| 234 return kOther; | 243 return kOther; |
| 235 } | 244 } |
| OLD | NEW |