| Index: base/file_util_posix.cc
|
| diff --git a/base/file_util_posix.cc b/base/file_util_posix.cc
|
| index f3a7553148721a34ca190c86e5fda45646f9a5b7..fdf196ec83e632ef3db223e3aaed6e468713537e 100644
|
| --- a/base/file_util_posix.cc
|
| +++ b/base/file_util_posix.cc
|
| @@ -639,40 +639,6 @@ bool NormalizeFilePath(const FilePath& path, FilePath* normalized_path) {
|
| return true;
|
| }
|
|
|
| -} // namespace base
|
| -
|
| -// -----------------------------------------------------------------------------
|
| -
|
| -namespace file_util {
|
| -
|
| -using base::stat_wrapper_t;
|
| -using base::CallStat;
|
| -using base::CallLstat;
|
| -using base::CreateAndOpenFdForTemporaryFile;
|
| -using base::DirectoryExists;
|
| -using base::FileEnumerator;
|
| -using base::FilePath;
|
| -using base::MakeAbsoluteFilePath;
|
| -using base::VerifySpecificPathControlledByUser;
|
| -
|
| -base::FilePath MakeUniqueDirectory(const base::FilePath& path) {
|
| - const int kMaxAttempts = 20;
|
| - for (int attempts = 0; attempts < kMaxAttempts; attempts++) {
|
| - int uniquifier =
|
| - GetUniquePathNumber(path, base::FilePath::StringType());
|
| - if (uniquifier < 0)
|
| - break;
|
| - base::FilePath test_path = (uniquifier == 0) ? path :
|
| - path.InsertBeforeExtensionASCII(
|
| - base::StringPrintf(" (%d)", uniquifier));
|
| - if (mkdir(test_path.value().c_str(), 0777) == 0)
|
| - return test_path;
|
| - else if (errno != EEXIST)
|
| - break;
|
| - }
|
| - return base::FilePath();
|
| -}
|
| -
|
| // TODO(rkc): Refactor GetFileInfo and FileEnumerator to handle symlinks
|
| // correctly. http://code.google.com/p/chromium-os/issues/detail?id=15948
|
| bool IsLink(const FilePath& file_path) {
|
| @@ -688,15 +654,15 @@ bool IsLink(const FilePath& file_path) {
|
| return false;
|
| }
|
|
|
| -bool GetFileInfo(const FilePath& file_path, base::PlatformFileInfo* results) {
|
| +bool GetFileInfo(const FilePath& file_path, PlatformFileInfo* results) {
|
| stat_wrapper_t file_info;
|
| #if defined(OS_ANDROID)
|
| if (file_path.IsContentUri()) {
|
| int fd = OpenContentUriForRead(file_path);
|
| if (fd < 0)
|
| return false;
|
| - ScopedFD scoped_fd(&fd);
|
| - if (base::CallFstat(fd, &file_info) != 0)
|
| + file_util::ScopedFD scoped_fd(&fd);
|
| + if (CallFstat(fd, &file_info) != 0)
|
| return false;
|
| } else {
|
| #endif // defined(OS_ANDROID)
|
| @@ -708,21 +674,55 @@ bool GetFileInfo(const FilePath& file_path, base::PlatformFileInfo* results) {
|
| results->is_directory = S_ISDIR(file_info.st_mode);
|
| results->size = file_info.st_size;
|
| #if defined(OS_MACOSX)
|
| - results->last_modified = base::Time::FromTimeSpec(file_info.st_mtimespec);
|
| - results->last_accessed = base::Time::FromTimeSpec(file_info.st_atimespec);
|
| - results->creation_time = base::Time::FromTimeSpec(file_info.st_ctimespec);
|
| + results->last_modified = Time::FromTimeSpec(file_info.st_mtimespec);
|
| + results->last_accessed = Time::FromTimeSpec(file_info.st_atimespec);
|
| + results->creation_time = Time::FromTimeSpec(file_info.st_ctimespec);
|
| #elif defined(OS_ANDROID)
|
| - results->last_modified = base::Time::FromTimeT(file_info.st_mtime);
|
| - results->last_accessed = base::Time::FromTimeT(file_info.st_atime);
|
| - results->creation_time = base::Time::FromTimeT(file_info.st_ctime);
|
| + results->last_modified = Time::FromTimeT(file_info.st_mtime);
|
| + results->last_accessed = Time::FromTimeT(file_info.st_atime);
|
| + results->creation_time = Time::FromTimeT(file_info.st_ctime);
|
| #else
|
| - results->last_modified = base::Time::FromTimeSpec(file_info.st_mtim);
|
| - results->last_accessed = base::Time::FromTimeSpec(file_info.st_atim);
|
| - results->creation_time = base::Time::FromTimeSpec(file_info.st_ctim);
|
| + results->last_modified = Time::FromTimeSpec(file_info.st_mtim);
|
| + results->last_accessed = Time::FromTimeSpec(file_info.st_atim);
|
| + results->creation_time = Time::FromTimeSpec(file_info.st_ctim);
|
| #endif
|
| return true;
|
| }
|
|
|
| +} // namespace base
|
| +
|
| +// -----------------------------------------------------------------------------
|
| +
|
| +namespace file_util {
|
| +
|
| +using base::stat_wrapper_t;
|
| +using base::CallStat;
|
| +using base::CallLstat;
|
| +using base::CreateAndOpenFdForTemporaryFile;
|
| +using base::DirectoryExists;
|
| +using base::FileEnumerator;
|
| +using base::FilePath;
|
| +using base::MakeAbsoluteFilePath;
|
| +using base::VerifySpecificPathControlledByUser;
|
| +
|
| +base::FilePath MakeUniqueDirectory(const base::FilePath& path) {
|
| + const int kMaxAttempts = 20;
|
| + for (int attempts = 0; attempts < kMaxAttempts; attempts++) {
|
| + int uniquifier =
|
| + GetUniquePathNumber(path, base::FilePath::StringType());
|
| + if (uniquifier < 0)
|
| + break;
|
| + base::FilePath test_path = (uniquifier == 0) ? path :
|
| + path.InsertBeforeExtensionASCII(
|
| + base::StringPrintf(" (%d)", uniquifier));
|
| + if (mkdir(test_path.value().c_str(), 0777) == 0)
|
| + return test_path;
|
| + else if (errno != EEXIST)
|
| + break;
|
| + }
|
| + return base::FilePath();
|
| +}
|
| +
|
| bool GetInode(const FilePath& path, ino_t* inode) {
|
| base::ThreadRestrictions::AssertIOAllowed(); // For call to stat().
|
| struct stat buffer;
|
|
|