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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 168 | 168 |
| 169 off_t File::LengthFromName(const char* name) { | 169 off_t File::LengthFromName(const char* name) { |
| 170 struct stat st; | 170 struct stat st; |
| 171 if (TEMP_FAILURE_RETRY(stat(name, &st)) == 0) { | 171 if (TEMP_FAILURE_RETRY(stat(name, &st)) == 0) { |
| 172 return st.st_size; | 172 return st.st_size; |
| 173 } | 173 } |
| 174 return -1; | 174 return -1; |
| 175 } | 175 } |
| 176 | 176 |
| 177 | 177 |
| 178 time_t File::LastModified(const char* name) { | |
|
Anders Johnsen
2012/05/24 12:05:42
intptr_t
| |
| 179 struct stat st; | |
| 180 if (TEMP_FAILURE_RETRY(stat(name, &st)) == 0) { | |
| 181 return st.st_mtime; | |
| 182 } | |
| 183 return -1; | |
| 184 } | |
| 185 | |
| 186 | |
| 178 bool File::IsAbsolutePath(const char* pathname) { | 187 bool File::IsAbsolutePath(const char* pathname) { |
| 179 return (pathname != NULL && pathname[0] == '/'); | 188 return (pathname != NULL && pathname[0] == '/'); |
| 180 } | 189 } |
| 181 | 190 |
| 182 | 191 |
| 183 char* File::GetCanonicalPath(const char* pathname) { | 192 char* File::GetCanonicalPath(const char* pathname) { |
| 184 char* abs_path = NULL; | 193 char* abs_path = NULL; |
| 185 if (pathname != NULL) { | 194 if (pathname != NULL) { |
| 186 // On some older MacOs versions the default behaviour of realpath allocating | 195 // On some older MacOs versions the default behaviour of realpath allocating |
| 187 // space for the resolved_path when a NULL is passed in does not seem to | 196 // space for the resolved_path when a NULL is passed in does not seem to |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 233 int result = fstat(fd, &buf); | 242 int result = fstat(fd, &buf); |
| 234 if (result == -1) { | 243 if (result == -1) { |
| 235 FATAL2("Failed stat on file descriptor %d: %s", fd, strerror(errno)); | 244 FATAL2("Failed stat on file descriptor %d: %s", fd, strerror(errno)); |
| 236 } | 245 } |
| 237 if (S_ISCHR(buf.st_mode)) return kTerminal; | 246 if (S_ISCHR(buf.st_mode)) return kTerminal; |
| 238 if (S_ISFIFO(buf.st_mode)) return kPipe; | 247 if (S_ISFIFO(buf.st_mode)) return kPipe; |
| 239 if (S_ISSOCK(buf.st_mode)) return kSocket; | 248 if (S_ISSOCK(buf.st_mode)) return kSocket; |
| 240 if (S_ISREG(buf.st_mode)) return kFile; | 249 if (S_ISREG(buf.st_mode)) return kFile; |
| 241 return kOther; | 250 return kOther; |
| 242 } | 251 } |
| OLD | NEW |