diff options
Diffstat (limited to 'base')
-rw-r--r-- | base/base.gypi | 1 | ||||
-rw-r--r-- | base/file_util.h | 58 | ||||
-rw-r--r-- | base/file_util_deprecated.h | 59 |
3 files changed, 64 insertions, 54 deletions
diff --git a/base/base.gypi b/base/base.gypi index 66094b9d..dd03ad3 100644 --- a/base/base.gypi +++ b/base/base.gypi @@ -70,6 +70,7 @@ 'file_path.h', 'file_util.cc', 'file_util.h', + 'file_util_deprecated.h', 'file_util_linux.cc', 'file_util_mac.mm', 'file_util_posix.cc', diff --git a/base/file_util.h b/base/file_util.h index a145acc..1038444 100644 --- a/base/file_util.h +++ b/base/file_util.h @@ -44,34 +44,11 @@ namespace file_util { // Returns true if the given path ends with a path separator character. bool EndsWithSeparator(const FilePath& path); -// These two versions are both deprecated. TODO(estade): remove them. -bool EndsWithSeparator(std::wstring* path); -bool EndsWithSeparator(const std::wstring& 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. bool EnsureEndsWithSeparator(FilePath* path); -// Strips the topmost directory from the end of 'dir'. Assumes 'dir' does not -// refer to a file. -// If 'dir' is a root directory, return without change. -// Deprecated. Use FilePath::DirName instead. -void UpOneDirectory(std::wstring* dir); -// Strips the topmost directory from the end of 'dir'. Assumes 'dir' does not -// refer to a file. -// If 'dir' is a root directory, the result becomes empty string. -// Deprecated. Use FilePath::DirName instead. -void UpOneDirectoryOrEmpty(std::wstring* dir); - -// Returns the filename portion of 'path', without any leading \'s or /'s. -// Deprecated. Use FilePath::BaseName instead. -std::wstring GetFilenameFromPath(const std::wstring& path); - -// Deprecated compatibility function. Use FilePath::Extension. -FilePath::StringType GetFileExtensionFromPath(const FilePath& path); -// Deprecated temporary compatibility function. -std::wstring GetFileExtensionFromPath(const std::wstring& path); - // Returns the directory component of a path, without the trailing // path separator, or an empty string on error. The function does not // check for the existence of the path, so if it is passed a directory @@ -89,20 +66,11 @@ void AppendToPath(std::wstring* path, const std::wstring& new_ending); // Convert provided relative path into an absolute path. Returns false on // error. On POSIX, this function fails if the path does not exist. bool AbsolutePath(FilePath* path); -// Deprecated temporary compatibility function. -bool AbsolutePath(std::wstring* path); // Returns true if |parent| contains |child|. Both paths are converted to // absolute paths before doing the comparison. bool ContainsPath(const FilePath& parent, const FilePath& child); -// Deprecated compatibility function. Use FilePath::InsertBeforeExtension. -void InsertBeforeExtension(FilePath* path, const FilePath::StringType& suffix); - -// Deprecated compatibility function. Use FilePath::ReplaceExtension. -void ReplaceExtension(FilePath* file_name, - const FilePath::StringType& extension); - //----------------------------------------------------------------------------- // Functions that involve filesystem access or modification: @@ -125,8 +93,6 @@ int CountFilesCreatedAfter(const FilePath& path, // WARNING: USING THIS WITH recursive==true IS EQUIVALENT // TO "rm -rf", SO USE WITH CAUTION. bool Delete(const FilePath& path, bool recursive); -// Deprecated temporary compatibility function. -bool Delete(const std::wstring& path, bool recursive); #if defined(OS_WIN) // Schedules to delete the given path, whether it's a file or a directory, until @@ -162,9 +128,6 @@ bool CopyFile(const FilePath& from_path, const FilePath& to_path); // If you only need to copy a file use CopyFile, it's faster. bool CopyDirectory(const FilePath& from_path, const FilePath& to_path, bool recursive); -// Deprecated temporary compatibility function. -bool CopyDirectory(const std::wstring& from_path, const std::wstring& to_path, - bool recursive); // Returns true if the given path exists on the local filesystem, // false otherwise. @@ -200,8 +163,6 @@ bool TextContentsEqual(const FilePath& filename1, const FilePath& filename2); // Read the file at |path| into |contents|, returning true on success. // Useful for unit tests. bool ReadFileToString(const FilePath& path, std::string* contents); -// Deprecated version. -bool ReadFileToString(const std::wstring& path, std::string* contents); #if defined(OS_POSIX) // Read exactly |bytes| bytes from file descriptor |fd|, storing the result @@ -264,8 +225,6 @@ bool CopyAndDeleteDirectory(const FilePath& from_path, // Get the temporary directory provided by the system. bool GetTempDir(FilePath* path); -// Deprecated temporary compatibility function. -bool GetTempDir(std::wstring* path); // Get a temporary directory for shared memory files. // Only useful on POSIX; redirects to GetTempDir() on Windows. bool GetShmemTempDir(FilePath* path); @@ -304,8 +263,6 @@ bool CreateDirectory(const FilePath& full_path); // Returns the file size. Returns true on success. bool GetFileSize(const FilePath& file_path, int64* file_size); -// Deprecated temporary compatibility function. -bool GetFileSize(const std::wstring& file_path, int64* file_size); // Returns true if the given path's base name is ".". bool IsDot(const FilePath& path); @@ -329,8 +286,6 @@ struct FileInfo { // Returns information about the given file path. bool GetFileInfo(const FilePath& file_path, FileInfo* info); -// Deprecated temporary compatibility function. -bool GetFileInfo(const std::wstring& file_path, FileInfo* info); // Set the time of the last modification. Useful for unit tests. bool SetLastModifiedTime(const FilePath& file_path, base::Time last_modified); @@ -342,9 +297,6 @@ bool GetInode(const FilePath& path, ino_t* inode); // Wrapper for fopen-like calls. Returns non-NULL FILE* on success. FILE* OpenFile(const FilePath& filename, const char* mode); -// Deprecated temporary compatibility functions. -FILE* OpenFile(const std::string& filename, const char* mode); -FILE* OpenFile(const std::wstring& filename, const char* mode); // Closes file opened by OpenFile. Returns true on success. bool CloseFile(FILE* file); @@ -356,14 +308,10 @@ 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. int ReadFile(const FilePath& filename, char* data, int size); -// Deprecated temporary compatibility function. -int ReadFile(const std::wstring& 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. int WriteFile(const FilePath& filename, const char* data, int size); -// Deprecated temporary compatibility function. -int WriteFile(const std::wstring& filename, const char* data, int size); #if defined(OS_POSIX) // Append the data to |fd|. Does not close |fd| when done. int WriteFileDescriptor(const int fd, const char* data, int size); @@ -371,8 +319,6 @@ int WriteFileDescriptor(const int fd, const char* data, int size); // Gets the current working directory for the process. bool GetCurrentDirectory(FilePath* path); -// Deprecated temporary compatibility function. -bool GetCurrentDirectory(std::wstring* path); // Sets the current working directory for the process. bool SetCurrentDirectory(const FilePath& path); @@ -564,4 +510,8 @@ bool HasFileBeenModifiedSince(const FileEnumerator::FindInfo& find_info, } // namespace file_util +// Deprecated functions have been moved to this separate header file, +// which must be included last after all the above definitions. +#include "base/file_util_deprecated.h" + #endif // BASE_FILE_UTIL_H_ diff --git a/base/file_util_deprecated.h b/base/file_util_deprecated.h new file mode 100644 index 0000000..fd28ed2 --- /dev/null +++ b/base/file_util_deprecated.h @@ -0,0 +1,59 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// We're trying to transition away from paths as wstrings into using +// FilePath objects. This file contains declarations of deprecated +// functions. By hiding them here rather in the main header, we hope +// to discourage callers. + +// See file_util.h for documentation on all functions that don't have +// documentation here. + +#ifndef BASE_FILE_UTIL_DEPRECATED_H_ +#define BASE_FILE_UTIL_DEPRECATED_H_ + +#include "build/build_config.h" + +namespace file_util { + +bool EndsWithSeparator(std::wstring* path); +bool EndsWithSeparator(const std::wstring& path); + +// Use FilePath::DirName instead. +void UpOneDirectory(std::wstring* dir); +// Use FilePath::DirName instead. +void UpOneDirectoryOrEmpty(std::wstring* dir); + +// Use FilePath::BaseName instead. +std::wstring GetFilenameFromPath(const std::wstring& path); + +// Use FilePath::Extension instead. +FilePath::StringType GetFileExtensionFromPath(const FilePath& path); +std::wstring GetFileExtensionFromPath(const std::wstring& path); + +bool AbsolutePath(std::wstring* path); + +// Use FilePath::InsertBeforeExtension. +void InsertBeforeExtension(FilePath* path, const FilePath::StringType& suffix); + +// Use FilePath::ReplaceExtension. +void ReplaceExtension(FilePath* file_name, + const FilePath::StringType& extension); + +bool Delete(const std::wstring& path, bool recursive); +bool CopyDirectory(const std::wstring& from_path, const std::wstring& to_path, + bool recursive); +bool ReadFileToString(const std::wstring& path, std::string* contents); +bool GetTempDir(std::wstring* path); +bool GetFileSize(const std::wstring& file_path, int64* file_size); +bool GetFileInfo(const std::wstring& file_path, FileInfo* info); +FILE* OpenFile(const std::string& filename, const char* mode); +FILE* OpenFile(const std::wstring& filename, const char* mode); +int ReadFile(const std::wstring& filename, char* data, int size); +int WriteFile(const std::wstring& filename, const char* data, int size); +bool GetCurrentDirectory(std::wstring* path); + +} + +#endif // BASE_FILE_UTIL_DEPRECATED_H_ |