diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-24 05:40:52 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-24 05:40:52 +0000 |
commit | 57999817d30c384de8974a2c64c0356e71fde63c (patch) | |
tree | eea7cbd7cd2a1226d4d7e0b983d01268334dc2ba /base | |
parent | 8701de1793a2c3fdf0f596aee8ec93c61c00bf2e (diff) | |
download | chromium_src-57999817d30c384de8974a2c64c0356e71fde63c.zip chromium_src-57999817d30c384de8974a2c64c0356e71fde63c.tar.gz chromium_src-57999817d30c384de8974a2c64c0356e71fde63c.tar.bz2 |
Move file_path.h to base/files.
TBR=sky
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@184344 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
81 files changed, 531 insertions, 525 deletions
diff --git a/base/android/path_service_android.cc b/base/android/path_service_android.cc index a9bf92d..18ca70c 100644 --- a/base/android/path_service_android.cc +++ b/base/android/path_service_android.cc @@ -4,10 +4,10 @@ #include "base/android/path_service_android.h" -#include "base/file_path.h" -#include "base/path_service.h" #include "base/android/jni_android.h" #include "base/android/jni_string.h" +#include "base/files/file_path.h" +#include "base/path_service.h" #include "jni/PathService_jni.h" namespace base { diff --git a/base/android/path_utils.cc b/base/android/path_utils.cc index 3d86177..5737227 100644 --- a/base/android/path_utils.cc +++ b/base/android/path_utils.cc @@ -7,7 +7,7 @@ #include "base/android/jni_android.h" #include "base/android/jni_string.h" #include "base/android/scoped_java_ref.h" -#include "base/file_path.h" +#include "base/files/file_path.h" #include "jni/PathUtils_jni.h" diff --git a/base/android/path_utils_unittest.cc b/base/android/path_utils_unittest.cc index 636e3fa..52b1928 100644 --- a/base/android/path_utils_unittest.cc +++ b/base/android/path_utils_unittest.cc @@ -3,8 +3,8 @@ // found in the LICENSE file. #include "base/android/path_utils.h" -#include "base/file_path.h" #include "base/file_util.h" +#include "base/files/file_path.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/base/base.gyp b/base/base.gyp index 7c63ec2..93f9d28 100644 --- a/base/base.gyp +++ b/base/base.gyp @@ -450,10 +450,10 @@ 'debug/trace_event_unittest.h', 'debug/trace_event_win_unittest.cc', 'environment_unittest.cc', - 'file_path_unittest.cc', 'file_util_unittest.cc', 'file_version_info_unittest.cc', 'files/dir_reader_posix_unittest.cc', + 'files/file_path_unittest.cc', 'files/file_util_proxy_unittest.cc', 'files/important_file_writer_unittest.cc', 'files/scoped_temp_dir_unittest.cc', diff --git a/base/base.gypi b/base/base.gypi index 7cad42a..35776f7 100644 --- a/base/base.gypi +++ b/base/base.gypi @@ -141,8 +141,6 @@ 'environment.cc', 'environment.h', 'file_descriptor_posix.h', - 'file_path.cc', - 'file_path.h', 'file_util.cc', 'file_util.h', 'file_util_android.cc', @@ -158,6 +156,8 @@ 'files/dir_reader_fallback.h', 'files/dir_reader_linux.h', 'files/dir_reader_posix.h', + 'files/file_path.cc', + 'files/file_path.h', 'files/file_path_watcher.cc', 'files/file_path_watcher.h', 'files/file_path_watcher_kqueue.cc', diff --git a/base/base_paths.cc b/base/base_paths.cc index 80105b6..05a55af 100644 --- a/base/base_paths.cc +++ b/base/base_paths.cc @@ -4,8 +4,8 @@ #include "base/base_paths.h" -#include "base/file_path.h" #include "base/file_util.h" +#include "base/files/file_path.h" #include "base/path_service.h" namespace base { diff --git a/base/base_paths_android.cc b/base/base_paths_android.cc index 9905200..edbe7cd 100644 --- a/base/base_paths_android.cc +++ b/base/base_paths_android.cc @@ -10,8 +10,8 @@ #include "base/android/jni_android.h" #include "base/android/path_utils.h" #include "base/base_paths.h" -#include "base/file_path.h" #include "base/file_util.h" +#include "base/files/file_path.h" #include "base/logging.h" #include "base/process_util.h" diff --git a/base/base_paths_mac.mm b/base/base_paths_mac.mm index 39a5814..8db5647 100644 --- a/base/base_paths_mac.mm +++ b/base/base_paths_mac.mm @@ -11,8 +11,8 @@ #include "base/base_paths.h" #include "base/compiler_specific.h" -#include "base/file_path.h" #include "base/file_util.h" +#include "base/files/file_path.h" #include "base/logging.h" #include "base/mac/foundation_util.h" #include "base/path_service.h" diff --git a/base/base_paths_posix.cc b/base/base_paths_posix.cc index 834dee3..59be094 100644 --- a/base/base_paths_posix.cc +++ b/base/base_paths_posix.cc @@ -11,13 +11,13 @@ #include "base/base_paths.h" #include "base/environment.h" -#include "base/file_path.h" #include "base/file_util.h" +#include "base/files/file_path.h" #include "base/logging.h" #include "base/memory/scoped_ptr.h" +#include "base/nix/xdg_util.h" #include "base/path_service.h" #include "base/process_util.h" -#include "base/nix/xdg_util.h" #include "build/build_config.h" #if defined(OS_FREEBSD) diff --git a/base/base_paths_win.cc b/base/base_paths_win.cc index bd4c791..f4dd434 100644 --- a/base/base_paths_win.cc +++ b/base/base_paths_win.cc @@ -7,8 +7,8 @@ #include <shlobj.h> #include "base/base_paths.h" -#include "base/file_path.h" #include "base/file_util.h" +#include "base/files/file_path.h" #include "base/path_service.h" #include "base/win/scoped_co_mem.h" #include "base/win/windows_version.h" diff --git a/base/command_line.cc b/base/command_line.cc index 1c73846..9aa68be 100644 --- a/base/command_line.cc +++ b/base/command_line.cc @@ -8,7 +8,7 @@ #include <ostream> #include "base/basictypes.h" -#include "base/file_path.h" +#include "base/files/file_path.h" #include "base/logging.h" #include "base/string_util.h" #include "base/strings/string_split.h" diff --git a/base/command_line_unittest.cc b/base/command_line_unittest.cc index 62080d1..ca7c9fb 100644 --- a/base/command_line_unittest.cc +++ b/base/command_line_unittest.cc @@ -7,7 +7,7 @@ #include "base/basictypes.h" #include "base/command_line.h" -#include "base/file_path.h" +#include "base/files/file_path.h" #include "base/utf_string_conversions.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/base/file_path.h b/base/file_path.h index c9a9bc9..c41ddd2 100644 --- a/base/file_path.h +++ b/base/file_path.h @@ -2,441 +2,5 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// FilePath is a container for pathnames stored in a platform's native string -// type, providing containers for manipulation in according with the -// platform's conventions for pathnames. It supports the following path -// types: -// -// POSIX Windows -// --------------- ---------------------------------- -// Fundamental type char[] wchar_t[] -// Encoding unspecified* UTF-16 -// Separator / \, tolerant of / -// Drive letters no case-insensitive A-Z followed by : -// Alternate root // (surprise!) \\, for UNC paths -// -// * The encoding need not be specified on POSIX systems, although some -// POSIX-compliant systems do specify an encoding. Mac OS X uses UTF-8. -// Chrome OS also uses UTF-8. -// Linux does not specify an encoding, but in practice, the locale's -// character set may be used. -// -// For more arcane bits of path trivia, see below. -// -// FilePath objects are intended to be used anywhere paths are. An -// application may pass FilePath objects around internally, masking the -// underlying differences between systems, only differing in implementation -// where interfacing directly with the system. For example, a single -// OpenFile(const FilePath &) function may be made available, allowing all -// callers to operate without regard to the underlying implementation. On -// POSIX-like platforms, OpenFile might wrap fopen, and on Windows, it might -// wrap _wfopen_s, perhaps both by calling file_path.value().c_str(). This -// allows each platform to pass pathnames around without requiring conversions -// between encodings, which has an impact on performance, but more imporantly, -// has an impact on correctness on platforms that do not have well-defined -// encodings for pathnames. -// -// Several methods are available to perform common operations on a FilePath -// object, such as determining the parent directory (DirName), isolating the -// final path component (BaseName), and appending a relative pathname string -// to an existing FilePath object (Append). These methods are highly -// recommended over attempting to split and concatenate strings directly. -// These methods are based purely on string manipulation and knowledge of -// platform-specific pathname conventions, and do not consult the filesystem -// at all, making them safe to use without fear of blocking on I/O operations. -// These methods do not function as mutators but instead return distinct -// instances of FilePath objects, and are therefore safe to use on const -// objects. The objects themselves are safe to share between threads. -// -// To aid in initialization of FilePath objects from string literals, a -// FILE_PATH_LITERAL macro is provided, which accounts for the difference -// between char[]-based pathnames on POSIX systems and wchar_t[]-based -// pathnames on Windows. -// -// Paths can't contain NULs as a precaution agaist premature truncation. -// -// Because a FilePath object should not be instantiated at the global scope, -// instead, use a FilePath::CharType[] and initialize it with -// FILE_PATH_LITERAL. At runtime, a FilePath object can be created from the -// character array. Example: -// -// | const FilePath::CharType kLogFileName[] = FILE_PATH_LITERAL("log.txt"); -// | -// | void Function() { -// | FilePath log_file_path(kLogFileName); -// | [...] -// | } -// -// WARNING: FilePaths should ALWAYS be displayed with LTR directionality, even -// when the UI language is RTL. This means you always need to pass filepaths -// through base::i18n::WrapPathWithLTRFormatting() before displaying it in the -// RTL UI. -// -// This is a very common source of bugs, please try to keep this in mind. -// -// ARCANE BITS OF PATH TRIVIA -// -// - A double leading slash is actually part of the POSIX standard. Systems -// are allowed to treat // as an alternate root, as Windows does for UNC -// (network share) paths. Most POSIX systems don't do anything special -// with two leading slashes, but FilePath handles this case properly -// in case it ever comes across such a system. FilePath needs this support -// for Windows UNC paths, anyway. -// References: -// The Open Group Base Specifications Issue 7, sections 3.266 ("Pathname") -// and 4.12 ("Pathname Resolution"), available at: -// http://www.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_266 -// http://www.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_12 -// -// - Windows treats c:\\ the same way it treats \\. This was intended to -// allow older applications that require drive letters to support UNC paths -// like \\server\share\path, by permitting c:\\server\share\path as an -// equivalent. Since the OS treats these paths specially, FilePath needs -// to do the same. Since Windows can use either / or \ as the separator, -// FilePath treats c://, c:\\, //, and \\ all equivalently. -// Reference: -// The Old New Thing, "Why is a drive letter permitted in front of UNC -// paths (sometimes)?", available at: -// http://blogs.msdn.com/oldnewthing/archive/2005/11/22/495740.aspx - -#ifndef BASE_FILE_PATH_H_ -#define BASE_FILE_PATH_H_ - -#include <stddef.h> -#include <string> -#include <vector> - -#include "base/base_export.h" -#include "base/compiler_specific.h" -#include "base/hash_tables.h" -#include "base/string16.h" -#include "base/string_piece.h" // For implicit conversions. -#include "build/build_config.h" - -// Windows-style drive letter support and pathname separator characters can be -// enabled and disabled independently, to aid testing. These #defines are -// here so that the same setting can be used in both the implementation and -// in the unit test. -#if defined(OS_WIN) -#define FILE_PATH_USES_DRIVE_LETTERS -#define FILE_PATH_USES_WIN_SEPARATORS -#endif // OS_WIN - -class Pickle; -class PickleIterator; - -namespace base { - -// An abstraction to isolate users from the differences between native -// pathnames on different platforms. -class BASE_EXPORT FilePath { - public: -#if defined(OS_POSIX) - // On most platforms, native pathnames are char arrays, and the encoding - // may or may not be specified. On Mac OS X, native pathnames are encoded - // in UTF-8. - typedef std::string StringType; -#elif defined(OS_WIN) - // On Windows, for Unicode-aware applications, native pathnames are wchar_t - // arrays encoded in UTF-16. - typedef std::wstring StringType; -#endif // OS_WIN - - typedef StringType::value_type CharType; - - // Null-terminated array of separators used to separate components in - // hierarchical paths. Each character in this array is a valid separator, - // but kSeparators[0] is treated as the canonical separator and will be used - // when composing pathnames. - static const CharType kSeparators[]; - - // A special path component meaning "this directory." - static const CharType kCurrentDirectory[]; - - // A special path component meaning "the parent directory." - static const CharType kParentDirectory[]; - - // The character used to identify a file extension. - static const CharType kExtensionSeparator; - - FilePath(); - FilePath(const FilePath& that); - explicit FilePath(const StringType& path); - ~FilePath(); - FilePath& operator=(const FilePath& that); - - bool operator==(const FilePath& that) const; - - bool operator!=(const FilePath& that) const; - - // Required for some STL containers and operations - bool operator<(const FilePath& that) const { - return path_ < that.path_; - } - - const StringType& value() const { return path_; } - - bool empty() const { return path_.empty(); } - - void clear() { path_.clear(); } - - // Returns true if |character| is in kSeparators. - static bool IsSeparator(CharType character); - - // Returns a vector of all of the components of the provided path. It is - // equivalent to calling DirName().value() on the path's root component, - // and BaseName().value() on each child component. - void GetComponents(std::vector<FilePath::StringType>* components) const; - - // Returns true if this FilePath is a strict parent of the |child|. Absolute - // and relative paths are accepted i.e. is /foo parent to /foo/bar and - // is foo parent to foo/bar. Does not convert paths to absolute, follow - // symlinks or directory navigation (e.g. ".."). A path is *NOT* its own - // parent. - bool IsParent(const FilePath& child) const; - - // If IsParent(child) holds, appends to path (if non-NULL) the - // relative path to child and returns true. For example, if parent - // holds "/Users/johndoe/Library/Application Support", child holds - // "/Users/johndoe/Library/Application Support/Google/Chrome/Default", and - // *path holds "/Users/johndoe/Library/Caches", then after - // parent.AppendRelativePath(child, path) is called *path will hold - // "/Users/johndoe/Library/Caches/Google/Chrome/Default". Otherwise, - // returns false. - bool AppendRelativePath(const FilePath& child, FilePath* path) const; - - // Returns a FilePath corresponding to the directory containing the path - // named by this object, stripping away the file component. If this object - // only contains one component, returns a FilePath identifying - // kCurrentDirectory. If this object already refers to the root directory, - // returns a FilePath identifying the root directory. - FilePath DirName() const WARN_UNUSED_RESULT; - - // Returns a FilePath corresponding to the last path component of this - // object, either a file or a directory. If this object already refers to - // the root directory, returns a FilePath identifying the root directory; - // this is the only situation in which BaseName will return an absolute path. - FilePath BaseName() const WARN_UNUSED_RESULT; - - // Returns ".jpg" for path "C:\pics\jojo.jpg", or an empty string if - // the file has no extension. If non-empty, Extension() will always start - // with precisely one ".". The following code should always work regardless - // of the value of path. - // new_path = path.RemoveExtension().value().append(path.Extension()); - // ASSERT(new_path == path.value()); - // NOTE: this is different from the original file_util implementation which - // returned the extension without a leading "." ("jpg" instead of ".jpg") - StringType Extension() const; - - // Returns "C:\pics\jojo" for path "C:\pics\jojo.jpg" - // NOTE: this is slightly different from the similar file_util implementation - // which returned simply 'jojo'. - FilePath RemoveExtension() const WARN_UNUSED_RESULT; - - // Inserts |suffix| after the file name portion of |path| but before the - // extension. Returns "" if BaseName() == "." or "..". - // Examples: - // path == "C:\pics\jojo.jpg" suffix == " (1)", returns "C:\pics\jojo (1).jpg" - // path == "jojo.jpg" suffix == " (1)", returns "jojo (1).jpg" - // path == "C:\pics\jojo" suffix == " (1)", returns "C:\pics\jojo (1)" - // path == "C:\pics.old\jojo" suffix == " (1)", returns "C:\pics.old\jojo (1)" - FilePath InsertBeforeExtension( - const StringType& suffix) const WARN_UNUSED_RESULT; - FilePath InsertBeforeExtensionASCII( - const base::StringPiece& suffix) const WARN_UNUSED_RESULT; - - // Adds |extension| to |file_name|. Returns the current FilePath if - // |extension| is empty. Returns "" if BaseName() == "." or "..". - FilePath AddExtension( - const StringType& extension) const WARN_UNUSED_RESULT; - - // Replaces the extension of |file_name| with |extension|. If |file_name| - // does not have an extension, then |extension| is added. If |extension| is - // empty, then the extension is removed from |file_name|. - // Returns "" if BaseName() == "." or "..". - FilePath ReplaceExtension( - const StringType& extension) const WARN_UNUSED_RESULT; - - // Returns true if the file path matches the specified extension. The test is - // case insensitive. Don't forget the leading period if appropriate. - bool MatchesExtension(const StringType& extension) const; - - // Returns a FilePath by appending a separator and the supplied path - // component to this object's path. Append takes care to avoid adding - // excessive separators if this object's path already ends with a separator. - // If this object's path is kCurrentDirectory, a new FilePath corresponding - // only to |component| is returned. |component| must be a relative path; - // it is an error to pass an absolute path. - FilePath Append(const StringType& component) const WARN_UNUSED_RESULT; - FilePath Append(const FilePath& component) const WARN_UNUSED_RESULT; - - // Although Windows StringType is std::wstring, since the encoding it uses for - // paths is well defined, it can handle ASCII path components as well. - // Mac uses UTF8, and since ASCII is a subset of that, it works there as well. - // On Linux, although it can use any 8-bit encoding for paths, we assume that - // ASCII is a valid subset, regardless of the encoding, since many operating - // system paths will always be ASCII. - FilePath AppendASCII(const base::StringPiece& component) - const WARN_UNUSED_RESULT; - - // Returns true if this FilePath contains an absolute path. On Windows, an - // absolute path begins with either a drive letter specification followed by - // a separator character, or with two separator characters. On POSIX - // platforms, an absolute path begins with a separator character. - bool IsAbsolute() const; - - // Returns a copy of this FilePath that does not end with a trailing - // separator. - FilePath StripTrailingSeparators() const WARN_UNUSED_RESULT; - - // Returns true if this FilePath contains any attempt to reference a parent - // directory (i.e. has a path component that is ".." - bool ReferencesParent() const; - - // Return a Unicode human-readable version of this path. - // Warning: you can *not*, in general, go from a display name back to a real - // path. Only use this when displaying paths to users, not just when you - // want to stuff a string16 into some other API. - string16 LossyDisplayName() const; - - // Return the path as ASCII, or the empty string if the path is not ASCII. - // This should only be used for cases where the FilePath is representing a - // known-ASCII filename. - std::string MaybeAsASCII() const; - - // Return the path as UTF-8. - // - // This function is *unsafe* as there is no way to tell what encoding is - // used in file names on POSIX systems other than Mac and Chrome OS, - // although UTF-8 is practically used everywhere these days. To mitigate - // the encoding issue, this function internally calls - // SysNativeMBToWide() on POSIX systems other than Mac and Chrome OS, - // per assumption that the current locale's encoding is used in file - // names, but this isn't a perfect solution. - // - // Once it becomes safe to to stop caring about non-UTF-8 file names, - // the SysNativeMBToWide() hack will be removed from the code, along - // with "Unsafe" in the function name. - std::string AsUTF8Unsafe() const; - - // Older Chromium code assumes that paths are always wstrings. - // This function converts wstrings to FilePaths, and is - // useful to smooth porting that old code to the FilePath API. - // It has "Hack" its name so people feel bad about using it. - // http://code.google.com/p/chromium/issues/detail?id=24672 - // - // If you are trying to be a good citizen and remove these, ask yourself: - // - Am I interacting with other Chrome code that deals with files? Then - // try to convert the API into using FilePath. - // - Am I interacting with OS-native calls? Then use value() to get at an - // OS-native string format. - // - Am I using well-known file names, like "config.ini"? Then use the - // ASCII functions (we require paths to always be supersets of ASCII). - // - Am I displaying a string to the user in some UI? Then use the - // LossyDisplayName() function, but keep in mind that you can't - // ever use the result of that again as a path. - static FilePath FromWStringHack(const std::wstring& wstring); - - // Returns a FilePath object from a path name in UTF-8. This function - // should only be used for cases where you are sure that the input - // string is UTF-8. - // - // Like AsUTF8Unsafe(), this function is unsafe. This function - // internally calls SysWideToNativeMB() on POSIX systems other than Mac - // and Chrome OS, to mitigate the encoding issue. See the comment at - // AsUTF8Unsafe() for details. - static FilePath FromUTF8Unsafe(const std::string& utf8); - - void WriteToPickle(Pickle* pickle) const; - bool ReadFromPickle(PickleIterator* iter); - - // Normalize all path separators to backslash on Windows - // (if FILE_PATH_USES_WIN_SEPARATORS is true), or do nothing on POSIX systems. - FilePath NormalizePathSeparators() const; - - // Compare two strings in the same way the file system does. - // Note that these always ignore case, even on file systems that are case- - // sensitive. If case-sensitive comparison is ever needed, add corresponding - // methods here. - // The methods are written as a static method so that they can also be used - // on parts of a file path, e.g., just the extension. - // CompareIgnoreCase() returns -1, 0 or 1 for less-than, equal-to and - // greater-than respectively. - static int CompareIgnoreCase(const StringType& string1, - const StringType& string2); - static bool CompareEqualIgnoreCase(const StringType& string1, - const StringType& string2) { - return CompareIgnoreCase(string1, string2) == 0; - } - static bool CompareLessIgnoreCase(const StringType& string1, - const StringType& string2) { - return CompareIgnoreCase(string1, string2) < 0; - } - -#if defined(OS_MACOSX) - // Returns the string in the special canonical decomposed form as defined for - // HFS, which is close to, but not quite, decomposition form D. See - // http://developer.apple.com/mac/library/technotes/tn/tn1150.html#UnicodeSubtleties - // for further comments. - // Returns the epmty string if the conversion failed. - static StringType GetHFSDecomposedForm(const FilePath::StringType& string); - - // Special UTF-8 version of FastUnicodeCompare. Cf: - // http://developer.apple.com/mac/library/technotes/tn/tn1150.html#StringComparisonAlgorithm - // IMPORTANT: The input strings must be in the special HFS decomposed form! - // (cf. above GetHFSDecomposedForm method) - static int HFSFastUnicodeCompare(const StringType& string1, - const StringType& string2); -#endif - - private: - // Remove trailing separators from this object. If the path is absolute, it - // will never be stripped any more than to refer to the absolute root - // directory, so "////" will become "/", not "". A leading pair of - // separators is never stripped, to support alternate roots. This is used to - // support UNC paths on Windows. - void StripTrailingSeparatorsInternal(); - - StringType path_; -}; - -} // namespace base - -// This is required by googletest to print a readable output on test failures. -BASE_EXPORT extern void PrintTo(const base::FilePath& path, std::ostream* out); - -// Macros for string literal initialization of FilePath::CharType[], and for -// using a FilePath::CharType[] in a printf-style format string. -#if defined(OS_POSIX) -#define FILE_PATH_LITERAL(x) x -#define PRFilePath "s" -#define PRFilePathLiteral "%s" -#elif defined(OS_WIN) -#define FILE_PATH_LITERAL(x) L ## x -#define PRFilePath "ls" -#define PRFilePathLiteral L"%ls" -#endif // OS_WIN - -// Provide a hash function so that hash_sets and maps can contain FilePath -// objects. -namespace BASE_HASH_NAMESPACE { -#if defined(COMPILER_GCC) - -template<> -struct hash<base::FilePath> { - size_t operator()(const base::FilePath& f) const { - return hash<base::FilePath::StringType>()(f.value()); - } -}; - -#elif defined(COMPILER_MSVC) - -inline size_t hash_value(const base::FilePath& f) { - return hash_value(f.value()); -} - -#endif // COMPILER - -} // namespace BASE_HASH_NAMESPACE - -#endif // BASE_FILE_PATH_H_ +// TODO(brettw) remove this file. +#include "base/files/file_path.h" diff --git a/base/file_util.cc b/base/file_util.cc index 03e70f9..b6cdc98 100644 --- a/base/file_util.cc +++ b/base/file_util.cc @@ -11,11 +11,11 @@ #include <fstream> -#include "base/file_path.h" +#include "base/files/file_path.h" #include "base/logging.h" -#include "base/stringprintf.h" #include "base/string_piece.h" #include "base/string_util.h" +#include "base/stringprintf.h" #include "base/utf_string_conversions.h" using base::FilePath; diff --git a/base/file_util.h b/base/file_util.h index 6a8fd05..e36456a 100644 --- a/base/file_util.h +++ b/base/file_util.h @@ -26,7 +26,7 @@ #include "base/base_export.h" #include "base/basictypes.h" -#include "base/file_path.h" +#include "base/files/file_path.h" #include "base/memory/scoped_ptr.h" #include "base/platform_file.h" #include "base/string16.h" diff --git a/base/file_util_android.cc b/base/file_util_android.cc index 615ffe6..6ac9def 100644 --- a/base/file_util_android.cc +++ b/base/file_util_android.cc @@ -4,7 +4,7 @@ #include "base/file_util.h" -#include "base/file_path.h" +#include "base/files/file_path.h" #include "base/path_service.h" namespace file_util { diff --git a/base/file_util_linux.cc b/base/file_util_linux.cc index cee2526..e4f0e28 100644 --- a/base/file_util_linux.cc +++ b/base/file_util_linux.cc @@ -4,7 +4,7 @@ #include "base/file_util.h" -#include "base/file_path.h" +#include "base/files/file_path.h" #include <errno.h> #include <sys/vfs.h> diff --git a/base/file_util_mac.mm b/base/file_util_mac.mm index 0de3786..377654d 100644 --- a/base/file_util_mac.mm +++ b/base/file_util_mac.mm @@ -8,7 +8,7 @@ #include <copyfile.h> #include "base/basictypes.h" -#include "base/file_path.h" +#include "base/files/file_path.h" #include "base/mac/foundation_util.h" #include "base/string_util.h" #include "base/threading/thread_restrictions.h" diff --git a/base/file_util_posix.cc b/base/file_util_posix.cc index 62bc9b3..974b30d 100644 --- a/base/file_util_posix.cc +++ b/base/file_util_posix.cc @@ -32,7 +32,7 @@ #include <fstream> #include "base/basictypes.h" -#include "base/file_path.h" +#include "base/files/file_path.h" #include "base/logging.h" #include "base/memory/scoped_ptr.h" #include "base/memory/singleton.h" diff --git a/base/file_util_unittest.cc b/base/file_util_unittest.cc index 8ae567d..b905654 100644 --- a/base/file_util_unittest.cc +++ b/base/file_util_unittest.cc @@ -17,8 +17,8 @@ #include <set> #include "base/base_paths.h" -#include "base/file_path.h" #include "base/file_util.h" +#include "base/files/file_path.h" #include "base/files/scoped_temp_dir.h" #include "base/path_service.h" #include "base/test/test_file_util.h" diff --git a/base/file_util_win.cc b/base/file_util_win.cc index a5f7e4c..679b108 100644 --- a/base/file_util_win.cc +++ b/base/file_util_win.cc @@ -14,7 +14,7 @@ #include <limits> #include <string> -#include "base/file_path.h" +#include "base/files/file_path.h" #include "base/logging.h" #include "base/metrics/histogram.h" #include "base/process_util.h" diff --git a/base/file_version_info_mac.mm b/base/file_version_info_mac.mm index 54af633..0c6f8d4 100644 --- a/base/file_version_info_mac.mm +++ b/base/file_version_info_mac.mm @@ -6,7 +6,7 @@ #import <Foundation/Foundation.h> -#include "base/file_path.h" +#include "base/files/file_path.h" #include "base/logging.h" #include "base/mac/bundle_locations.h" #include "base/mac/foundation_util.h" diff --git a/base/file_version_info_win.cc b/base/file_version_info_win.cc index e5cd5f7..80dbaea 100644 --- a/base/file_version_info_win.cc +++ b/base/file_version_info_win.cc @@ -6,8 +6,8 @@ #include <windows.h> -#include "base/file_path.h" #include "base/file_version_info.h" +#include "base/files/file_path.h" #include "base/logging.h" #include "base/path_service.h" #include "base/threading/thread_restrictions.h" diff --git a/base/file_path.cc b/base/files/file_path.cc index d56d8d0..407ec85 100644 --- a/base/file_path.cc +++ b/base/files/file_path.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/file_path.h" +#include "base/files/file_path.h" #include <string.h> #include <algorithm> diff --git a/base/files/file_path.h b/base/files/file_path.h new file mode 100644 index 0000000..2e0009d --- /dev/null +++ b/base/files/file_path.h @@ -0,0 +1,442 @@ +// Copyright (c) 2012 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. + +// FilePath is a container for pathnames stored in a platform's native string +// type, providing containers for manipulation in according with the +// platform's conventions for pathnames. It supports the following path +// types: +// +// POSIX Windows +// --------------- ---------------------------------- +// Fundamental type char[] wchar_t[] +// Encoding unspecified* UTF-16 +// Separator / \, tolerant of / +// Drive letters no case-insensitive A-Z followed by : +// Alternate root // (surprise!) \\, for UNC paths +// +// * The encoding need not be specified on POSIX systems, although some +// POSIX-compliant systems do specify an encoding. Mac OS X uses UTF-8. +// Chrome OS also uses UTF-8. +// Linux does not specify an encoding, but in practice, the locale's +// character set may be used. +// +// For more arcane bits of path trivia, see below. +// +// FilePath objects are intended to be used anywhere paths are. An +// application may pass FilePath objects around internally, masking the +// underlying differences between systems, only differing in implementation +// where interfacing directly with the system. For example, a single +// OpenFile(const FilePath &) function may be made available, allowing all +// callers to operate without regard to the underlying implementation. On +// POSIX-like platforms, OpenFile might wrap fopen, and on Windows, it might +// wrap _wfopen_s, perhaps both by calling file_path.value().c_str(). This +// allows each platform to pass pathnames around without requiring conversions +// between encodings, which has an impact on performance, but more imporantly, +// has an impact on correctness on platforms that do not have well-defined +// encodings for pathnames. +// +// Several methods are available to perform common operations on a FilePath +// object, such as determining the parent directory (DirName), isolating the +// final path component (BaseName), and appending a relative pathname string +// to an existing FilePath object (Append). These methods are highly +// recommended over attempting to split and concatenate strings directly. +// These methods are based purely on string manipulation and knowledge of +// platform-specific pathname conventions, and do not consult the filesystem +// at all, making them safe to use without fear of blocking on I/O operations. +// These methods do not function as mutators but instead return distinct +// instances of FilePath objects, and are therefore safe to use on const +// objects. The objects themselves are safe to share between threads. +// +// To aid in initialization of FilePath objects from string literals, a +// FILE_PATH_LITERAL macro is provided, which accounts for the difference +// between char[]-based pathnames on POSIX systems and wchar_t[]-based +// pathnames on Windows. +// +// Paths can't contain NULs as a precaution agaist premature truncation. +// +// Because a FilePath object should not be instantiated at the global scope, +// instead, use a FilePath::CharType[] and initialize it with +// FILE_PATH_LITERAL. At runtime, a FilePath object can be created from the +// character array. Example: +// +// | const FilePath::CharType kLogFileName[] = FILE_PATH_LITERAL("log.txt"); +// | +// | void Function() { +// | FilePath log_file_path(kLogFileName); +// | [...] +// | } +// +// WARNING: FilePaths should ALWAYS be displayed with LTR directionality, even +// when the UI language is RTL. This means you always need to pass filepaths +// through base::i18n::WrapPathWithLTRFormatting() before displaying it in the +// RTL UI. +// +// This is a very common source of bugs, please try to keep this in mind. +// +// ARCANE BITS OF PATH TRIVIA +// +// - A double leading slash is actually part of the POSIX standard. Systems +// are allowed to treat // as an alternate root, as Windows does for UNC +// (network share) paths. Most POSIX systems don't do anything special +// with two leading slashes, but FilePath handles this case properly +// in case it ever comes across such a system. FilePath needs this support +// for Windows UNC paths, anyway. +// References: +// The Open Group Base Specifications Issue 7, sections 3.266 ("Pathname") +// and 4.12 ("Pathname Resolution"), available at: +// http://www.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_266 +// http://www.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_12 +// +// - Windows treats c:\\ the same way it treats \\. This was intended to +// allow older applications that require drive letters to support UNC paths +// like \\server\share\path, by permitting c:\\server\share\path as an +// equivalent. Since the OS treats these paths specially, FilePath needs +// to do the same. Since Windows can use either / or \ as the separator, +// FilePath treats c://, c:\\, //, and \\ all equivalently. +// Reference: +// The Old New Thing, "Why is a drive letter permitted in front of UNC +// paths (sometimes)?", available at: +// http://blogs.msdn.com/oldnewthing/archive/2005/11/22/495740.aspx + +#ifndef BASE_FILES_FILE_PATH_H_ +#define BASE_FILES_FILE_PATH_H_ + +#include <stddef.h> +#include <string> +#include <vector> + +#include "base/base_export.h" +#include "base/compiler_specific.h" +#include "base/hash_tables.h" +#include "base/string16.h" +#include "base/string_piece.h" // For implicit conversions. +#include "build/build_config.h" + +// Windows-style drive letter support and pathname separator characters can be +// enabled and disabled independently, to aid testing. These #defines are +// here so that the same setting can be used in both the implementation and +// in the unit test. +#if defined(OS_WIN) +#define FILE_PATH_USES_DRIVE_LETTERS +#define FILE_PATH_USES_WIN_SEPARATORS +#endif // OS_WIN + +class Pickle; +class PickleIterator; + +namespace base { + +// An abstraction to isolate users from the differences between native +// pathnames on different platforms. +class BASE_EXPORT FilePath { + public: +#if defined(OS_POSIX) + // On most platforms, native pathnames are char arrays, and the encoding + // may or may not be specified. On Mac OS X, native pathnames are encoded + // in UTF-8. + typedef std::string StringType; +#elif defined(OS_WIN) + // On Windows, for Unicode-aware applications, native pathnames are wchar_t + // arrays encoded in UTF-16. + typedef std::wstring StringType; +#endif // OS_WIN + + typedef StringType::value_type CharType; + + // Null-terminated array of separators used to separate components in + // hierarchical paths. Each character in this array is a valid separator, + // but kSeparators[0] is treated as the canonical separator and will be used + // when composing pathnames. + static const CharType kSeparators[]; + + // A special path component meaning "this directory." + static const CharType kCurrentDirectory[]; + + // A special path component meaning "the parent directory." + static const CharType kParentDirectory[]; + + // The character used to identify a file extension. + static const CharType kExtensionSeparator; + + FilePath(); + FilePath(const FilePath& that); + explicit FilePath(const StringType& path); + ~FilePath(); + FilePath& operator=(const FilePath& that); + + bool operator==(const FilePath& that) const; + + bool operator!=(const FilePath& that) const; + + // Required for some STL containers and operations + bool operator<(const FilePath& that) const { + return path_ < that.path_; + } + + const StringType& value() const { return path_; } + + bool empty() const { return path_.empty(); } + + void clear() { path_.clear(); } + + // Returns true if |character| is in kSeparators. + static bool IsSeparator(CharType character); + + // Returns a vector of all of the components of the provided path. It is + // equivalent to calling DirName().value() on the path's root component, + // and BaseName().value() on each child component. + void GetComponents(std::vector<FilePath::StringType>* components) const; + + // Returns true if this FilePath is a strict parent of the |child|. Absolute + // and relative paths are accepted i.e. is /foo parent to /foo/bar and + // is foo parent to foo/bar. Does not convert paths to absolute, follow + // symlinks or directory navigation (e.g. ".."). A path is *NOT* its own + // parent. + bool IsParent(const FilePath& child) const; + + // If IsParent(child) holds, appends to path (if non-NULL) the + // relative path to child and returns true. For example, if parent + // holds "/Users/johndoe/Library/Application Support", child holds + // "/Users/johndoe/Library/Application Support/Google/Chrome/Default", and + // *path holds "/Users/johndoe/Library/Caches", then after + // parent.AppendRelativePath(child, path) is called *path will hold + // "/Users/johndoe/Library/Caches/Google/Chrome/Default". Otherwise, + // returns false. + bool AppendRelativePath(const FilePath& child, FilePath* path) const; + + // Returns a FilePath corresponding to the directory containing the path + // named by this object, stripping away the file component. If this object + // only contains one component, returns a FilePath identifying + // kCurrentDirectory. If this object already refers to the root directory, + // returns a FilePath identifying the root directory. + FilePath DirName() const WARN_UNUSED_RESULT; + + // Returns a FilePath corresponding to the last path component of this + // object, either a file or a directory. If this object already refers to + // the root directory, returns a FilePath identifying the root directory; + // this is the only situation in which BaseName will return an absolute path. + FilePath BaseName() const WARN_UNUSED_RESULT; + + // Returns ".jpg" for path "C:\pics\jojo.jpg", or an empty string if + // the file has no extension. If non-empty, Extension() will always start + // with precisely one ".". The following code should always work regardless + // of the value of path. + // new_path = path.RemoveExtension().value().append(path.Extension()); + // ASSERT(new_path == path.value()); + // NOTE: this is different from the original file_util implementation which + // returned the extension without a leading "." ("jpg" instead of ".jpg") + StringType Extension() const; + + // Returns "C:\pics\jojo" for path "C:\pics\jojo.jpg" + // NOTE: this is slightly different from the similar file_util implementation + // which returned simply 'jojo'. + FilePath RemoveExtension() const WARN_UNUSED_RESULT; + + // Inserts |suffix| after the file name portion of |path| but before the + // extension. Returns "" if BaseName() == "." or "..". + // Examples: + // path == "C:\pics\jojo.jpg" suffix == " (1)", returns "C:\pics\jojo (1).jpg" + // path == "jojo.jpg" suffix == " (1)", returns "jojo (1).jpg" + // path == "C:\pics\jojo" suffix == " (1)", returns "C:\pics\jojo (1)" + // path == "C:\pics.old\jojo" suffix == " (1)", returns "C:\pics.old\jojo (1)" + FilePath InsertBeforeExtension( + const StringType& suffix) const WARN_UNUSED_RESULT; + FilePath InsertBeforeExtensionASCII( + const base::StringPiece& suffix) const WARN_UNUSED_RESULT; + + // Adds |extension| to |file_name|. Returns the current FilePath if + // |extension| is empty. Returns "" if BaseName() == "." or "..". + FilePath AddExtension( + const StringType& extension) const WARN_UNUSED_RESULT; + + // Replaces the extension of |file_name| with |extension|. If |file_name| + // does not have an extension, then |extension| is added. If |extension| is + // empty, then the extension is removed from |file_name|. + // Returns "" if BaseName() == "." or "..". + FilePath ReplaceExtension( + const StringType& extension) const WARN_UNUSED_RESULT; + + // Returns true if the file path matches the specified extension. The test is + // case insensitive. Don't forget the leading period if appropriate. + bool MatchesExtension(const StringType& extension) const; + + // Returns a FilePath by appending a separator and the supplied path + // component to this object's path. Append takes care to avoid adding + // excessive separators if this object's path already ends with a separator. + // If this object's path is kCurrentDirectory, a new FilePath corresponding + // only to |component| is returned. |component| must be a relative path; + // it is an error to pass an absolute path. + FilePath Append(const StringType& component) const WARN_UNUSED_RESULT; + FilePath Append(const FilePath& component) const WARN_UNUSED_RESULT; + + // Although Windows StringType is std::wstring, since the encoding it uses for + // paths is well defined, it can handle ASCII path components as well. + // Mac uses UTF8, and since ASCII is a subset of that, it works there as well. + // On Linux, although it can use any 8-bit encoding for paths, we assume that + // ASCII is a valid subset, regardless of the encoding, since many operating + // system paths will always be ASCII. + FilePath AppendASCII(const base::StringPiece& component) + const WARN_UNUSED_RESULT; + + // Returns true if this FilePath contains an absolute path. On Windows, an + // absolute path begins with either a drive letter specification followed by + // a separator character, or with two separator characters. On POSIX + // platforms, an absolute path begins with a separator character. + bool IsAbsolute() const; + + // Returns a copy of this FilePath that does not end with a trailing + // separator. + FilePath StripTrailingSeparators() const WARN_UNUSED_RESULT; + + // Returns true if this FilePath contains any attempt to reference a parent + // directory (i.e. has a path component that is ".." + bool ReferencesParent() const; + + // Return a Unicode human-readable version of this path. + // Warning: you can *not*, in general, go from a display name back to a real + // path. Only use this when displaying paths to users, not just when you + // want to stuff a string16 into some other API. + string16 LossyDisplayName() const; + + // Return the path as ASCII, or the empty string if the path is not ASCII. + // This should only be used for cases where the FilePath is representing a + // known-ASCII filename. + std::string MaybeAsASCII() const; + + // Return the path as UTF-8. + // + // This function is *unsafe* as there is no way to tell what encoding is + // used in file names on POSIX systems other than Mac and Chrome OS, + // although UTF-8 is practically used everywhere these days. To mitigate + // the encoding issue, this function internally calls + // SysNativeMBToWide() on POSIX systems other than Mac and Chrome OS, + // per assumption that the current locale's encoding is used in file + // names, but this isn't a perfect solution. + // + // Once it becomes safe to to stop caring about non-UTF-8 file names, + // the SysNativeMBToWide() hack will be removed from the code, along + // with "Unsafe" in the function name. + std::string AsUTF8Unsafe() const; + + // Older Chromium code assumes that paths are always wstrings. + // This function converts wstrings to FilePaths, and is + // useful to smooth porting that old code to the FilePath API. + // It has "Hack" its name so people feel bad about using it. + // http://code.google.com/p/chromium/issues/detail?id=24672 + // + // If you are trying to be a good citizen and remove these, ask yourself: + // - Am I interacting with other Chrome code that deals with files? Then + // try to convert the API into using FilePath. + // - Am I interacting with OS-native calls? Then use value() to get at an + // OS-native string format. + // - Am I using well-known file names, like "config.ini"? Then use the + // ASCII functions (we require paths to always be supersets of ASCII). + // - Am I displaying a string to the user in some UI? Then use the + // LossyDisplayName() function, but keep in mind that you can't + // ever use the result of that again as a path. + static FilePath FromWStringHack(const std::wstring& wstring); + + // Returns a FilePath object from a path name in UTF-8. This function + // should only be used for cases where you are sure that the input + // string is UTF-8. + // + // Like AsUTF8Unsafe(), this function is unsafe. This function + // internally calls SysWideToNativeMB() on POSIX systems other than Mac + // and Chrome OS, to mitigate the encoding issue. See the comment at + // AsUTF8Unsafe() for details. + static FilePath FromUTF8Unsafe(const std::string& utf8); + + void WriteToPickle(Pickle* pickle) const; + bool ReadFromPickle(PickleIterator* iter); + + // Normalize all path separators to backslash on Windows + // (if FILE_PATH_USES_WIN_SEPARATORS is true), or do nothing on POSIX systems. + FilePath NormalizePathSeparators() const; + + // Compare two strings in the same way the file system does. + // Note that these always ignore case, even on file systems that are case- + // sensitive. If case-sensitive comparison is ever needed, add corresponding + // methods here. + // The methods are written as a static method so that they can also be used + // on parts of a file path, e.g., just the extension. + // CompareIgnoreCase() returns -1, 0 or 1 for less-than, equal-to and + // greater-than respectively. + static int CompareIgnoreCase(const StringType& string1, + const StringType& string2); + static bool CompareEqualIgnoreCase(const StringType& string1, + const StringType& string2) { + return CompareIgnoreCase(string1, string2) == 0; + } + static bool CompareLessIgnoreCase(const StringType& string1, + const StringType& string2) { + return CompareIgnoreCase(string1, string2) < 0; + } + +#if defined(OS_MACOSX) + // Returns the string in the special canonical decomposed form as defined for + // HFS, which is close to, but not quite, decomposition form D. See + // http://developer.apple.com/mac/library/technotes/tn/tn1150.html#UnicodeSubtleties + // for further comments. + // Returns the epmty string if the conversion failed. + static StringType GetHFSDecomposedForm(const FilePath::StringType& string); + + // Special UTF-8 version of FastUnicodeCompare. Cf: + // http://developer.apple.com/mac/library/technotes/tn/tn1150.html#StringComparisonAlgorithm + // IMPORTANT: The input strings must be in the special HFS decomposed form! + // (cf. above GetHFSDecomposedForm method) + static int HFSFastUnicodeCompare(const StringType& string1, + const StringType& string2); +#endif + + private: + // Remove trailing separators from this object. If the path is absolute, it + // will never be stripped any more than to refer to the absolute root + // directory, so "////" will become "/", not "". A leading pair of + // separators is never stripped, to support alternate roots. This is used to + // support UNC paths on Windows. + void StripTrailingSeparatorsInternal(); + + StringType path_; +}; + +} // namespace base + +// This is required by googletest to print a readable output on test failures. +BASE_EXPORT extern void PrintTo(const base::FilePath& path, std::ostream* out); + +// Macros for string literal initialization of FilePath::CharType[], and for +// using a FilePath::CharType[] in a printf-style format string. +#if defined(OS_POSIX) +#define FILE_PATH_LITERAL(x) x +#define PRFilePath "s" +#define PRFilePathLiteral "%s" +#elif defined(OS_WIN) +#define FILE_PATH_LITERAL(x) L ## x +#define PRFilePath "ls" +#define PRFilePathLiteral L"%ls" +#endif // OS_WIN + +// Provide a hash function so that hash_sets and maps can contain FilePath +// objects. +namespace BASE_HASH_NAMESPACE { +#if defined(COMPILER_GCC) + +template<> +struct hash<base::FilePath> { + size_t operator()(const base::FilePath& f) const { + return hash<base::FilePath::StringType>()(f.value()); + } +}; + +#elif defined(COMPILER_MSVC) + +inline size_t hash_value(const base::FilePath& f) { + return hash_value(f.value()); +} + +#endif // COMPILER + +} // namespace BASE_HASH_NAMESPACE + +#endif // BASE_FILES_FILE_PATH_H_ diff --git a/base/file_path_unittest.cc b/base/files/file_path_unittest.cc index ba6c8a2..9a690a9 100644 --- a/base/file_path_unittest.cc +++ b/base/files/file_path_unittest.cc @@ -3,8 +3,8 @@ // found in the LICENSE file. #include "base/basictypes.h" -#include "base/file_path.h" #include "base/file_util.h" +#include "base/files/file_path.h" #include "base/utf_string_conversions.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/platform_test.h" diff --git a/base/files/file_path_watcher.h b/base/files/file_path_watcher.h index b0d55a2..896601c 100644 --- a/base/files/file_path_watcher.h +++ b/base/files/file_path_watcher.h @@ -10,7 +10,7 @@ #include "base/base_export.h" #include "base/basictypes.h" #include "base/callback.h" -#include "base/file_path.h" +#include "base/files/file_path.h" #include "base/memory/ref_counted.h" #include "base/message_loop_proxy.h" diff --git a/base/files/file_path_watcher_browsertest.cc b/base/files/file_path_watcher_browsertest.cc index 9129d91..48d8d0d 100644 --- a/base/files/file_path_watcher_browsertest.cc +++ b/base/files/file_path_watcher_browsertest.cc @@ -17,8 +17,8 @@ #include "base/bind.h" #include "base/bind_helpers.h" #include "base/compiler_specific.h" -#include "base/file_path.h" #include "base/file_util.h" +#include "base/files/file_path.h" #include "base/files/scoped_temp_dir.h" #include "base/message_loop.h" #include "base/message_loop_proxy.h" diff --git a/base/files/file_path_watcher_linux.cc b/base/files/file_path_watcher_linux.cc index b4a714a..074eee3 100644 --- a/base/files/file_path_watcher_linux.cc +++ b/base/files/file_path_watcher_linux.cc @@ -17,8 +17,8 @@ #include <vector> #include "base/bind.h" -#include "base/file_path.h" #include "base/file_util.h" +#include "base/files/file_path.h" #include "base/hash_tables.h" #include "base/lazy_instance.h" #include "base/location.h" diff --git a/base/files/file_path_watcher_win.cc b/base/files/file_path_watcher_win.cc index 2c439ca..2452922 100644 --- a/base/files/file_path_watcher_win.cc +++ b/base/files/file_path_watcher_win.cc @@ -5,8 +5,8 @@ #include "base/files/file_path_watcher.h" #include "base/bind.h" -#include "base/file_path.h" #include "base/file_util.h" +#include "base/files/file_path.h" #include "base/logging.h" #include "base/memory/ref_counted.h" #include "base/message_loop_proxy.h" diff --git a/base/files/file_util_proxy.h b/base/files/file_util_proxy.h index 8cbdfcb..d155355 100644 --- a/base/files/file_util_proxy.h +++ b/base/files/file_util_proxy.h @@ -7,8 +7,8 @@ #include "base/base_export.h" #include "base/callback_forward.h" -#include "base/file_path.h" #include "base/file_util.h" +#include "base/files/file_path.h" #include "base/memory/ref_counted.h" #include "base/platform_file.h" diff --git a/base/files/important_file_writer.cc b/base/files/important_file_writer.cc index 4a7bdf9..e58dcf3 100644 --- a/base/files/important_file_writer.cc +++ b/base/files/important_file_writer.cc @@ -10,12 +10,12 @@ #include "base/bind.h" #include "base/critical_closure.h" -#include "base/file_path.h" #include "base/file_util.h" +#include "base/files/file_path.h" #include "base/logging.h" -#include "base/task_runner.h" #include "base/metrics/histogram.h" #include "base/strings/string_number_conversions.h" +#include "base/task_runner.h" #include "base/threading/thread.h" #include "base/time.h" diff --git a/base/files/important_file_writer.h b/base/files/important_file_writer.h index 9bc8f07..190a60b 100644 --- a/base/files/important_file_writer.h +++ b/base/files/important_file_writer.h @@ -9,7 +9,7 @@ #include "base/base_export.h" #include "base/basictypes.h" -#include "base/file_path.h" +#include "base/files/file_path.h" #include "base/memory/ref_counted.h" #include "base/threading/non_thread_safe.h" #include "base/time.h" diff --git a/base/files/important_file_writer_unittest.cc b/base/files/important_file_writer_unittest.cc index 53c642b..8133782 100644 --- a/base/files/important_file_writer_unittest.cc +++ b/base/files/important_file_writer_unittest.cc @@ -5,8 +5,8 @@ #include "base/files/important_file_writer.h" #include "base/compiler_specific.h" -#include "base/file_path.h" #include "base/file_util.h" +#include "base/files/file_path.h" #include "base/files/scoped_temp_dir.h" #include "base/logging.h" #include "base/message_loop.h" diff --git a/base/files/scoped_temp_dir.h b/base/files/scoped_temp_dir.h index 641e7ef..5f63e09 100644 --- a/base/files/scoped_temp_dir.h +++ b/base/files/scoped_temp_dir.h @@ -16,7 +16,7 @@ // intervening calls to Delete or Take, or the calls will fail. #include "base/base_export.h" -#include "base/file_path.h" +#include "base/files/file_path.h" namespace base { diff --git a/base/i18n/file_util_icu.cc b/base/i18n/file_util_icu.cc index 2f45efc..f023a4f 100644 --- a/base/i18n/file_util_icu.cc +++ b/base/i18n/file_util_icu.cc @@ -6,7 +6,7 @@ #include "base/i18n/file_util_icu.h" -#include "base/file_path.h" +#include "base/files/file_path.h" #include "base/i18n/icu_string_conversions.h" #include "base/logging.h" #include "base/memory/scoped_ptr.h" diff --git a/base/i18n/file_util_icu.h b/base/i18n/file_util_icu.h index cf22e7c..024a927 100644 --- a/base/i18n/file_util_icu.h +++ b/base/i18n/file_util_icu.h @@ -7,7 +7,7 @@ // File utilities that use the ICU library go in this file. -#include "base/file_path.h" +#include "base/files/file_path.h" #include "base/i18n/base_i18n_export.h" #include "base/string16.h" diff --git a/base/i18n/icu_util.cc b/base/i18n/icu_util.cc index 25fe8c1..fed1176 100644 --- a/base/i18n/icu_util.cc +++ b/base/i18n/icu_util.cc @@ -12,8 +12,8 @@ #include <string> -#include "base/file_path.h" #include "base/file_util.h" +#include "base/files/file_path.h" #include "base/logging.h" #include "base/path_service.h" #include "base/string_util.h" diff --git a/base/i18n/rtl.cc b/base/i18n/rtl.cc index 821548f..1b7dd8b 100644 --- a/base/i18n/rtl.cc +++ b/base/i18n/rtl.cc @@ -4,7 +4,7 @@ #include "base/i18n/rtl.h" -#include "base/file_path.h" +#include "base/files/file_path.h" #include "base/logging.h" #include "base/string_util.h" #include "base/strings/sys_string_conversions.h" diff --git a/base/i18n/rtl_unittest.cc b/base/i18n/rtl_unittest.cc index ed661a9..0cc334e 100644 --- a/base/i18n/rtl_unittest.cc +++ b/base/i18n/rtl_unittest.cc @@ -6,7 +6,7 @@ #include <algorithm> -#include "base/file_path.h" +#include "base/files/file_path.h" #include "base/string_util.h" #include "base/strings/sys_string_conversions.h" #include "base/utf_string_conversions.h" diff --git a/base/json/json_file_value_serializer.h b/base/json/json_file_value_serializer.h index 3869e5e..81904df 100644 --- a/base/json/json_file_value_serializer.h +++ b/base/json/json_file_value_serializer.h @@ -9,7 +9,7 @@ #include "base/base_export.h" #include "base/basictypes.h" -#include "base/file_path.h" +#include "base/files/file_path.h" #include "base/values.h" class BASE_EXPORT JSONFileValueSerializer : public base::ValueSerializer { diff --git a/base/json/json_string_value_serializer.h b/base/json/json_string_value_serializer.h index e333dc6..71bd152 100644 --- a/base/json/json_string_value_serializer.h +++ b/base/json/json_string_value_serializer.h @@ -9,7 +9,7 @@ #include "base/base_export.h" #include "base/basictypes.h" -#include "base/file_path.h" +#include "base/files/file_path.h" #include "base/values.h" class BASE_EXPORT JSONStringValueSerializer : public base::ValueSerializer { diff --git a/base/mac/bundle_locations.h b/base/mac/bundle_locations.h index 1d96539..276290b 100644 --- a/base/mac/bundle_locations.h +++ b/base/mac/bundle_locations.h @@ -6,7 +6,7 @@ #define BASE_MAC_BUNDLE_LOCATIONS_H_ #include "base/base_export.h" -#include "base/file_path.h" +#include "base/files/file_path.h" #if defined(__OBJC__) #import <Foundation/Foundation.h> diff --git a/base/mac/foundation_util.mm b/base/mac/foundation_util.mm index 1217402..71e8942 100644 --- a/base/mac/foundation_util.mm +++ b/base/mac/foundation_util.mm @@ -7,7 +7,7 @@ #include <stdlib.h> #include <string.h> -#include "base/file_path.h" +#include "base/files/file_path.h" #include "base/logging.h" #include "base/mac/bundle_locations.h" #include "base/mac/mac_logging.h" diff --git a/base/mac/foundation_util_unittest.mm b/base/mac/foundation_util_unittest.mm index 6fb85d8..fc7dd09 100644 --- a/base/mac/foundation_util_unittest.mm +++ b/base/mac/foundation_util_unittest.mm @@ -5,7 +5,7 @@ #include "base/mac/foundation_util.h" #include "base/basictypes.h" -#include "base/file_path.h" +#include "base/files/file_path.h" #include "base/mac/scoped_cftyperef.h" #include "base/mac/scoped_nsautorelease_pool.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/base/mac/mac_util.mm b/base/mac/mac_util.mm index 5a46200..d3594a4 100644 --- a/base/mac/mac_util.mm +++ b/base/mac/mac_util.mm @@ -12,7 +12,7 @@ #include <sys/utsname.h> #include <sys/xattr.h> -#include "base/file_path.h" +#include "base/files/file_path.h" #include "base/logging.h" #include "base/mac/bundle_locations.h" #include "base/mac/foundation_util.h" diff --git a/base/mac/mac_util_unittest.mm b/base/mac/mac_util_unittest.mm index 3182948..44cc5ec 100644 --- a/base/mac/mac_util_unittest.mm +++ b/base/mac/mac_util_unittest.mm @@ -6,8 +6,8 @@ #include "base/mac/mac_util.h" -#include "base/file_path.h" #include "base/file_util.h" +#include "base/files/file_path.h" #include "base/files/scoped_temp_dir.h" #include "base/mac/foundation_util.h" #include "base/mac/scoped_cftyperef.h" diff --git a/base/native_library_mac.mm b/base/native_library_mac.mm index daaaeb0..eec586b 100644 --- a/base/native_library_mac.mm +++ b/base/native_library_mac.mm @@ -6,8 +6,8 @@ #include <dlfcn.h> -#include "base/file_path.h" #include "base/file_util.h" +#include "base/files/file_path.h" #include "base/mac/scoped_cftyperef.h" #include "base/string_util.h" #include "base/threading/thread_restrictions.h" diff --git a/base/native_library_posix.cc b/base/native_library_posix.cc index 4b82ff4..9b694e1 100644 --- a/base/native_library_posix.cc +++ b/base/native_library_posix.cc @@ -6,7 +6,7 @@ #include <dlfcn.h> -#include "base/file_path.h" +#include "base/files/file_path.h" #include "base/logging.h" #include "base/threading/thread_restrictions.h" #include "base/utf_string_conversions.h" diff --git a/base/nix/xdg_util.cc b/base/nix/xdg_util.cc index 10cbcaa..b3caf2a 100644 --- a/base/nix/xdg_util.cc +++ b/base/nix/xdg_util.cc @@ -7,8 +7,8 @@ #include <string> #include "base/environment.h" -#include "base/file_path.h" #include "base/file_util.h" +#include "base/files/file_path.h" #include "base/third_party/xdg_user_dirs/xdg_user_dir_lookup.h" namespace { diff --git a/base/path_service.cc b/base/path_service.cc index cb34d28..5b362ab 100644 --- a/base/path_service.cc +++ b/base/path_service.cc @@ -10,8 +10,8 @@ #include <shlobj.h> #endif -#include "base/file_path.h" #include "base/file_util.h" +#include "base/files/file_path.h" #include "base/hash_tables.h" #include "base/lazy_instance.h" #include "base/logging.h" diff --git a/base/path_service_unittest.cc b/base/path_service_unittest.cc index 7c0f036..8ae4178 100644 --- a/base/path_service_unittest.cc +++ b/base/path_service_unittest.cc @@ -5,8 +5,8 @@ #include "base/path_service.h" #include "base/basictypes.h" -#include "base/file_path.h" #include "base/file_util.h" +#include "base/files/file_path.h" #include "base/files/scoped_temp_dir.h" #include "base/string_util.h" #include "build/build_config.h" diff --git a/base/perftimer.cc b/base/perftimer.cc index 94158c8..9ab7c6b 100644 --- a/base/perftimer.cc +++ b/base/perftimer.cc @@ -8,8 +8,8 @@ #include <string> #include "base/basictypes.h" -#include "base/file_path.h" #include "base/file_util.h" +#include "base/files/file_path.h" #include "base/logging.h" static FILE* perf_log_file = NULL; diff --git a/base/platform_file.h b/base/platform_file.h index 1ac40fcd..48d1806 100644 --- a/base/platform_file.h +++ b/base/platform_file.h @@ -14,7 +14,7 @@ #include "base/base_export.h" #include "base/basictypes.h" -#include "base/file_path.h" +#include "base/files/file_path.h" #include "base/time.h" namespace base { diff --git a/base/platform_file_posix.cc b/base/platform_file_posix.cc index d89a1b0..ee06055 100644 --- a/base/platform_file_posix.cc +++ b/base/platform_file_posix.cc @@ -9,7 +9,7 @@ #include <sys/stat.h> #include <unistd.h> -#include "base/file_path.h" +#include "base/files/file_path.h" #include "base/logging.h" #include "base/posix/eintr_wrapper.h" #include "base/threading/thread_restrictions.h" diff --git a/base/platform_file_win.cc b/base/platform_file_win.cc index 7c72f9e..b88fe9c 100644 --- a/base/platform_file_win.cc +++ b/base/platform_file_win.cc @@ -4,7 +4,7 @@ #include "base/platform_file.h" -#include "base/file_path.h" +#include "base/files/file_path.h" #include "base/logging.h" #include "base/threading/thread_restrictions.h" diff --git a/base/prefs/json_pref_store.h b/base/prefs/json_pref_store.h index 479d706..7956764 100644 --- a/base/prefs/json_pref_store.h +++ b/base/prefs/json_pref_store.h @@ -10,7 +10,7 @@ #include "base/basictypes.h" #include "base/compiler_specific.h" -#include "base/file_path.h" +#include "base/files/file_path.h" #include "base/files/important_file_writer.h" #include "base/memory/scoped_ptr.h" #include "base/message_loop_proxy.h" diff --git a/base/prefs/pref_registry_simple.cc b/base/prefs/pref_registry_simple.cc index 792ff19..cc3f1f0 100644 --- a/base/prefs/pref_registry_simple.cc +++ b/base/prefs/pref_registry_simple.cc @@ -4,7 +4,7 @@ #include "base/prefs/pref_registry_simple.h" -#include "base/file_path.h" +#include "base/files/file_path.h" #include "base/string_number_conversions.h" #include "base/values.h" diff --git a/base/prefs/pref_service.cc b/base/prefs/pref_service.cc index 457778f..67ab898 100644 --- a/base/prefs/pref_service.cc +++ b/base/prefs/pref_service.cc @@ -7,7 +7,7 @@ #include <algorithm> #include "base/bind.h" -#include "base/file_path.h" +#include "base/files/file_path.h" #include "base/logging.h" #include "base/message_loop.h" #include "base/metrics/histogram.h" diff --git a/base/prefs/public/pref_member.h b/base/prefs/public/pref_member.h index 7e27912..4c82735 100644 --- a/base/prefs/public/pref_member.h +++ b/base/prefs/public/pref_member.h @@ -30,7 +30,7 @@ #include "base/basictypes.h" #include "base/bind.h" #include "base/callback_forward.h" -#include "base/file_path.h" +#include "base/files/file_path.h" #include "base/logging.h" #include "base/memory/ref_counted.h" #include "base/message_loop_proxy.h" diff --git a/base/process_util.h b/base/process_util.h index b8ad122..0df3b92 100644 --- a/base/process_util.h +++ b/base/process_util.h @@ -37,7 +37,7 @@ typedef struct _malloc_zone_t malloc_zone_t; #include <vector> #include "base/base_export.h" -#include "base/file_path.h" +#include "base/files/file_path.h" #include "base/process.h" #if defined(OS_POSIX) diff --git a/base/process_util_unittest.cc b/base/process_util_unittest.cc index 0310e9c..d109fba 100644 --- a/base/process_util_unittest.cc +++ b/base/process_util_unittest.cc @@ -9,7 +9,7 @@ #include "base/command_line.h" #include "base/debug/alias.h" #include "base/debug/stack_trace.h" -#include "base/file_path.h" +#include "base/files/file_path.h" #include "base/logging.h" #include "base/memory/scoped_ptr.h" #include "base/path_service.h" @@ -25,13 +25,13 @@ #include "testing/multiprocess_func_list.h" #if defined(OS_LINUX) -#include <malloc.h> #include <glib.h> +#include <malloc.h> #include <sched.h> #endif #if defined(OS_POSIX) -#include <errno.h> #include <dlfcn.h> +#include <errno.h> #include <fcntl.h> #include <signal.h> #include <sys/resource.h> diff --git a/base/scoped_native_library_unittest.cc b/base/scoped_native_library_unittest.cc index a4fde6a..c120555 100644 --- a/base/scoped_native_library_unittest.cc +++ b/base/scoped_native_library_unittest.cc @@ -4,7 +4,7 @@ #include "base/scoped_native_library.h" #if defined(OS_WIN) -#include "base/file_path.h" +#include "base/files/file_path.h" #endif #include "testing/gtest/include/gtest/gtest.h" diff --git a/base/sys_info.h b/base/sys_info.h index 5af5d43..38462ed 100644 --- a/base/sys_info.h +++ b/base/sys_info.h @@ -9,7 +9,7 @@ #include "base/base_export.h" #include "base/basictypes.h" -#include "base/file_path.h" +#include "base/files/file_path.h" #include "build/build_config.h" namespace base { diff --git a/base/sys_info_chromeos.cc b/base/sys_info_chromeos.cc index 78b8bd5..ef7b3dc 100644 --- a/base/sys_info_chromeos.cc +++ b/base/sys_info_chromeos.cc @@ -5,8 +5,8 @@ #include "base/sys_info.h" #include "base/basictypes.h" -#include "base/file_path.h" #include "base/file_util.h" +#include "base/files/file_path.h" #include "base/lazy_instance.h" #include "base/string_piece.h" #include "base/strings/string_number_conversions.h" diff --git a/base/sys_info_win.cc b/base/sys_info_win.cc index 98d2f7c..af0ce7e 100644 --- a/base/sys_info_win.cc +++ b/base/sys_info_win.cc @@ -6,7 +6,7 @@ #include <windows.h> -#include "base/file_path.h" +#include "base/files/file_path.h" #include "base/logging.h" #include "base/memory/scoped_ptr.h" #include "base/stringprintf.h" diff --git a/base/test/perf_test_suite.cc b/base/test/perf_test_suite.cc index 232766a..7276c14 100644 --- a/base/test/perf_test_suite.cc +++ b/base/test/perf_test_suite.cc @@ -6,7 +6,7 @@ #include "base/command_line.h" #include "base/debug/debugger.h" -#include "base/file_path.h" +#include "base/files/file_path.h" #include "base/path_service.h" #include "base/perftimer.h" #include "base/process_util.h" diff --git a/base/test/test_file_util.h b/base/test/test_file_util.h index e97c0e5..8d1be1c 100644 --- a/base/test/test_file_util.h +++ b/base/test/test_file_util.h @@ -10,7 +10,7 @@ #include <string> #include "base/compiler_specific.h" -#include "base/file_path.h" +#include "base/files/file_path.h" namespace base { class FilePath; diff --git a/base/test/test_file_util_linux.cc b/base/test/test_file_util_linux.cc index 958fa81..7eb0533 100644 --- a/base/test/test_file_util_linux.cc +++ b/base/test/test_file_util_linux.cc @@ -9,7 +9,7 @@ #include <sys/types.h> #include <unistd.h> -#include "base/file_path.h" +#include "base/files/file_path.h" namespace file_util { diff --git a/base/test/test_file_util_posix.cc b/base/test/test_file_util_posix.cc index f538bc1..6be1c82 100644 --- a/base/test/test_file_util_posix.cc +++ b/base/test/test_file_util_posix.cc @@ -11,8 +11,8 @@ #include <string> -#include "base/file_path.h" #include "base/file_util.h" +#include "base/files/file_path.h" #include "base/logging.h" #include "base/string_util.h" #include "base/utf_string_conversions.h" diff --git a/base/test/test_file_util_win.cc b/base/test/test_file_util_win.cc index 9b234e3..8d28aef 100644 --- a/base/test/test_file_util_win.cc +++ b/base/test/test_file_util_win.cc @@ -4,14 +4,14 @@ #include "base/test/test_file_util.h" +#include <windows.h> #include <aclapi.h> #include <shlwapi.h> -#include <windows.h> #include <vector> -#include "base/file_path.h" #include "base/file_util.h" +#include "base/files/file_path.h" #include "base/logging.h" #include "base/strings/string_split.h" #include "base/threading/platform_thread.h" diff --git a/base/test/test_shortcut_win.cc b/base/test/test_shortcut_win.cc index 1a0d280..ec6300a 100644 --- a/base/test/test_shortcut_win.cc +++ b/base/test/test_shortcut_win.cc @@ -8,7 +8,7 @@ #include <shlobj.h> #include <propkey.h> -#include "base/file_path.h" +#include "base/files/file_path.h" #include "base/string16.h" #include "base/utf_string_conversions.h" #include "base/win/scoped_comptr.h" diff --git a/base/test/test_shortcut_win.h b/base/test/test_shortcut_win.h index ef75713..4c42935 100644 --- a/base/test/test_shortcut_win.h +++ b/base/test/test_shortcut_win.h @@ -5,7 +5,7 @@ #ifndef BASE_TEST_TEST_SHORTCUT_WIN_H_ #define BASE_TEST_TEST_SHORTCUT_WIN_H_ -#include "base/file_path.h" +#include "base/files/file_path.h" #include "base/win/shortcut.h" // Windows shortcut functions used only by tests. diff --git a/base/test/test_suite.cc b/base/test/test_suite.cc index cd7875b..a55b8e0 100644 --- a/base/test/test_suite.cc +++ b/base/test/test_suite.cc @@ -11,7 +11,7 @@ #include "base/debug/debug_on_start_win.h" #include "base/debug/debugger.h" #include "base/debug/stack_trace.h" -#include "base/file_path.h" +#include "base/files/file_path.h" #include "base/i18n/icu_util.h" #include "base/logging.h" #include "base/memory/scoped_ptr.h" diff --git a/base/test/test_support_android.cc b/base/test/test_support_android.cc index b87c073..64da18a 100644 --- a/base/test/test_support_android.cc +++ b/base/test/test_support_android.cc @@ -6,7 +6,7 @@ #include <string.h> #include "base/android/path_utils.h" -#include "base/file_path.h" +#include "base/files/file_path.h" #include "base/logging.h" #include "base/memory/singleton.h" #include "base/message_loop.h" diff --git a/base/value_conversions.cc b/base/value_conversions.cc index 08a6b3c..b9c831e 100644 --- a/base/value_conversions.cc +++ b/base/value_conversions.cc @@ -4,7 +4,7 @@ #include "base/value_conversions.h" -#include "base/file_path.h" +#include "base/files/file_path.h" #include "base/strings/string_number_conversions.h" #include "base/time.h" #include "base/values.h" diff --git a/base/win/event_trace_consumer_unittest.cc b/base/win/event_trace_consumer_unittest.cc index 9e9297c..be8e5f4 100644 --- a/base/win/event_trace_consumer_unittest.cc +++ b/base/win/event_trace_consumer_unittest.cc @@ -10,8 +10,8 @@ #include <objbase.h> #include "base/basictypes.h" -#include "base/file_path.h" #include "base/file_util.h" +#include "base/files/file_path.h" #include "base/files/scoped_temp_dir.h" #include "base/logging.h" #include "base/process.h" diff --git a/base/win/event_trace_controller_unittest.cc b/base/win/event_trace_controller_unittest.cc index 82c4106..2ab9ef0 100644 --- a/base/win/event_trace_controller_unittest.cc +++ b/base/win/event_trace_controller_unittest.cc @@ -7,8 +7,8 @@ #include <objbase.h> #include <initguid.h> -#include "base/file_path.h" #include "base/file_util.h" +#include "base/files/file_path.h" #include "base/files/scoped_temp_dir.h" #include "base/logging.h" #include "base/process.h" diff --git a/base/win/metro.h b/base/win/metro.h index 8c7f3f9..1aa07fb 100644 --- a/base/win/metro.h +++ b/base/win/metro.h @@ -10,7 +10,7 @@ #include "base/base_export.h" #include "base/callback.h" -#include "base/file_path.h" +#include "base/files/file_path.h" #include "base/string16.h" namespace base { diff --git a/base/win/shortcut.h b/base/win/shortcut.h index 52ac1a7..3ecd84c 100644 --- a/base/win/shortcut.h +++ b/base/win/shortcut.h @@ -7,8 +7,8 @@ #include <windows.h> +#include "base/files/file_path.h" #include "base/logging.h" -#include "base/file_path.h" #include "base/string16.h" namespace base { diff --git a/base/win/shortcut_unittest.cc b/base/win/shortcut_unittest.cc index 14aab29..56f3b4a 100644 --- a/base/win/shortcut_unittest.cc +++ b/base/win/shortcut_unittest.cc @@ -6,8 +6,8 @@ #include <string> -#include "base/file_path.h" #include "base/file_util.h" +#include "base/files/file_path.h" #include "base/files/scoped_temp_dir.h" #include "base/test/test_file_util.h" #include "base/test/test_shortcut_win.h" |