summaryrefslogtreecommitdiffstats
path: root/base/file_util_posix.cc
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-04 20:56:49 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-04 20:56:49 +0000
commit9eae4e686d49213ee7dba24cdf28f13d38b99741 (patch)
tree353f674537dc93191c54033123904fc84f2eb0cd /base/file_util_posix.cc
parentba23e5d378762bf5e7a25f8f6591674c5d25e365 (diff)
downloadchromium_src-9eae4e686d49213ee7dba24cdf28f13d38b99741.zip
chromium_src-9eae4e686d49213ee7dba24cdf28f13d38b99741.tar.gz
chromium_src-9eae4e686d49213ee7dba24cdf28f13d38b99741.tar.bz2
Move more file_util functions to base namespace.
This moves DevicePathToDriveLetterPath, NormalizeToNativeFilePath, IsLink, and GetFileInfo. This also removes some explicit "base::" usage in base files I touched. TBR=jam Review URL: https://codereview.chromium.org/105293002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@238763 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/file_util_posix.cc')
-rw-r--r--base/file_util_posix.cc92
1 files changed, 46 insertions, 46 deletions
diff --git a/base/file_util_posix.cc b/base/file_util_posix.cc
index f3a7553..fdf196e 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;