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 "platform/globals.h" | 5 #include "platform/globals.h" |
6 #if defined(TARGET_OS_ANDROID) | 6 #if defined(TARGET_OS_ANDROID) |
7 | 7 |
8 #include "bin/file.h" | 8 #include "bin/file.h" |
9 | 9 |
10 #include <errno.h> // NOLINT | 10 #include <errno.h> // NOLINT |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 | 194 |
195 off_t File::LengthFromPath(const char* name) { | 195 off_t File::LengthFromPath(const char* name) { |
196 struct stat st; | 196 struct stat st; |
197 if (TEMP_FAILURE_RETRY(stat(name, &st)) == 0) { | 197 if (TEMP_FAILURE_RETRY(stat(name, &st)) == 0) { |
198 return st.st_size; | 198 return st.st_size; |
199 } | 199 } |
200 return -1; | 200 return -1; |
201 } | 201 } |
202 | 202 |
203 | 203 |
| 204 void File::Stat(const char* name, int64_t* data) { |
| 205 struct stat st; |
| 206 if (TEMP_FAILURE_RETRY(stat(name, &st)) == 0) { |
| 207 if (S_ISREG(st.st_mode)) { |
| 208 data[kType] = kIsFile; |
| 209 } else if (S_ISDIR(st.st_mode)) { |
| 210 data[kType] = kIsDirectory; |
| 211 } else if (S_ISLNK(st.st_mode)) { |
| 212 data[kType] = kIsLink; |
| 213 } else { |
| 214 data[kType] = kDoesNotExist; |
| 215 } |
| 216 data[kCreatedTime] = st.st_ctime; |
| 217 data[kModifiedTime] = st.st_mtime; |
| 218 data[kAccessedTime] = st.st_atime; |
| 219 data[kMode] = st.st_mode; |
| 220 data[kSize] = st.st_size; |
| 221 } else { |
| 222 data[kType] = kDoesNotExist; |
| 223 data[kCreatedTime] = 0; |
| 224 data[kModifiedTime] = 0; |
| 225 data[kAccessedTime] = 0; |
| 226 data[kMode] = 0; |
| 227 data[kSize] = 0; |
| 228 } |
| 229 } |
| 230 |
| 231 |
204 time_t File::LastModified(const char* name) { | 232 time_t File::LastModified(const char* name) { |
205 struct stat st; | 233 struct stat st; |
206 if (TEMP_FAILURE_RETRY(stat(name, &st)) == 0) { | 234 if (TEMP_FAILURE_RETRY(stat(name, &st)) == 0) { |
207 return st.st_mtime; | 235 return st.st_mtime; |
208 } | 236 } |
209 return -1; | 237 return -1; |
210 } | 238 } |
211 | 239 |
212 | 240 |
213 char* File::LinkTarget(const char* pathname) { | 241 char* File::LinkTarget(const char* pathname) { |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 return (file_1_info.st_ino == file_2_info.st_ino && | 344 return (file_1_info.st_ino == file_2_info.st_ino && |
317 file_1_info.st_dev == file_2_info.st_dev) ? | 345 file_1_info.st_dev == file_2_info.st_dev) ? |
318 File::kIdentical : | 346 File::kIdentical : |
319 File::kDifferent; | 347 File::kDifferent; |
320 } | 348 } |
321 | 349 |
322 } // namespace bin | 350 } // namespace bin |
323 } // namespace dart | 351 } // namespace dart |
324 | 352 |
325 #endif // defined(TARGET_OS_ANDROID) | 353 #endif // defined(TARGET_OS_ANDROID) |
OLD | NEW |