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

Side by Side Diff: base/file_util.h

Issue 8800025: Adaptively use temp dir instead of /dev/shm for executable shmem file on Linux (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: clean up per review Created 9 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 | « no previous file | base/file_util_android.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #pragma once 10 #pragma once
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 252
253 // Return true if the given directory is empty 253 // Return true if the given directory is empty
254 BASE_EXPORT bool IsDirectoryEmpty(const FilePath& dir_path); 254 BASE_EXPORT bool IsDirectoryEmpty(const FilePath& dir_path);
255 255
256 // Get the temporary directory provided by the system. 256 // Get the temporary directory provided by the system.
257 // WARNING: DON'T USE THIS. If you want to create a temporary file, use one of 257 // WARNING: DON'T USE THIS. If you want to create a temporary file, use one of
258 // the functions below. 258 // the functions below.
259 BASE_EXPORT bool GetTempDir(FilePath* path); 259 BASE_EXPORT bool GetTempDir(FilePath* path);
260 // Get a temporary directory for shared memory files. 260 // Get a temporary directory for shared memory files.
261 // Only useful on POSIX; redirects to GetTempDir() on Windows. 261 // Only useful on POSIX; redirects to GetTempDir() on Windows.
262 BASE_EXPORT bool GetShmemTempDir(FilePath* path); 262 BASE_EXPORT bool GetShmemTempDir(FilePath* path, bool executable);
263 263
264 // Get the home directory. This is more complicated than just getenv("HOME") 264 // Get the home directory. This is more complicated than just getenv("HOME")
265 // as it knows to fall back on getpwent() etc. 265 // as it knows to fall back on getpwent() etc.
266 BASE_EXPORT FilePath GetHomeDir(); 266 BASE_EXPORT FilePath GetHomeDir();
267 267
268 // Creates a temporary file. The full path is placed in |path|, and the 268 // Creates a temporary file. The full path is placed in |path|, and the
269 // function returns true if was successful in creating the file. The file will 269 // function returns true if was successful in creating the file. The file will
270 // be empty and all handles closed after this function returns. 270 // be empty and all handles closed after this function returns.
271 BASE_EXPORT bool CreateTemporaryFile(FilePath* path); 271 BASE_EXPORT bool CreateTemporaryFile(FilePath* path);
272 272
273 // Same as CreateTemporaryFile but the file is created in |dir|. 273 // Same as CreateTemporaryFile but the file is created in |dir|.
274 BASE_EXPORT bool CreateTemporaryFileInDir(const FilePath& dir, 274 BASE_EXPORT bool CreateTemporaryFileInDir(const FilePath& dir,
275 FilePath* temp_file); 275 FilePath* temp_file);
276 276
277 // Create and open a temporary file. File is opened for read/write. 277 // Create and open a temporary file. File is opened for read/write.
278 // The full path is placed in |path|. 278 // The full path is placed in |path|.
279 // Returns a handle to the opened file or NULL if an error occured. 279 // Returns a handle to the opened file or NULL if an error occured.
280 BASE_EXPORT FILE* CreateAndOpenTemporaryFile(FilePath* path); 280 BASE_EXPORT FILE* CreateAndOpenTemporaryFile(FilePath* path);
281 // Like above but for shmem files. Only useful for POSIX. 281 // Like above but for shmem files. Only useful for POSIX.
282 BASE_EXPORT FILE* CreateAndOpenTemporaryShmemFile(FilePath* path); 282 // The executable flag says the file needs to support using
283 // mprotect with PROT_EXEC after mapping.
284 BASE_EXPORT FILE* CreateAndOpenTemporaryShmemFile(FilePath* path,
285 bool executable);
283 // Similar to CreateAndOpenTemporaryFile, but the file is created in |dir|. 286 // Similar to CreateAndOpenTemporaryFile, but the file is created in |dir|.
284 BASE_EXPORT FILE* CreateAndOpenTemporaryFileInDir(const FilePath& dir, 287 BASE_EXPORT FILE* CreateAndOpenTemporaryFileInDir(const FilePath& dir,
285 FilePath* path); 288 FilePath* path);
286 289
287 // Create a new directory. If prefix is provided, the new directory name is in 290 // Create a new directory. If prefix is provided, the new directory name is in
288 // the format of prefixyyyy. 291 // the format of prefixyyyy.
289 // NOTE: prefix is ignored in the POSIX implementation. 292 // NOTE: prefix is ignored in the POSIX implementation.
290 // If success, return true and output the full path of the directory created. 293 // If success, return true and output the full path of the directory created.
291 BASE_EXPORT bool CreateNewTempDirectory(const FilePath::StringType& prefix, 294 BASE_EXPORT bool CreateNewTempDirectory(const FilePath::StringType& prefix,
292 FilePath* new_temp_path); 295 FilePath* new_temp_path);
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 BASE_EXPORT bool GetFileSystemType(const FilePath& path, FileSystemType* type); 631 BASE_EXPORT bool GetFileSystemType(const FilePath& path, FileSystemType* type);
629 #endif 632 #endif
630 633
631 } // namespace file_util 634 } // namespace file_util
632 635
633 // Deprecated functions have been moved to this separate header file, 636 // Deprecated functions have been moved to this separate header file,
634 // which must be included last after all the above definitions. 637 // which must be included last after all the above definitions.
635 #include "base/file_util_deprecated.h" 638 #include "base/file_util_deprecated.h"
636 639
637 #endif // BASE_FILE_UTIL_H_ 640 #endif // BASE_FILE_UTIL_H_
OLDNEW
« no previous file with comments | « no previous file | base/file_util_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698