0

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
This commit is contained in:
brettw@chromium.org
2013-02-24 05:40:52 +00:00
parent 8701de1793
commit 57999817d3
1203 changed files with 1793 additions and 1784 deletions
android_webview/browser
apps/app_host
ash
base
android
base.gypbase.gypibase_paths.ccbase_paths_android.ccbase_paths_mac.mmbase_paths_posix.ccbase_paths_win.cccommand_line.cccommand_line_unittest.ccfile_path.hfile_util.ccfile_util.hfile_util_android.ccfile_util_linux.ccfile_util_mac.mmfile_util_posix.ccfile_util_unittest.ccfile_util_win.ccfile_version_info_mac.mmfile_version_info_win.cc
files
i18n
json
mac
native_library_mac.mmnative_library_posix.cc
nix
path_service.ccpath_service_unittest.ccperftimer.ccplatform_file.hplatform_file_posix.ccplatform_file_win.cc
prefs
process_util.hprocess_util_unittest.ccscoped_native_library_unittest.ccsys_info.hsys_info_chromeos.ccsys_info_win.cc
test
value_conversions.cc
win
cc
chrome
app
browser
android
app_controller_mac.mmauto_launch_trial.cc
autofill
automation
background
bookmarks
browser_shutdown.ccbrowser_util_win.cc
browsing_data
captive_portal
chrome_browser_main.ccchrome_browser_main_mac.mmchrome_browser_main_win.ccchrome_to_mobile_service.h
chromeos
app_mode
boot_times_loader.cc
contacts
cros
customization_document.cc
drive
extensions
external_metrics.h
imageburner
kiosk_mode
login
mobile
mobile_config.cc
settings
system
system_logs
version_loader.cc
component_updater
crash_handler_host_linux.cccrash_recovery_browsertest.cccrash_upload_list.cc
diagnostics
download
enumerate_modules_model_win.cc
extensions
activity_database.hactivity_database_unittest.cc
api
app_notification_manager.ccapp_notification_storage.ccapp_notification_storage_unittest.cccomponent_loader.hconvert_user_script.ccconvert_user_script_unittest.ccconvert_web_app.ccconvert_web_app_unittest.cccrx_installer.h
docs
extension_browsertest.ccextension_browsertest.hextension_creator_filter.ccextension_disabled_ui_browsertest.ccextension_function_test_utils.ccextension_nacl_browsertest.ccextension_protocols.ccextension_resource_protocols.ccextension_service.hextension_service_unittest.hextension_startup_browsertest.ccextension_sync_data_unittest.ccextension_system.ccexternal_loader.hexternal_pref_loader.ccexternal_provider_impl.ccexternal_registry_loader_win.ccfile_reader_unittest.ccinstalled_loader.cclazy_background_page_apitest.ccpack_extension_job.hpermissions_updater_unittest.ccplatform_app_launcher.ccrequirements_checker_browsertest.ccsandboxed_unpacker.hscript_bubble_controller_unittest.ccstate_store.hsystem_info_event_router.hunpacked_installer.h
updater
user_script_master.ccuser_script_master.huser_script_master_unittest.cc
fast_shutdown_browsertest.cc
feedback
first_run
google
google_apis
history
icon_manager_chromeos.ccicon_manager_mac.mmicon_manager_win.cciframe_browsertest.cc
importer
mac
managed_mode
media_gallery
memory_details_mac.ccmemory_details_win.cc
metrics
mouseleave_browsertest.cc
nacl_host
net
page_cycler
parsers
password_manager
pepper_broker_infobar_delegate.h
performance_monitor
platform_util_mac.mmplatform_util_win.cc
plugins
policy
popup_blocker_browsertest.cc
predictors
prefs
printing
process_info_snapshot_mac_unittest.ccprocess_singleton.hprocess_singleton_browsertest.ccprocess_singleton_linux.ccprocess_singleton_linux_unittest.ccprocess_singleton_win.cc
profiles
renderer_host
safe_browsing
service
sessions
shell_integration.hshell_integration_linux.ccshell_integration_linux.hshell_integration_unittest.ccshell_integration_win_unittest.cc
spellchecker
ssl
storage_monitor
sync
sync_file_system
task_manager
task_profiler
themes
ui
app_list
ash
browser_browsertest.ccchrome_select_file_policy_unittest.cc
cocoa
extensions
gtk
hung_plugin_tab_helper.hmetro_pin_tab_helper_win.ccnetwork_profile_bubble.cc
startup
tabs
toolbar
views
webui
upgrade_detector_impl.ccuser_style_sheet_watcher.h
value_store
web_applications
webdata
common
installer
nacl
plugin
renderer
service
test
tools
convert_dict
crash_service
mac_helpers
perf
flush_cache
profiles
safe_browsing
chrome_frame
chromeos
cloud_print/service/win
components/visitedlink
content
app
browser
accessibility
appcache
browser_child_process_host_impl.ccchild_process_launcher.ccchild_process_security_policy_browsertest.ccchild_process_security_policy_impl.ccchild_process_security_policy_unittest.cc
device_orientation
devtools
dom_storage
download
fileapi
geolocation
gpu
hyphenator
in_process_webkit
loader
mime_registry_message_filter.hpepper_flash_settings_helper_impl.ccplugin_loader_posix_unittest.ccplugin_process_host.ccplugin_service_impl.ccpower_save_blocker_linux.ccppapi_plugin_process_host.ccppapi_plugin_process_host.h
renderer_host
safe_util_win.cc
speech
storage_partition_impl.hstorage_partition_impl_map.ccsystem_message_window_win_unittest.cc
web_contents
worker_host
common
gpu
plugin
public
renderer
shell
test
utility
zygote
courgette
crypto
device/bluetooth
gpu/tools/compositor_model_bench
ipc
media
net
android
base
disk_cache
dns
http
proxy
socket
test
tools
url_request
ppapi
printing
remoting
rlz
sandbox/linux/services
sql
sync
testing/android
third_party
leveldatabase
widevine
tools
ui
webkit
appcache
base
blob
chromeos
database
dom_storage
fileapi
glue
media
plugins
quota
support
tools
win8

@ -10,7 +10,7 @@
#include "android_webview/browser/aw_download_manager_delegate.h"
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/file_path.h"
#include "base/files/file_path.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "components/visitedlink/browser/visitedlink_delegate.h"

@ -7,7 +7,7 @@
#include "android_webview/browser/aw_browser_context.h"
#include "android_webview/browser/aw_result_codes.h"
#include "base/android/build_info.h"
#include "base/file_path.h"
#include "base/files/file_path.h"
#include "base/path_service.h"
#include "content/public/browser/android/compositor.h"
#include "content/public/browser/content_browser_client.h"

@ -4,7 +4,7 @@
#include "android_webview/browser/aw_download_manager_delegate.h"
#include "base/file_path.h"
#include "base/files/file_path.h"
#include "content/public/browser/download_danger_type.h"
#include "content/public/browser/download_item.h"

@ -8,7 +8,7 @@
#include "apps/app_host/update.h"
#include "base/at_exit.h"
#include "base/command_line.h"
#include "base/file_path.h"
#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/process_util.h"
#include "chrome/installer/launcher_support/chrome_launcher_support.h"

@ -6,7 +6,7 @@
#include "ash/shell/content_client/shell_content_browser_client.h"
#include "base/command_line.h"
#include "base/file_path.h"
#include "base/files/file_path.h"
#include "base/path_service.h"
#include "content/public/common/content_switches.h"
#include "ui/base/resource/resource_bundle.h"

@ -11,7 +11,7 @@
#include "ash/ash_export.h"
#include "ash/system/power/power_supply_status.h"
#include "ash/system/user/login_status.h"
#include "base/file_path.h"
#include "base/files/file_path.h"
#include "base/i18n/time_formatting.h"
#include "base/memory/scoped_ptr.h"
#include "base/string16.h"

@ -8,8 +8,8 @@
#include <shlobj.h>
#include "base/command_line.h"
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/files/file_path.h"
#include "base/string16.h"
#include "base/time.h"
#include "base/win/scoped_com_initializer.h"

@ -4,7 +4,7 @@
#include "ash/test/test_suite.h"
#include "base/file_path.h"
#include "base/files/file_path.h"
#include "base/path_service.h"
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"

@ -6,7 +6,7 @@
#import <Cocoa/Cocoa.h>
#include "base/file_path.h"
#include "base/files/file_path.h"
#include "base/mac/bundle_locations.h"
#include "base/memory/scoped_nsobject.h"
#include "base/path_service.h"

@ -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 {

@ -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"

@ -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"

@ -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',

@ -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',

@ -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 {

@ -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"

@ -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"

@ -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)

@ -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"

@ -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"

@ -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"

@ -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"

@ -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;

@ -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"

@ -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 {

@ -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>

@ -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"

@ -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"

@ -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"

@ -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"

@ -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"

@ -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"

@ -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>

442
base/files/file_path.h Normal file

@ -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_

@ -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"

@ -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"

@ -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"

@ -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"

@ -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"

@ -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"

@ -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"

@ -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"

@ -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"

@ -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 {

@ -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"

@ -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"

@ -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"

@ -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"

@ -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"

@ -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 {

@ -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 {

@ -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>

@ -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"

@ -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"

@ -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"

@ -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"

@ -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"

@ -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"

@ -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 {

@ -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"

@ -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"

@ -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;

@ -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 {

@ -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"

@ -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"

@ -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"

@ -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"

@ -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"

@ -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"

@ -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)

@ -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>

@ -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"

@ -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 {

@ -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"

@ -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"

@ -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"

@ -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;

@ -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 {

@ -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"

@ -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"

@ -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"

@ -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.

@ -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"

@ -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"

@ -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"

@ -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"

@ -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"

@ -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 {

@ -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 {

@ -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"

@ -4,8 +4,8 @@
#include "cc/layer_tree_host.h"
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/files/file_path.h"
#include "base/path_service.h"
#include "base/string_piece.h"
#include "cc/content_layer.h"

@ -4,8 +4,8 @@
#include "cc/test/paths.h"
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/files/file_path.h"
#include "base/path_service.h"
namespace cc {

@ -5,7 +5,7 @@
#ifndef CC_TEST_PIXEL_TEST_UTILS_H_
#define CC_TEST_PIXEL_TEST_UTILS_H_
#include "base/file_path.h"
#include "base/files/file_path.h"
class SkBitmap;

@ -13,8 +13,8 @@
#include <CoreFoundation/CoreFoundation.h>
#import <Foundation/Foundation.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/mac/scoped_nsautorelease_pool.h"

@ -15,8 +15,8 @@
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/uio.h>
#include <sys/wait.h>
#include <time.h>
#include <unistd.h>
@ -24,7 +24,7 @@
#include <string>
#include "base/command_line.h"
#include "base/file_path.h"
#include "base/files/file_path.h"
#include "base/linux_util.h"
#include "base/path_service.h"
#include "base/platform_file.h"

@ -12,8 +12,8 @@
#import "base/basictypes.h"
#include "base/command_line.h"
#include "base/debug/crash_logging.h"
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/files/file_path.h"
#import "base/logging.h"
#include "base/mac/bundle_locations.h"
#include "base/mac/mac_util.h"

@ -8,7 +8,7 @@
// those app bundles.
#include "base/basictypes.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"

@ -9,7 +9,7 @@
#include <string>
#include "base/basictypes.h"
#include "base/file_path.h"
#include "base/files/file_path.h"
#include "base/logging.h"
#import "base/mac/bundle_locations.h"
#import "base/mac/foundation_util.h"

@ -13,7 +13,7 @@
#include "base/basictypes.h"
#include "base/command_line.h"
#include "base/file_path.h"
#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/path_service.h"
#include "base/posix/eintr_wrapper.h"

@ -7,7 +7,7 @@
#include <map>
#include "base/file_path.h"
#include "base/files/file_path.h"
#include "base/platform_file.h"
#include "base/process.h"
#include "base/synchronization/lock.h"

Some files were not shown because too many files have changed in this diff Show More