summaryrefslogtreecommitdiffstats
path: root/base/file_util.h
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-09 17:42:26 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-09 17:42:26 +0000
commitf0ff2ad2c5bcf8e206baf27dbfaeef7743fd6c0d (patch)
treef16870d528455ef5acb84e180e6e07afb308ee6f /base/file_util.h
parent456f3b4c2d9942fd86e7c374426d37f029542a9a (diff)
downloadchromium_src-f0ff2ad2c5bcf8e206baf27dbfaeef7743fd6c0d.zip
chromium_src-f0ff2ad2c5bcf8e206baf27dbfaeef7743fd6c0d.tar.gz
chromium_src-f0ff2ad2c5bcf8e206baf27dbfaeef7743fd6c0d.tar.bz2
Move Copy* into the base namespace.
This also creates a new base::internal namespace in file_util and I moved some of the internal functions in file_util to there. BUG= TBR=jam Review URL: https://codereview.chromium.org/18332014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@210600 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/file_util.h')
-rw-r--r--base/file_util.h65
1 files changed, 36 insertions, 29 deletions
diff --git a/base/file_util.h b/base/file_util.h
index bdef48a..321070f 100644
--- a/base/file_util.h
+++ b/base/file_util.h
@@ -87,11 +87,6 @@ BASE_EXPORT bool DeleteAfterReboot(const FilePath& path);
// This function fails if either path contains traversal components ('..').
BASE_EXPORT bool Move(const FilePath& from_path, const FilePath& to_path);
-// Same as Move but allows paths with traversal components.
-// Use only with extreme care.
-BASE_EXPORT bool MoveUnsafe(const FilePath& from_path,
- const FilePath& to_path);
-
// Renames file |from_path| to |to_path|. Both paths must be on the same
// volume, or the function will fail. Destination file will be created
// if it doesn't exist. Prefer this function over Move when dealing with
@@ -102,21 +97,9 @@ BASE_EXPORT bool ReplaceFile(const FilePath& from_path,
const FilePath& to_path,
PlatformFileError* error);
-} // namespace base
-
-// -----------------------------------------------------------------------------
-
-namespace file_util {
-
// Copies a single file. Use CopyDirectory to copy directories.
// This function fails if either path contains traversal components ('..').
-BASE_EXPORT bool CopyFile(const base::FilePath& from_path,
- const base::FilePath& to_path);
-
-// Same as CopyFile but allows paths with traversal components.
-// Use only with extreme care.
-BASE_EXPORT bool CopyFileUnsafe(const base::FilePath& from_path,
- const base::FilePath& to_path);
+BASE_EXPORT bool CopyFile(const FilePath& from_path, const FilePath& to_path);
// Copies the given path, and optionally all subdirectories and their contents
// as well.
@@ -125,10 +108,16 @@ BASE_EXPORT bool CopyFileUnsafe(const base::FilePath& from_path,
// if successful, false otherwise. Wildcards on the names are not supported.
//
// If you only need to copy a file use CopyFile, it's faster.
-BASE_EXPORT bool CopyDirectory(const base::FilePath& from_path,
- const base::FilePath& to_path,
+BASE_EXPORT bool CopyDirectory(const FilePath& from_path,
+ const FilePath& to_path,
bool recursive);
+} // namespace base
+
+// -----------------------------------------------------------------------------
+
+namespace file_util {
+
// Returns true if the given path exists on the local filesystem,
// false otherwise.
BASE_EXPORT bool PathExists(const base::FilePath& path);
@@ -202,15 +191,6 @@ BASE_EXPORT bool SetPosixFilePermissions(const base::FilePath& path,
int mode);
#endif // defined(OS_POSIX)
-#if defined(OS_WIN)
-// Copy from_path to to_path recursively and then delete from_path recursively.
-// Returns true if all operations succeed.
-// This function simulates Move(), but unlike Move() it works across volumes.
-// This fuction is not transactional.
-BASE_EXPORT bool CopyAndDeleteDirectory(const base::FilePath& from_path,
- const base::FilePath& to_path);
-#endif // defined(OS_WIN)
-
// Return true if the given directory is empty
BASE_EXPORT bool IsDirectoryEmpty(const base::FilePath& dir_path);
@@ -454,4 +434,31 @@ BASE_EXPORT bool GetFileSystemType(const base::FilePath& path,
} // namespace file_util
+// Internal --------------------------------------------------------------------
+
+namespace base {
+namespace internal {
+
+// Same as Move but allows paths with traversal components.
+// Use only with extreme care.
+BASE_EXPORT bool MoveUnsafe(const FilePath& from_path,
+ const FilePath& to_path);
+
+// Same as CopyFile but allows paths with traversal components.
+// Use only with extreme care.
+BASE_EXPORT bool CopyFileUnsafe(const FilePath& from_path,
+ const FilePath& to_path);
+
+#if defined(OS_WIN)
+// Copy from_path to to_path recursively and then delete from_path recursively.
+// Returns true if all operations succeed.
+// This function simulates Move(), but unlike Move() it works across volumes.
+// This fuction is not transactional.
+BASE_EXPORT bool CopyAndDeleteDirectory(const FilePath& from_path,
+ const FilePath& to_path);
+#endif // defined(OS_WIN)
+
+} // namespace internal
+} // namespace base
+
#endif // BASE_FILE_UTIL_H_