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

Side by Side Diff: base/file_util.h

Issue 93263002: Move some more file utils to the base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 | « base/base_paths_posix.cc ('k') | base/file_util.cc » ('j') | 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 // This file contains utility functions for dealing with the local 5 // This file contains utility functions for dealing with the local
6 // filesystem. 6 // filesystem.
7 7
8 #ifndef BASE_FILE_UTIL_H_ 8 #ifndef BASE_FILE_UTIL_H_
9 #define BASE_FILE_UTIL_H_ 9 #define BASE_FILE_UTIL_H_
10 10
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 // Reads the permission of the given |path|, storing the file permission 174 // Reads the permission of the given |path|, storing the file permission
175 // bits in |mode|. If |path| is symbolic link, |mode| is the permission of 175 // bits in |mode|. If |path| is symbolic link, |mode| is the permission of
176 // a file which the symlink points to. 176 // a file which the symlink points to.
177 BASE_EXPORT bool GetPosixFilePermissions(const FilePath& path, int* mode); 177 BASE_EXPORT bool GetPosixFilePermissions(const FilePath& path, int* mode);
178 // Sets the permission of the given |path|. If |path| is symbolic link, sets 178 // Sets the permission of the given |path|. If |path| is symbolic link, sets
179 // the permission of a file which the symlink points to. 179 // the permission of a file which the symlink points to.
180 BASE_EXPORT bool SetPosixFilePermissions(const FilePath& path, int mode); 180 BASE_EXPORT bool SetPosixFilePermissions(const FilePath& path, int mode);
181 181
182 #endif // OS_POSIX 182 #endif // OS_POSIX
183 183
184 // Returns true if the given directory is empty
185 BASE_EXPORT bool IsDirectoryEmpty(const FilePath& dir_path);
186
187 // Get the temporary directory provided by the system.
188 //
189 // WARNING: In general, you should use CreateTemporaryFile variants below
190 // instead of this function. Those variants will ensure that the proper
191 // permissions are set so that other users on the system can't edit them while
192 // they're open (which can lead to security issues).
193 BASE_EXPORT bool GetTempDir(FilePath* path);
194
195 // Get a temporary directory for shared memory files. The directory may depend
196 // on whether the destination is intended for executable files, which in turn
197 // depends on how /dev/shmem was mounted. As a result, you must supply whether
198 // you intend to create executable shmem segments so this function can find
199 // an appropriate location.
200 //
201 // Only useful on POSIX; redirects to GetTempDir() on Windows.
202 BASE_EXPORT bool GetShmemTempDir(bool executable, FilePath* path);
203
204 #if defined(OS_POSIX)
205 // Get the home directory. This is more complicated than just getenv("HOME")
206 // as it knows to fall back on getpwent() etc.
207 //
208 // This function is not currently implemented on Windows or Mac because we
209 // don't use it. Generally you would use one of PathService's APP_DATA
210 // directories on those platforms. If we need it, this could be implemented
211 // there to return the appropriate directory.
212 BASE_EXPORT FilePath GetHomeDir();
213 #endif // OS_POSIX
214
184 } // namespace base 215 } // namespace base
185 216
186 // ----------------------------------------------------------------------------- 217 // -----------------------------------------------------------------------------
187 218
188 namespace file_util { 219 namespace file_util {
189 220
190 // Return true if the given directory is empty
191 BASE_EXPORT bool IsDirectoryEmpty(const base::FilePath& dir_path);
192
193 // Get the temporary directory provided by the system.
194 // WARNING: DON'T USE THIS. If you want to create a temporary file, use one of
195 // the functions below.
196 BASE_EXPORT bool GetTempDir(base::FilePath* path);
197 // Get a temporary directory for shared memory files.
198 // Only useful on POSIX; redirects to GetTempDir() on Windows.
199 BASE_EXPORT bool GetShmemTempDir(base::FilePath* path, bool executable);
200
201 // Get the home directory. This is more complicated than just getenv("HOME")
202 // as it knows to fall back on getpwent() etc.
203 BASE_EXPORT base::FilePath GetHomeDir();
204
205 // Creates a temporary file. The full path is placed in |path|, and the 221 // Creates a temporary file. The full path is placed in |path|, and the
206 // function returns true if was successful in creating the file. The file will 222 // function returns true if was successful in creating the file. The file will
207 // be empty and all handles closed after this function returns. 223 // be empty and all handles closed after this function returns.
208 BASE_EXPORT bool CreateTemporaryFile(base::FilePath* path); 224 BASE_EXPORT bool CreateTemporaryFile(base::FilePath* path);
209 225
210 // Same as CreateTemporaryFile but the file is created in |dir|. 226 // Same as CreateTemporaryFile but the file is created in |dir|.
211 BASE_EXPORT bool CreateTemporaryFileInDir(const base::FilePath& dir, 227 BASE_EXPORT bool CreateTemporaryFileInDir(const base::FilePath& dir,
212 base::FilePath* temp_file); 228 base::FilePath* temp_file);
213 229
214 // Create and open a temporary file. File is opened for read/write. 230 // Create and open a temporary file. File is opened for read/write.
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 // This function simulates Move(), but unlike Move() it works across volumes. 467 // This function simulates Move(), but unlike Move() it works across volumes.
452 // This function is not transactional. 468 // This function is not transactional.
453 BASE_EXPORT bool CopyAndDeleteDirectory(const FilePath& from_path, 469 BASE_EXPORT bool CopyAndDeleteDirectory(const FilePath& from_path,
454 const FilePath& to_path); 470 const FilePath& to_path);
455 #endif // defined(OS_WIN) 471 #endif // defined(OS_WIN)
456 472
457 } // namespace internal 473 } // namespace internal
458 } // namespace base 474 } // namespace base
459 475
460 #endif // BASE_FILE_UTIL_H_ 476 #endif // BASE_FILE_UTIL_H_
OLDNEW
« no previous file with comments | « base/base_paths_posix.cc ('k') | base/file_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698