diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-02 18:55:49 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-02 18:55:49 +0000 |
commit | fb4bcfa38b2cdd740fd112fabeb5d45add27354b (patch) | |
tree | ae328c487cad94671d0788b3287cdd053f5d46a6 /base/file_util.h | |
parent | 072b8d48705dc76cafa1aa8189f62a15c94aa7fb (diff) | |
download | chromium_src-fb4bcfa38b2cdd740fd112fabeb5d45add27354b.zip chromium_src-fb4bcfa38b2cdd740fd112fabeb5d45add27354b.tar.gz chromium_src-fb4bcfa38b2cdd740fd112fabeb5d45add27354b.tar.bz2 |
Move some more file utils to the base namespace.
This also swaps the order of the parameters to GetShmemTempDir so the out
parameter is last, and enhances some documentation.
Review URL: https://codereview.chromium.org/93263002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@238144 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/file_util.h')
-rw-r--r-- | base/file_util.h | 44 |
1 files changed, 30 insertions, 14 deletions
diff --git a/base/file_util.h b/base/file_util.h index ac9f67d..35225c7 100644 --- a/base/file_util.h +++ b/base/file_util.h @@ -181,26 +181,42 @@ BASE_EXPORT bool SetPosixFilePermissions(const FilePath& path, int mode); #endif // OS_POSIX -} // namespace base - -// ----------------------------------------------------------------------------- - -namespace file_util { - -// Return true if the given directory is empty -BASE_EXPORT bool IsDirectoryEmpty(const base::FilePath& dir_path); +// Returns true if the given directory is empty +BASE_EXPORT bool IsDirectoryEmpty(const FilePath& dir_path); // Get the temporary directory provided by the system. -// WARNING: DON'T USE THIS. If you want to create a temporary file, use one of -// the functions below. -BASE_EXPORT bool GetTempDir(base::FilePath* path); -// Get a temporary directory for shared memory files. +// +// WARNING: In general, you should use CreateTemporaryFile variants below +// instead of this function. Those variants will ensure that the proper +// permissions are set so that other users on the system can't edit them while +// they're open (which can lead to security issues). +BASE_EXPORT bool GetTempDir(FilePath* path); + +// Get a temporary directory for shared memory files. The directory may depend +// on whether the destination is intended for executable files, which in turn +// depends on how /dev/shmem was mounted. As a result, you must supply whether +// you intend to create executable shmem segments so this function can find +// an appropriate location. +// // Only useful on POSIX; redirects to GetTempDir() on Windows. -BASE_EXPORT bool GetShmemTempDir(base::FilePath* path, bool executable); +BASE_EXPORT bool GetShmemTempDir(bool executable, FilePath* path); +#if defined(OS_POSIX) // Get the home directory. This is more complicated than just getenv("HOME") // as it knows to fall back on getpwent() etc. -BASE_EXPORT base::FilePath GetHomeDir(); +// +// This function is not currently implemented on Windows or Mac because we +// don't use it. Generally you would use one of PathService's APP_DATA +// directories on those platforms. If we need it, this could be implemented +// there to return the appropriate directory. +BASE_EXPORT FilePath GetHomeDir(); +#endif // OS_POSIX + +} // namespace base + +// ----------------------------------------------------------------------------- + +namespace file_util { // Creates a temporary file. The full path is placed in |path|, and the // function returns true if was successful in creating the file. The file will |