OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 | 253 |
254 // Return true if the given directory is empty | 254 // Return true if the given directory is empty |
255 bool IsDirectoryEmpty(const std::wstring& dir_path); | 255 bool IsDirectoryEmpty(const std::wstring& dir_path); |
256 | 256 |
257 #endif | 257 #endif |
258 | 258 |
259 // Get the temporary directory provided by the system. | 259 // Get the temporary directory provided by the system. |
260 bool GetTempDir(FilePath* path); | 260 bool GetTempDir(FilePath* path); |
261 // Deprecated temporary compatibility function. | 261 // Deprecated temporary compatibility function. |
262 bool GetTempDir(std::wstring* path); | 262 bool GetTempDir(std::wstring* path); |
| 263 // Get a temporary directory for shared memory files. |
| 264 // Only useful on POSIX; redirects to GetTempDir() on Windows. |
| 265 bool GetShmemTempDir(FilePath* path); |
263 | 266 |
264 // Creates a temporary file. The full path is placed in |path|, and the | 267 // Creates a temporary file. The full path is placed in |path|, and the |
265 // function returns true if was successful in creating the file. The file will | 268 // function returns true if was successful in creating the file. The file will |
266 // be empty and all handles closed after this function returns. | 269 // be empty and all handles closed after this function returns. |
267 // TODO(erikkay): rename this function and track down all of the callers. | 270 // TODO(erikkay): rename this function and track down all of the callers. |
| 271 // (Clarification of erik's comment: the intent is to rename the BlahFileName() |
| 272 // calls into BlahFile(), since they create temp files (not temp filenames).) |
268 bool CreateTemporaryFileName(FilePath* path); | 273 bool CreateTemporaryFileName(FilePath* path); |
269 // Deprecated temporary compatibility function. | 274 // Deprecated temporary compatibility function. |
270 bool CreateTemporaryFileName(std::wstring* temp_file); | 275 bool CreateTemporaryFileName(std::wstring* temp_file); |
271 | 276 |
| 277 // Create and open a temporary file. File is opened for read/write. |
| 278 // The full path is placed in |path|, and the function returns true if |
| 279 // was successful in creating and opening the file. |
| 280 FILE* CreateAndOpenTemporaryFile(FilePath* path); |
| 281 // Like above but for shmem files. Only useful for POSIX. |
| 282 FILE* CreateAndOpenTemporaryShmemFile(FilePath* path); |
| 283 |
272 // Same as CreateTemporaryFileName but the file is created in |dir|. | 284 // Same as CreateTemporaryFileName but the file is created in |dir|. |
273 bool CreateTemporaryFileNameInDir(const std::wstring& dir, | 285 bool CreateTemporaryFileNameInDir(const std::wstring& dir, |
274 std::wstring* temp_file); | 286 std::wstring* temp_file); |
275 | 287 |
276 // Create a new directory under TempPath. If prefix is provided, the new | 288 // Create a new directory under TempPath. If prefix is provided, the new |
277 // directory name is in the format of prefixyyyy. | 289 // directory name is in the format of prefixyyyy. |
278 // NOTE: prefix is ignored in the POSIX implementation. | 290 // NOTE: prefix is ignored in the POSIX implementation. |
279 // TODO(erikkay): is this OK? | 291 // TODO(erikkay): is this OK? |
280 // If success, return true and output the full path of the directory created. | 292 // If success, return true and output the full path of the directory created. |
281 bool CreateNewTempDirectory(const FilePath::StringType& prefix, | 293 bool CreateNewTempDirectory(const FilePath::StringType& prefix, |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 | 495 |
484 // Renames a file using the SHFileOperation API to ensure that the target file | 496 // Renames a file using the SHFileOperation API to ensure that the target file |
485 // gets the correct default security descriptor in the new path. | 497 // gets the correct default security descriptor in the new path. |
486 bool RenameFileAndResetSecurityDescriptor( | 498 bool RenameFileAndResetSecurityDescriptor( |
487 const FilePath& source_file_path, | 499 const FilePath& source_file_path, |
488 const FilePath& target_file_path); | 500 const FilePath& target_file_path); |
489 | 501 |
490 } // namespace file_util | 502 } // namespace file_util |
491 | 503 |
492 #endif // BASE_FILE_UTIL_H_ | 504 #endif // BASE_FILE_UTIL_H_ |
OLD | NEW |