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

Side by Side Diff: base/file_util_posix.cc

Issue 16093026: Provide nanoseconds precision for base::PlatformFileInfo on POSIX (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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 | « no previous file | no next file » | 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 Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/file_util.h" 5 #include "base/file_util.h"
6 6
7 #include <dirent.h> 7 #include <dirent.h>
8 #include <errno.h> 8 #include <errno.h>
9 #include <fcntl.h> 9 #include <fcntl.h>
10 #include <fnmatch.h> 10 #include <fnmatch.h>
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 else 581 else
582 return false; 582 return false;
583 } 583 }
584 584
585 bool GetFileInfo(const FilePath& file_path, base::PlatformFileInfo* results) { 585 bool GetFileInfo(const FilePath& file_path, base::PlatformFileInfo* results) {
586 stat_wrapper_t file_info; 586 stat_wrapper_t file_info;
587 if (CallStat(file_path.value().c_str(), &file_info) != 0) 587 if (CallStat(file_path.value().c_str(), &file_info) != 0)
588 return false; 588 return false;
589 results->is_directory = S_ISDIR(file_info.st_mode); 589 results->is_directory = S_ISDIR(file_info.st_mode);
590 results->size = file_info.st_size; 590 results->size = file_info.st_size;
591 results->last_modified = base::Time::FromTimeT(file_info.st_mtime); 591 results->last_modified = base::Time::FromDoubleT(file_info.st_mtim.tv_sec +
592 results->last_accessed = base::Time::FromTimeT(file_info.st_atime); 592 static_cast<double>(file_info.st_mtim.tv_nsec) /
593 results->creation_time = base::Time::FromTimeT(file_info.st_ctime); 593 base::Time::kNanosecondsPerSecond);
594 results->last_accessed = base::Time::FromDoubleT(file_info.st_atim.tv_sec +
595 static_cast<double>(file_info.st_atim.tv_nsec) /
596 base::Time::kNanosecondsPerSecond);
597 results->creation_time = base::Time::FromDoubleT(file_info.st_ctim.tv_sec +
598 static_cast<double>(file_info.st_ctim.tv_nsec) /
599 base::Time::kNanosecondsPerSecond);
tzik 2013/06/05 04:00:17 Can we add Time::FromTimeSpec(const timespec&) and
apavlov 2013/06/05 17:03:41 Done.
594 return true; 600 return true;
595 } 601 }
596 602
597 bool GetInode(const FilePath& path, ino_t* inode) { 603 bool GetInode(const FilePath& path, ino_t* inode) {
598 base::ThreadRestrictions::AssertIOAllowed(); // For call to stat(). 604 base::ThreadRestrictions::AssertIOAllowed(); // For call to stat().
599 struct stat buffer; 605 struct stat buffer;
600 int result = stat(path.value().c_str(), &buffer); 606 int result = stat(path.value().c_str(), &buffer);
601 if (result < 0) 607 if (result < 0)
602 return false; 608 return false;
603 609
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
1067 kFileSystemRoot, path, kRootUid, allowed_group_ids); 1073 kFileSystemRoot, path, kRootUid, allowed_group_ids);
1068 } 1074 }
1069 #endif // defined(OS_MACOSX) && !defined(OS_IOS) 1075 #endif // defined(OS_MACOSX) && !defined(OS_IOS)
1070 1076
1071 int GetMaximumPathComponentLength(const FilePath& path) { 1077 int GetMaximumPathComponentLength(const FilePath& path) {
1072 base::ThreadRestrictions::AssertIOAllowed(); 1078 base::ThreadRestrictions::AssertIOAllowed();
1073 return pathconf(path.value().c_str(), _PC_NAME_MAX); 1079 return pathconf(path.value().c_str(), _PC_NAME_MAX);
1074 } 1080 }
1075 1081
1076 } // namespace file_util 1082 } // namespace file_util
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698