Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(325)

Side by Side Diff: runtime/bin/file_macos.cc

Issue 252123005: Make FileStat have millisecond precisions, for linux, mac and android. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/bin/file_linux.cc ('k') | runtime/bin/file_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_MACOS) 6 #if defined(TARGET_OS_MACOS)
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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 243
244 int64_t File::LengthFromPath(const char* name) { 244 int64_t File::LengthFromPath(const char* name) {
245 struct stat st; 245 struct stat st;
246 if (NO_RETRY_EXPECTED(stat(name, &st)) == 0) { 246 if (NO_RETRY_EXPECTED(stat(name, &st)) == 0) {
247 return st.st_size; 247 return st.st_size;
248 } 248 }
249 return -1; 249 return -1;
250 } 250 }
251 251
252 252
253 static int64_t TimespecToMilliseconds(const struct timespec& t) {
254 return static_cast<int64_t>(t.tv_sec) * 1000L +
255 static_cast<int64_t>(t.tv_nsec) / 1000000L;
256 }
257
258
253 void File::Stat(const char* name, int64_t* data) { 259 void File::Stat(const char* name, int64_t* data) {
254 struct stat st; 260 struct stat st;
255 if (NO_RETRY_EXPECTED(stat(name, &st)) == 0) { 261 if (NO_RETRY_EXPECTED(stat(name, &st)) == 0) {
256 if (S_ISREG(st.st_mode)) { 262 if (S_ISREG(st.st_mode)) {
257 data[kType] = kIsFile; 263 data[kType] = kIsFile;
258 } else if (S_ISDIR(st.st_mode)) { 264 } else if (S_ISDIR(st.st_mode)) {
259 data[kType] = kIsDirectory; 265 data[kType] = kIsDirectory;
260 } else if (S_ISLNK(st.st_mode)) { 266 } else if (S_ISLNK(st.st_mode)) {
261 data[kType] = kIsLink; 267 data[kType] = kIsLink;
262 } else { 268 } else {
263 data[kType] = kDoesNotExist; 269 data[kType] = kDoesNotExist;
264 } 270 }
265 data[kCreatedTime] = st.st_ctime; 271 data[kCreatedTime] = st.st_ctime;
266 data[kModifiedTime] = st.st_mtime; 272 data[kModifiedTime] = st.st_mtime;
267 data[kAccessedTime] = st.st_atime; 273 data[kAccessedTime] = st.st_atime;
274 data[kCreatedTime] = TimespecToMilliseconds(st.st_ctimespec);
275 data[kModifiedTime] = TimespecToMilliseconds(st.st_mtimespec);
276 data[kAccessedTime] = TimespecToMilliseconds(st.st_atimespec);
268 data[kMode] = st.st_mode; 277 data[kMode] = st.st_mode;
269 data[kSize] = st.st_size; 278 data[kSize] = st.st_size;
270 } else { 279 } else {
271 data[kType] = kDoesNotExist; 280 data[kType] = kDoesNotExist;
272 } 281 }
273 } 282 }
274 283
275 284
276 time_t File::LastModified(const char* name) { 285 time_t File::LastModified(const char* name) {
277 struct stat st; 286 struct stat st;
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 return (file_1_info.st_ino == file_2_info.st_ino && 387 return (file_1_info.st_ino == file_2_info.st_ino &&
379 file_1_info.st_dev == file_2_info.st_dev) ? 388 file_1_info.st_dev == file_2_info.st_dev) ?
380 File::kIdentical : 389 File::kIdentical :
381 File::kDifferent; 390 File::kDifferent;
382 } 391 }
383 392
384 } // namespace bin 393 } // namespace bin
385 } // namespace dart 394 } // namespace dart
386 395
387 #endif // defined(TARGET_OS_MACOS) 396 #endif // defined(TARGET_OS_MACOS)
OLDNEW
« no previous file with comments | « runtime/bin/file_linux.cc ('k') | runtime/bin/file_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698