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

Unified Diff: base/file_util.h

Issue 7461141: Rename BASE_API to BASE_EXPORT. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/file_path.h ('k') | base/file_util_deprecated.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/file_util.h
===================================================================
--- base/file_util.h (revision 95578)
+++ base/file_util.h (working copy)
@@ -27,7 +27,7 @@
#include <string>
#include <vector>
-#include "base/base_api.h"
+#include "base/base_export.h"
#include "base/basictypes.h"
#include "base/file_path.h"
#include "base/memory/scoped_ptr.h"
@@ -50,19 +50,19 @@
// Functions that operate purely on a path string w/o touching the filesystem:
// Returns true if the given path ends with a path separator character.
-BASE_API bool EndsWithSeparator(const FilePath& path);
+BASE_EXPORT bool EndsWithSeparator(const FilePath& path);
// Makes sure that |path| ends with a separator IFF path is a directory that
// exists. Returns true if |path| is an existing directory, false otherwise.
-BASE_API bool EnsureEndsWithSeparator(FilePath* path);
+BASE_EXPORT bool EnsureEndsWithSeparator(FilePath* path);
// Convert provided relative path into an absolute path. Returns false on
// error. On POSIX, this function fails if the path does not exist.
-BASE_API bool AbsolutePath(FilePath* path);
+BASE_EXPORT bool AbsolutePath(FilePath* path);
// Returns true if |parent| contains |child|. Both paths are converted to
// absolute paths before doing the comparison.
-BASE_API bool ContainsPath(const FilePath& parent, const FilePath& child);
+BASE_EXPORT bool ContainsPath(const FilePath& parent, const FilePath& child);
//-----------------------------------------------------------------------------
// Functions that involve filesystem access or modification:
@@ -75,15 +75,15 @@
// timestmap of file creation time. If you need to avoid such
// mis-detection perfectly, you should wait one second before
// obtaining |file_time|.
-BASE_API int CountFilesCreatedAfter(const FilePath& path,
- const base::Time& file_time);
+BASE_EXPORT int CountFilesCreatedAfter(const FilePath& path,
+ const base::Time& file_time);
// Returns the total number of bytes used by all the files under |root_path|.
// If the path does not exist the function returns 0.
//
// This function is implemented using the FileEnumerator class so it is not
// particularly speedy in any platform.
-BASE_API int64 ComputeDirectorySize(const FilePath& root_path);
+BASE_EXPORT int64 ComputeDirectorySize(const FilePath& root_path);
// Returns the total number of bytes used by all files matching the provided
// |pattern|, on this |directory| (without recursion). If the path does not
@@ -91,8 +91,8 @@
//
// This function is implemented using the FileEnumerator class so it is not
// particularly speedy in any platform.
-BASE_API int64 ComputeFilesSize(const FilePath& directory,
- const FilePath::StringType& pattern);
+BASE_EXPORT int64 ComputeFilesSize(const FilePath& directory,
+ const FilePath::StringType& pattern);
// Deletes the given path, whether it's a file or a directory.
// If it's a directory, it's perfectly happy to delete all of the
@@ -102,7 +102,7 @@
//
// WARNING: USING THIS WITH recursive==true IS EQUIVALENT
// TO "rm -rf", SO USE WITH CAUTION.
-BASE_API bool Delete(const FilePath& path, bool recursive);
+BASE_EXPORT bool Delete(const FilePath& path, bool recursive);
#if defined(OS_WIN)
// Schedules to delete the given path, whether it's a file or a directory, until
@@ -110,24 +110,25 @@
// Note:
// 1) The file/directory to be deleted should exist in a temp folder.
// 2) The directory to be deleted must be empty.
-BASE_API bool DeleteAfterReboot(const FilePath& path);
+BASE_EXPORT bool DeleteAfterReboot(const FilePath& path);
#endif
// Moves the given path, whether it's a file or a directory.
// If a simple rename is not possible, such as in the case where the paths are
// on different volumes, this will attempt to copy and delete. Returns
// true for success.
-BASE_API bool Move(const FilePath& from_path, const FilePath& to_path);
+BASE_EXPORT bool Move(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
// temporary files. On Windows it preserves attributes of the target file.
// Returns true on success.
-BASE_API bool ReplaceFile(const FilePath& from_path, const FilePath& to_path);
+BASE_EXPORT bool ReplaceFile(const FilePath& from_path,
+ const FilePath& to_path);
// Copies a single file. Use CopyDirectory to copy directories.
-BASE_API bool CopyFile(const FilePath& from_path, const 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.
@@ -136,61 +137,62 @@
// Don't use wildcards on the names, it may stop working without notice.
//
// If you only need to copy a file use CopyFile, it's faster.
-BASE_API bool CopyDirectory(const FilePath& from_path, const FilePath& to_path,
- bool recursive);
+BASE_EXPORT bool CopyDirectory(const FilePath& from_path,
+ const FilePath& to_path,
+ bool recursive);
// Returns true if the given path exists on the local filesystem,
// false otherwise.
-BASE_API bool PathExists(const FilePath& path);
+BASE_EXPORT bool PathExists(const FilePath& path);
// Returns true if the given path is writable by the user, false otherwise.
-BASE_API bool PathIsWritable(const FilePath& path);
+BASE_EXPORT bool PathIsWritable(const FilePath& path);
// Returns true if the given path exists and is a directory, false otherwise.
-BASE_API bool DirectoryExists(const FilePath& path);
+BASE_EXPORT bool DirectoryExists(const FilePath& path);
#if defined(OS_WIN)
// Gets the creation time of the given file (expressed in the local timezone),
// and returns it via the creation_time parameter. Returns true if successful,
// false otherwise.
-BASE_API bool GetFileCreationLocalTime(const std::wstring& filename,
- LPSYSTEMTIME creation_time);
+BASE_EXPORT bool GetFileCreationLocalTime(const std::wstring& filename,
+ LPSYSTEMTIME creation_time);
// Same as above, but takes a previously-opened file handle instead of a name.
-BASE_API bool GetFileCreationLocalTimeFromHandle(HANDLE file_handle,
- LPSYSTEMTIME creation_time);
+BASE_EXPORT bool GetFileCreationLocalTimeFromHandle(HANDLE file_handle,
+ LPSYSTEMTIME creation_time);
#endif // defined(OS_WIN)
// Returns true if the contents of the two files given are equal, false
// otherwise. If either file can't be read, returns false.
-BASE_API bool ContentsEqual(const FilePath& filename1,
- const FilePath& filename2);
+BASE_EXPORT bool ContentsEqual(const FilePath& filename1,
+ const FilePath& filename2);
// Returns true if the contents of the two text files given are equal, false
// otherwise. This routine treats "\r\n" and "\n" as equivalent.
-BASE_API bool TextContentsEqual(const FilePath& filename1,
- const FilePath& filename2);
+BASE_EXPORT bool TextContentsEqual(const FilePath& filename1,
+ const FilePath& filename2);
// Read the file at |path| into |contents|, returning true on success.
// |contents| may be NULL, in which case this function is useful for its
// side effect of priming the disk cache.
// Useful for unit tests.
-BASE_API bool ReadFileToString(const FilePath& path, std::string* contents);
+BASE_EXPORT bool ReadFileToString(const FilePath& path, std::string* contents);
#if defined(OS_POSIX)
// Read exactly |bytes| bytes from file descriptor |fd|, storing the result
// in |buffer|. This function is protected against EINTR and partial reads.
// Returns true iff |bytes| bytes have been successfuly read from |fd|.
-BASE_API bool ReadFromFD(int fd, char* buffer, size_t bytes);
+BASE_EXPORT bool ReadFromFD(int fd, char* buffer, size_t bytes);
// Creates a symbolic link at |symlink| pointing to |target|. Returns
// false on failure.
-BASE_API bool CreateSymbolicLink(const FilePath& target,
- const FilePath& symlink);
+BASE_EXPORT bool CreateSymbolicLink(const FilePath& target,
+ const FilePath& symlink);
// Reads the given |symlink| and returns where it points to in |target|.
// Returns false upon failure.
-BASE_API bool ReadSymbolicLink(const FilePath& symlink, FilePath* target);
+BASE_EXPORT bool ReadSymbolicLink(const FilePath& symlink, FilePath* target);
#endif // defined(OS_POSIX)
#if defined(OS_WIN)
@@ -198,7 +200,7 @@
// This methods tries to resolve a shortcut .LNK file. If the |path| is valid
// returns true and puts the target into the |path|, otherwise returns
// false leaving the path as it is.
-BASE_API bool ResolveShortcut(FilePath* path);
+BASE_EXPORT bool ResolveShortcut(FilePath* path);
// Create a Windows shortcut (.LNK file)
// This method creates a shortcut link using the information given. Ensure
@@ -209,14 +211,14 @@
// The 'icon' can specify a dll or exe in which case the icon index is the
// resource id. 'app_id' is the app model id for the shortcut on Win7.
// Note that if the shortcut exists it will overwrite it.
-BASE_API bool CreateShortcutLink(const wchar_t *source,
- const wchar_t *destination,
- const wchar_t *working_dir,
- const wchar_t *arguments,
- const wchar_t *description,
- const wchar_t *icon,
- int icon_index,
- const wchar_t* app_id);
+BASE_EXPORT bool CreateShortcutLink(const wchar_t *source,
+ const wchar_t *destination,
+ const wchar_t *working_dir,
+ const wchar_t *arguments,
+ const wchar_t *description,
+ const wchar_t *icon,
+ int icon_index,
+ const wchar_t* app_id);
// Update a Windows shortcut (.LNK file). This method assumes the shortcut
// link already exists (otherwise false is returned). Ensure you have
@@ -225,92 +227,92 @@
// is NULL no changes are made to the shortcut). 'destination' is the link
// file to be updated. 'app_id' is the app model id for the shortcut on Win7.
// For best results pass the filename with the .lnk extension.
-BASE_API bool UpdateShortcutLink(const wchar_t *source,
- const wchar_t *destination,
- const wchar_t *working_dir,
- const wchar_t *arguments,
- const wchar_t *description,
- const wchar_t *icon,
- int icon_index,
- const wchar_t* app_id);
+BASE_EXPORT bool UpdateShortcutLink(const wchar_t *source,
+ const wchar_t *destination,
+ const wchar_t *working_dir,
+ const wchar_t *arguments,
+ const wchar_t *description,
+ const wchar_t *icon,
+ int icon_index,
+ const wchar_t* app_id);
// Pins a shortcut to the Windows 7 taskbar. The shortcut file must already
// exist and be a shortcut that points to an executable.
-BASE_API bool TaskbarPinShortcutLink(const wchar_t* shortcut);
+BASE_EXPORT bool TaskbarPinShortcutLink(const wchar_t* shortcut);
// Unpins a shortcut from the Windows 7 taskbar. The shortcut must exist and
// already be pinned to the taskbar.
-BASE_API bool TaskbarUnpinShortcutLink(const wchar_t* shortcut);
+BASE_EXPORT bool TaskbarUnpinShortcutLink(const wchar_t* shortcut);
// 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_API bool CopyAndDeleteDirectory(const FilePath& from_path,
- const FilePath& to_path);
+BASE_EXPORT bool CopyAndDeleteDirectory(const FilePath& from_path,
+ const FilePath& to_path);
#endif // defined(OS_WIN)
// Return true if the given directory is empty
-BASE_API bool IsDirectoryEmpty(const FilePath& dir_path);
+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_API bool GetTempDir(FilePath* path);
+BASE_EXPORT bool GetTempDir(FilePath* path);
// Get a temporary directory for shared memory files.
// Only useful on POSIX; redirects to GetTempDir() on Windows.
-BASE_API bool GetShmemTempDir(FilePath* path);
+BASE_EXPORT bool GetShmemTempDir(FilePath* path);
// Get the home directory. This is more complicated than just getenv("HOME")
// as it knows to fall back on getpwent() etc.
-BASE_API FilePath GetHomeDir();
+BASE_EXPORT FilePath GetHomeDir();
// 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
// be empty and all handles closed after this function returns.
-BASE_API bool CreateTemporaryFile(FilePath* path);
+BASE_EXPORT bool CreateTemporaryFile(FilePath* path);
// Same as CreateTemporaryFile but the file is created in |dir|.
-BASE_API bool CreateTemporaryFileInDir(const FilePath& dir,
- FilePath* temp_file);
+BASE_EXPORT bool CreateTemporaryFileInDir(const FilePath& dir,
+ FilePath* temp_file);
// Create and open a temporary file. File is opened for read/write.
// The full path is placed in |path|.
// Returns a handle to the opened file or NULL if an error occured.
-BASE_API FILE* CreateAndOpenTemporaryFile(FilePath* path);
+BASE_EXPORT FILE* CreateAndOpenTemporaryFile(FilePath* path);
// Like above but for shmem files. Only useful for POSIX.
-BASE_API FILE* CreateAndOpenTemporaryShmemFile(FilePath* path);
+BASE_EXPORT FILE* CreateAndOpenTemporaryShmemFile(FilePath* path);
// Similar to CreateAndOpenTemporaryFile, but the file is created in |dir|.
-BASE_API FILE* CreateAndOpenTemporaryFileInDir(const FilePath& dir,
- FilePath* path);
+BASE_EXPORT FILE* CreateAndOpenTemporaryFileInDir(const FilePath& dir,
+ FilePath* path);
// Create a new directory. If prefix is provided, the new directory name is in
// the format of prefixyyyy.
// NOTE: prefix is ignored in the POSIX implementation.
// If success, return true and output the full path of the directory created.
-BASE_API bool CreateNewTempDirectory(const FilePath::StringType& prefix,
- FilePath* new_temp_path);
+BASE_EXPORT bool CreateNewTempDirectory(const FilePath::StringType& prefix,
+ FilePath* new_temp_path);
// Create a directory within another directory.
// Extra characters will be appended to |prefix| to ensure that the
// new directory does not have the same name as an existing directory.
-BASE_API bool CreateTemporaryDirInDir(const FilePath& base_dir,
- const FilePath::StringType& prefix,
- FilePath* new_dir);
+BASE_EXPORT bool CreateTemporaryDirInDir(const FilePath& base_dir,
+ const FilePath::StringType& prefix,
+ FilePath* new_dir);
// Creates a directory, as well as creating any parent directories, if they
// don't exist. Returns 'true' on successful creation, or if the directory
// already exists. The directory is only readable by the current user.
-BASE_API bool CreateDirectory(const FilePath& full_path);
+BASE_EXPORT bool CreateDirectory(const FilePath& full_path);
// Returns the file size. Returns true on success.
-BASE_API bool GetFileSize(const FilePath& file_path, int64* file_size);
+BASE_EXPORT bool GetFileSize(const FilePath& file_path, int64* file_size);
// Returns true if the given path's base name is ".".
-BASE_API bool IsDot(const FilePath& path);
+BASE_EXPORT bool IsDot(const FilePath& path);
// Returns true if the given path's base name is "..".
-BASE_API bool IsDotDot(const FilePath& path);
+BASE_EXPORT bool IsDotDot(const FilePath& path);
// Sets |real_path| to |path| with symbolic links and junctions expanded.
// On windows, make sure the path starts with a lettered drive.
@@ -318,65 +320,65 @@
// a directory or to a nonexistent path. On windows, this function will
// fail if |path| is a junction or symlink that points to an empty file,
// or if |real_path| would be longer than MAX_PATH characters.
-BASE_API bool NormalizeFilePath(const FilePath& path, FilePath* real_path);
+BASE_EXPORT bool NormalizeFilePath(const FilePath& path, FilePath* real_path);
#if defined(OS_WIN)
// Given an existing file in |path|, it returns in |real_path| the path
// in the native NT format, of the form "\Device\HarddiskVolumeXX\..".
// Returns false it it fails. Empty files cannot be resolved with this
// function.
-BASE_API bool NormalizeToNativeFilePath(const FilePath& path,
- FilePath* nt_path);
+BASE_EXPORT bool NormalizeToNativeFilePath(const FilePath& path,
+ FilePath* nt_path);
#endif
// This function will return if the given file is a symlink or not.
-BASE_API bool IsLink(const FilePath& file_path);
+BASE_EXPORT bool IsLink(const FilePath& file_path);
// Returns information about the given file path.
-BASE_API bool GetFileInfo(const FilePath& file_path,
- base::PlatformFileInfo* info);
+BASE_EXPORT bool GetFileInfo(const FilePath& file_path,
+ base::PlatformFileInfo* info);
// Sets the time of the last access and the time of the last modification.
-BASE_API bool TouchFile(const FilePath& path,
- const base::Time& last_accessed,
- const base::Time& last_modified);
+BASE_EXPORT bool TouchFile(const FilePath& path,
+ const base::Time& last_accessed,
+ const base::Time& last_modified);
// Set the time of the last modification. Useful for unit tests.
-BASE_API bool SetLastModifiedTime(const FilePath& path,
- const base::Time& last_modified);
+BASE_EXPORT bool SetLastModifiedTime(const FilePath& path,
+ const base::Time& last_modified);
#if defined(OS_POSIX)
// Store inode number of |path| in |inode|. Return true on success.
-BASE_API bool GetInode(const FilePath& path, ino_t* inode);
+BASE_EXPORT bool GetInode(const FilePath& path, ino_t* inode);
#endif
// Wrapper for fopen-like calls. Returns non-NULL FILE* on success.
-BASE_API FILE* OpenFile(const FilePath& filename, const char* mode);
+BASE_EXPORT FILE* OpenFile(const FilePath& filename, const char* mode);
// Closes file opened by OpenFile. Returns true on success.
-BASE_API bool CloseFile(FILE* file);
+BASE_EXPORT bool CloseFile(FILE* file);
// Truncates an open file to end at the location of the current file pointer.
// This is a cross-platform analog to Windows' SetEndOfFile() function.
-BASE_API bool TruncateFile(FILE* file);
+BASE_EXPORT bool TruncateFile(FILE* file);
// Reads the given number of bytes from the file into the buffer. Returns
// the number of read bytes, or -1 on error.
-BASE_API int ReadFile(const FilePath& filename, char* data, int size);
+BASE_EXPORT int ReadFile(const FilePath& filename, char* data, int size);
// Writes the given buffer into the file, overwriting any data that was
// previously there. Returns the number of bytes written, or -1 on error.
-BASE_API int WriteFile(const FilePath& filename, const char* data, int size);
+BASE_EXPORT int WriteFile(const FilePath& filename, const char* data, int size);
#if defined(OS_POSIX)
// Append the data to |fd|. Does not close |fd| when done.
-BASE_API int WriteFileDescriptor(const int fd, const char* data, int size);
+BASE_EXPORT int WriteFileDescriptor(const int fd, const char* data, int size);
#endif
// Gets the current working directory for the process.
-BASE_API bool GetCurrentDirectory(FilePath* path);
+BASE_EXPORT bool GetCurrentDirectory(FilePath* path);
// Sets the current working directory for the process.
-BASE_API bool SetCurrentDirectory(const FilePath& path);
+BASE_EXPORT bool SetCurrentDirectory(const FilePath& path);
// A class to handle auto-closing of FILE*'s.
class ScopedFILEClose {
@@ -410,7 +412,7 @@
//
// DO NOT USE FROM THE MAIN THREAD of your application unless it is a test
// program where latency does not matter. This class is blocking.
-class BASE_API FileEnumerator {
+class BASE_EXPORT FileEnumerator {
public:
#if defined(OS_WIN)
typedef WIN32_FIND_DATA FindInfo;
@@ -511,7 +513,7 @@
DISALLOW_COPY_AND_ASSIGN(FileEnumerator);
};
-class BASE_API MemoryMappedFile {
+class BASE_EXPORT MemoryMappedFile {
public:
// The default constructor sets all members to invalid/null values.
MemoryMappedFile();
@@ -566,12 +568,12 @@
// Renames a file using the SHFileOperation API to ensure that the target file
// gets the correct default security descriptor in the new path.
-BASE_API bool RenameFileAndResetSecurityDescriptor(
+BASE_EXPORT bool RenameFileAndResetSecurityDescriptor(
const FilePath& source_file_path,
const FilePath& target_file_path);
// Returns whether the file has been modified since a particular date.
-BASE_API bool HasFileBeenModifiedSince(
+BASE_EXPORT bool HasFileBeenModifiedSince(
const FileEnumerator::FindInfo& find_info,
const base::Time& cutoff_time);
@@ -633,8 +635,8 @@
// is passed in. If it is 0 then the whole file is paged in. The step size
// which indicates the number of bytes to skip after every page touched is
// also passed in.
-bool BASE_API PreReadImage(const wchar_t* file_path, size_t size_to_read,
- size_t step_size);
+bool BASE_EXPORT PreReadImage(const wchar_t* file_path, size_t size_to_read,
+ size_t step_size);
#endif // OS_WIN
#if defined(OS_LINUX)
@@ -654,7 +656,7 @@
// Attempts determine the FileSystemType for |path|.
// Returns false if |path| doesn't exist.
-BASE_API bool GetFileSystemType(const FilePath& path, FileSystemType* type);
+BASE_EXPORT bool GetFileSystemType(const FilePath& path, FileSystemType* type);
#endif
} // namespace file_util
« no previous file with comments | « base/file_path.h ('k') | base/file_util_deprecated.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698