diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-08-13 20:22:14 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-08-13 20:23:37 +0000 |
commit | e3177dd5063e419cb181cf6a45d3ff94cb0feebd (patch) | |
tree | 9eb2bd0b85941a0586a1a7185ed151689a0032f9 | |
parent | 7fa443fda5ddbf8e83e1967931f115f5394d16aa (diff) | |
download | chromium_src-e3177dd5063e419cb181cf6a45d3ff94cb0feebd.zip chromium_src-e3177dd5063e419cb181cf6a45d3ff94cb0feebd.tar.gz chromium_src-e3177dd5063e419cb181cf6a45d3ff94cb0feebd.tar.bz2 |
Move file_util to base/files/ directory.
This updates the includes in base but leaves a forwarding header for the rest of the project for now.
R=yzshen@chromium.org
Review URL: https://codereview.chromium.org/468253002
Cr-Commit-Position: refs/heads/master@{#289360}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@289360 0039d316-1c4b-4281-b951-d872f2087c98
85 files changed, 546 insertions, 540 deletions
diff --git a/base/BUILD.gn b/base/BUILD.gn index 7954972..9952af0 100644 --- a/base/BUILD.gn +++ b/base/BUILD.gn @@ -173,13 +173,6 @@ component("base") { "event_recorder.h", "event_recorder_win.cc", "file_descriptor_posix.h", - "file_util.cc", - "file_util.h", - "file_util_android.cc", - "file_util_linux.cc", - "file_util_mac.mm", - "file_util_posix.cc", - "file_util_win.cc", "file_version_info.h", "file_version_info_mac.h", "file_version_info_mac.mm", @@ -209,8 +202,15 @@ component("base") { "files/file_path_watcher_win.cc", "files/file_proxy.cc", "files/file_proxy.h", + "files/file_util.cc", + "files/file_util.h", + "files/file_util_android.cc", + "files/file_util_linux.cc", + "files/file_util_mac.mm", + "files/file_util_posix.cc", "files/file_util_proxy.cc", "files/file_util_proxy.h", + "files/file_util_win.cc", "files/important_file_writer.cc", "files/important_file_writer.h", "files/memory_mapped_file.cc", @@ -799,7 +799,7 @@ component("base") { sources -= [ "debug/stack_trace_posix.cc", "files/file_enumerator_posix.cc", - "file_util_posix.cc", + "files/file_util_posix.cc", "message_loop/message_pump_libevent.cc", "process/kill_posix.cc", "process/launch_posix.cc", @@ -1084,13 +1084,13 @@ test("base_unittests") { "debug/trace_event_win_unittest.cc", "deferred_sequenced_task_runner_unittest.cc", "environment_unittest.cc", - "file_util_unittest.cc", "file_version_info_unittest.cc", "files/dir_reader_posix_unittest.cc", "files/file_path_unittest.cc", "files/file_proxy_unittest.cc", "files/file_unittest.cc", "files/file_util_proxy_unittest.cc", + "files/file_util_unittest.cc", "files/important_file_writer_unittest.cc", "files/scoped_temp_dir_unittest.cc", "gmock_unittest.cc", diff --git a/base/android/path_utils_unittest.cc b/base/android/path_utils_unittest.cc index b641075..c678ce2 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_util.h" #include "base/files/file_path.h" +#include "base/files/file_util.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/base/base.gyp b/base/base.gyp index 9c0c203..ce2c54f 100644 --- a/base/base.gyp +++ b/base/base.gyp @@ -456,13 +456,13 @@ 'debug/trace_event_win_unittest.cc', 'deferred_sequenced_task_runner_unittest.cc', 'environment_unittest.cc', - 'file_util_unittest.cc', 'file_version_info_unittest.cc', 'files/dir_reader_posix_unittest.cc', 'files/file_path_unittest.cc', 'files/file_proxy_unittest.cc', 'files/file_unittest.cc', 'files/file_util_proxy_unittest.cc', + 'files/file_util_unittest.cc', 'files/important_file_writer_unittest.cc', 'files/memory_mapped_file_unittest.cc', 'files/scoped_temp_dir_unittest.cc', diff --git a/base/base.gypi b/base/base.gypi index fd64aef..bf8bd59 100644 --- a/base/base.gypi +++ b/base/base.gypi @@ -176,13 +176,6 @@ 'environment.cc', 'environment.h', 'file_descriptor_posix.h', - 'file_util.cc', - 'file_util.h', - 'file_util_android.cc', - 'file_util_linux.cc', - 'file_util_mac.mm', - 'file_util_posix.cc', - 'file_util_win.cc', 'file_version_info.h', 'file_version_info_mac.h', 'file_version_info_mac.mm', @@ -213,8 +206,15 @@ 'files/file_posix.cc', 'files/file_proxy.cc', 'files/file_proxy.h', + 'files/file_util.cc', + 'files/file_util.h', + 'files/file_util_android.cc', + 'files/file_util_linux.cc', + 'files/file_util_mac.mm', + 'files/file_util_posix.cc', 'files/file_util_proxy.cc', 'files/file_util_proxy.h', + 'files/file_util_win.cc', 'files/file_win.cc', 'files/important_file_writer.h', 'files/important_file_writer.cc', @@ -756,14 +756,14 @@ 'base_paths.cc', 'cpu.cc', 'debug/stack_trace_posix.cc', - 'file_util.cc', - 'file_util_posix.cc', 'files/file_enumerator_posix.cc', 'files/file_path_watcher_fsevents.cc', 'files/file_path_watcher_fsevents.h', 'files/file_path_watcher_kqueue.cc', 'files/file_path_watcher_kqueue.h', 'files/file_proxy.cc', + 'files/file_util.cc', + 'files/file_util_posix.cc', 'files/file_util_proxy.cc', 'memory/shared_memory_posix.cc', 'native_library_posix.cc', @@ -839,7 +839,7 @@ # by file name rules). ['include', '^atomicops_internals_mac\\.'], ['include', '^base_paths_mac\\.'], - ['include', '^file_util_mac\\.'], + ['include', '^files/file_util_mac\\.'], ['include', '^file_version_info_mac\\.'], ['include', '^mac/bundle_locations\\.'], ['include', '^mac/foundation_util\\.'], @@ -943,7 +943,7 @@ 'sources/': [ ['exclude', '^files/file_path_watcher_linux\\.cc$'], ['exclude', '^files/file_path_watcher_stub\\.cc$'], - ['exclude', '^file_util_linux\\.cc$'], + ['exclude', '^files/file_util_linux\\.cc$'], ['exclude', '^process/process_linux\\.cc$'], ['exclude', '^sys_info_linux\\.cc$'], ], diff --git a/base/base_paths.cc b/base/base_paths.cc index 1b99e85..7076ec3 100644 --- a/base/base_paths.cc +++ b/base/base_paths.cc @@ -4,8 +4,8 @@ #include "base/base_paths.h" -#include "base/file_util.h" #include "base/files/file_path.h" +#include "base/files/file_util.h" #include "base/path_service.h" namespace base { diff --git a/base/base_paths_android.cc b/base/base_paths_android.cc index 27be24e..56c6cc70 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_util.h" #include "base/files/file_path.h" +#include "base/files/file_util.h" #include "base/logging.h" #include "base/process/process_metrics.h" diff --git a/base/base_paths_mac.mm b/base/base_paths_mac.mm index 3930c44..9864eb3 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_util.h" #include "base/files/file_path.h" +#include "base/files/file_util.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 cf136d4..048434f 100644 --- a/base/base_paths_posix.cc +++ b/base/base_paths_posix.cc @@ -11,8 +11,8 @@ #include "base/base_paths.h" #include "base/environment.h" -#include "base/file_util.h" #include "base/files/file_path.h" +#include "base/files/file_util.h" #include "base/logging.h" #include "base/memory/scoped_ptr.h" #include "base/nix/xdg_util.h" diff --git a/base/cpu.cc b/base/cpu.cc index a6a6128..ef3309d 100644 --- a/base/cpu.cc +++ b/base/cpu.cc @@ -14,7 +14,7 @@ #include "build/build_config.h" #if defined(ARCH_CPU_ARM_FAMILY) && (defined(OS_ANDROID) || defined(OS_LINUX)) -#include "base/file_util.h" +#include "base/files/file_util.h" #include "base/lazy_instance.h" #endif diff --git a/base/debug/proc_maps_linux.cc b/base/debug/proc_maps_linux.cc index 1e0209e..4c1aedf 100644 --- a/base/debug/proc_maps_linux.cc +++ b/base/debug/proc_maps_linux.cc @@ -10,7 +10,7 @@ #include <inttypes.h> #endif -#include "base/file_util.h" +#include "base/files/file_util.h" #include "base/files/scoped_file.h" #include "base/strings/string_split.h" diff --git a/base/debug/trace_event_win_unittest.cc b/base/debug/trace_event_win_unittest.cc index a79e9a1..3782645 100644 --- a/base/debug/trace_event_win_unittest.cc +++ b/base/debug/trace_event_win_unittest.cc @@ -8,9 +8,9 @@ #include "base/at_exit.h" #include "base/basictypes.h" -#include "base/file_util.h" #include "base/debug/trace_event.h" #include "base/debug/trace_event_win.h" +#include "base/files/file_util.h" #include "base/win/event_trace_consumer.h" #include "base/win/event_trace_controller.h" #include "base/win/event_trace_provider.h" diff --git a/base/event_recorder_win.cc b/base/event_recorder_win.cc index 39c4220..b3076a1 100644 --- a/base/event_recorder_win.cc +++ b/base/event_recorder_win.cc @@ -7,7 +7,7 @@ #include <mmsystem.h> #include "base/event_recorder.h" -#include "base/file_util.h" +#include "base/files/file_util.h" #include "base/logging.h" // A note about time. diff --git a/base/file_util.h b/base/file_util.h index ab1432d..9760a34 100644 --- a/base/file_util.h +++ b/base/file_util.h @@ -1,439 +1,6 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright 2014 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. -// This file contains utility functions for dealing with the local -// filesystem. - -#ifndef BASE_FILE_UTIL_H_ -#define BASE_FILE_UTIL_H_ - -#include "build/build_config.h" - -#if defined(OS_WIN) -#include <windows.h> -#elif defined(OS_POSIX) -#include <sys/stat.h> -#include <unistd.h> -#endif - -#include <stdio.h> - -#include <set> -#include <string> -#include <vector> - -#include "base/base_export.h" -#include "base/basictypes.h" -#include "base/files/file.h" -#include "base/files/file_path.h" -#include "base/memory/scoped_ptr.h" -#include "base/strings/string16.h" - -#if defined(OS_POSIX) -#include "base/file_descriptor_posix.h" -#include "base/logging.h" -#include "base/posix/eintr_wrapper.h" -#endif - -namespace base { - -class Time; - -//----------------------------------------------------------------------------- -// Functions that involve filesystem access or modification: - -// Returns an absolute version of a relative path. Returns an empty path on -// error. On POSIX, this function fails if the path does not exist. This -// function can result in I/O so it can be slow. -BASE_EXPORT FilePath MakeAbsoluteFilePath(const FilePath& input); - -// Returns the total number of bytes used by all the files under |root_path|. -// If the path does not exist the function returns 0. -// -// This function is implemented using the FileEnumerator class so it is not -// particularly speedy in any platform. -BASE_EXPORT int64 ComputeDirectorySize(const FilePath& root_path); - -// Deletes the given path, whether it's a file or a directory. -// If it's a directory, it's perfectly happy to delete all of the -// directory's contents. Passing true to recursive deletes -// subdirectories and their contents as well. -// Returns true if successful, false otherwise. It is considered successful -// to attempt to delete a file that does not exist. -// -// In posix environment and if |path| is a symbolic link, this deletes only -// the symlink. (even if the symlink points to a non-existent file) -// -// WARNING: USING THIS WITH recursive==true IS EQUIVALENT -// TO "rm -rf", SO USE WITH CAUTION. -BASE_EXPORT bool DeleteFile(const FilePath& path, bool recursive); - -#if defined(OS_WIN) -// Schedules to delete the given path, whether it's a file or a directory, until -// the operating system is restarted. -// Note: -// 1) The file/directory to be deleted should exist in a temp folder. -// 2) The directory to be deleted must be empty. -BASE_EXPORT bool DeleteFileAfterReboot(const FilePath& path); -#endif - -// Moves the given path, whether it's a file or a directory. -// If a simple rename is not possible, such as in the case where the paths are -// on different volumes, this will attempt to copy and delete. Returns -// true for success. -// This function fails if either path contains traversal components ('..'). -BASE_EXPORT bool Move(const FilePath& from_path, const FilePath& to_path); - -// Renames file |from_path| to |to_path|. Both paths must be on the same -// volume, or the function will fail. Destination file will be created -// if it doesn't exist. Prefer this function over Move when dealing with -// temporary files. On Windows it preserves attributes of the target file. -// Returns true on success, leaving *error unchanged. -// Returns false on failure and sets *error appropriately, if it is non-NULL. -BASE_EXPORT bool ReplaceFile(const FilePath& from_path, - const FilePath& to_path, - File::Error* error); - -// Copies a single file. Use CopyDirectory to copy directories. -// This function fails if either path contains traversal components ('..'). -// -// This function keeps the metadata on Windows. The read only bit on Windows is -// not kept. -BASE_EXPORT bool CopyFile(const FilePath& from_path, const FilePath& to_path); - -// Copies the given path, and optionally all subdirectories and their contents -// as well. -// -// If there are files existing under to_path, always overwrite. Returns true -// if successful, false otherwise. Wildcards on the names are not supported. -// -// This function calls into CopyFile() so the same behavior w.r.t. metadata -// applies. -// -// If you only need to copy a file use CopyFile, it's faster. -BASE_EXPORT bool CopyDirectory(const FilePath& from_path, - const FilePath& to_path, - bool recursive); - -// Returns true if the given path exists on the local filesystem, -// false otherwise. -BASE_EXPORT bool PathExists(const FilePath& path); - -// Returns true if the given path is writable by the user, false otherwise. -BASE_EXPORT bool PathIsWritable(const FilePath& path); - -// Returns true if the given path exists and is a directory, false otherwise. -BASE_EXPORT bool DirectoryExists(const FilePath& path); - -// Returns true if the contents of the two files given are equal, false -// otherwise. If either file can't be read, returns false. -BASE_EXPORT bool ContentsEqual(const FilePath& filename1, - const FilePath& filename2); - -// Returns true if the contents of the two text files given are equal, false -// otherwise. This routine treats "\r\n" and "\n" as equivalent. -BASE_EXPORT bool TextContentsEqual(const FilePath& filename1, - const FilePath& filename2); - -// Reads the file at |path| into |contents| and returns true on success and -// false on error. For security reasons, a |path| containing path traversal -// components ('..') is treated as a read error and |contents| is set to empty. -// In case of I/O error, |contents| holds the data that could be read from the -// file before the error occurred. -// |contents| may be NULL, in which case this function is useful for its side -// effect of priming the disk cache (could be used for unit tests). -BASE_EXPORT bool ReadFileToString(const FilePath& path, std::string* contents); - -// Reads the file at |path| into |contents| and returns true on success and -// false on error. For security reasons, a |path| containing path traversal -// components ('..') is treated as a read error and |contents| is set to empty. -// In case of I/O error, |contents| holds the data that could be read from the -// file before the error occurred. When the file size exceeds |max_size|, the -// function returns false with |contents| holding the file truncated to -// |max_size|. -// |contents| may be NULL, in which case this function is useful for its side -// effect of priming the disk cache (could be used for unit tests). -BASE_EXPORT bool ReadFileToString(const FilePath& path, - std::string* contents, - size_t max_size); - -#if defined(OS_POSIX) - -// Read exactly |bytes| bytes from file descriptor |fd|, storing the result -// in |buffer|. This function is protected against EINTR and partial reads. -// Returns true iff |bytes| bytes have been successfully read from |fd|. -BASE_EXPORT bool ReadFromFD(int fd, char* buffer, size_t bytes); - -// Creates a symbolic link at |symlink| pointing to |target|. Returns -// false on failure. -BASE_EXPORT bool CreateSymbolicLink(const FilePath& target, - const FilePath& symlink); - -// Reads the given |symlink| and returns where it points to in |target|. -// Returns false upon failure. -BASE_EXPORT bool ReadSymbolicLink(const FilePath& symlink, FilePath* target); - -// Bits and masks of the file permission. -enum FilePermissionBits { - FILE_PERMISSION_MASK = S_IRWXU | S_IRWXG | S_IRWXO, - FILE_PERMISSION_USER_MASK = S_IRWXU, - FILE_PERMISSION_GROUP_MASK = S_IRWXG, - FILE_PERMISSION_OTHERS_MASK = S_IRWXO, - - FILE_PERMISSION_READ_BY_USER = S_IRUSR, - FILE_PERMISSION_WRITE_BY_USER = S_IWUSR, - FILE_PERMISSION_EXECUTE_BY_USER = S_IXUSR, - FILE_PERMISSION_READ_BY_GROUP = S_IRGRP, - FILE_PERMISSION_WRITE_BY_GROUP = S_IWGRP, - FILE_PERMISSION_EXECUTE_BY_GROUP = S_IXGRP, - FILE_PERMISSION_READ_BY_OTHERS = S_IROTH, - FILE_PERMISSION_WRITE_BY_OTHERS = S_IWOTH, - FILE_PERMISSION_EXECUTE_BY_OTHERS = S_IXOTH, -}; - -// Reads the permission of the given |path|, storing the file permission -// bits in |mode|. If |path| is symbolic link, |mode| is the permission of -// a file which the symlink points to. -BASE_EXPORT bool GetPosixFilePermissions(const FilePath& path, int* mode); -// Sets the permission of the given |path|. If |path| is symbolic link, sets -// the permission of a file which the symlink points to. -BASE_EXPORT bool SetPosixFilePermissions(const FilePath& path, int mode); - -#endif // OS_POSIX - -// Returns true if the given directory is empty -BASE_EXPORT bool IsDirectoryEmpty(const FilePath& dir_path); - -// Get the temporary directory provided by the system. -// -// WARNING: In general, you should use CreateTemporaryFile variants below -// instead of this function. Those variants will ensure that the proper -// permissions are set so that other users on the system can't edit them while -// they're open (which can lead to security issues). -BASE_EXPORT bool GetTempDir(FilePath* path); - -// Get the home directory. This is more complicated than just getenv("HOME") -// as it knows to fall back on getpwent() etc. -// -// You should not generally call this directly. Instead use DIR_HOME with the -// path service which will use this function but cache the value. -// Path service may also override DIR_HOME. -BASE_EXPORT FilePath GetHomeDir(); - -// Creates a temporary file. The full path is placed in |path|, and the -// function returns true if was successful in creating the file. The file will -// be empty and all handles closed after this function returns. -BASE_EXPORT bool CreateTemporaryFile(FilePath* path); - -// Same as CreateTemporaryFile but the file is created in |dir|. -BASE_EXPORT bool CreateTemporaryFileInDir(const FilePath& dir, - FilePath* temp_file); - -// Create and open a temporary file. File is opened for read/write. -// The full path is placed in |path|. -// Returns a handle to the opened file or NULL if an error occurred. -BASE_EXPORT FILE* CreateAndOpenTemporaryFile(FilePath* path); - -// Similar to CreateAndOpenTemporaryFile, but the file is created in |dir|. -BASE_EXPORT FILE* CreateAndOpenTemporaryFileInDir(const FilePath& dir, - FilePath* path); - -// Create a new directory. If prefix is provided, the new directory name is in -// the format of prefixyyyy. -// NOTE: prefix is ignored in the POSIX implementation. -// If success, return true and output the full path of the directory created. -BASE_EXPORT bool CreateNewTempDirectory(const FilePath::StringType& prefix, - FilePath* new_temp_path); - -// Create a directory within another directory. -// Extra characters will be appended to |prefix| to ensure that the -// new directory does not have the same name as an existing directory. -BASE_EXPORT bool CreateTemporaryDirInDir(const FilePath& base_dir, - const FilePath::StringType& prefix, - FilePath* new_dir); - -// Creates a directory, as well as creating any parent directories, if they -// don't exist. Returns 'true' on successful creation, or if the directory -// already exists. The directory is only readable by the current user. -// Returns true on success, leaving *error unchanged. -// Returns false on failure and sets *error appropriately, if it is non-NULL. -BASE_EXPORT bool CreateDirectoryAndGetError(const FilePath& full_path, - File::Error* error); - -// Backward-compatible convenience method for the above. -BASE_EXPORT bool CreateDirectory(const FilePath& full_path); - -// Returns the file size. Returns true on success. -BASE_EXPORT bool GetFileSize(const FilePath& file_path, int64* file_size); - -// Sets |real_path| to |path| with symbolic links and junctions expanded. -// On windows, make sure the path starts with a lettered drive. -// |path| must reference a file. Function will fail if |path| points to -// a directory or to a nonexistent path. On windows, this function will -// fail if |path| is a junction or symlink that points to an empty file, -// or if |real_path| would be longer than MAX_PATH characters. -BASE_EXPORT bool NormalizeFilePath(const FilePath& path, FilePath* real_path); - -#if defined(OS_WIN) - -// Given a path in NT native form ("\Device\HarddiskVolumeXX\..."), -// return in |drive_letter_path| the equivalent path that starts with -// a drive letter ("C:\..."). Return false if no such path exists. -BASE_EXPORT bool DevicePathToDriveLetterPath(const FilePath& device_path, - FilePath* drive_letter_path); - -// Given an existing file in |path|, set |real_path| to the path -// in native NT format, of the form "\Device\HarddiskVolumeXX\..". -// Returns false if the path can not be found. Empty files cannot -// be resolved with this function. -BASE_EXPORT bool NormalizeToNativeFilePath(const FilePath& path, - FilePath* nt_path); -#endif - -// This function will return if the given file is a symlink or not. -BASE_EXPORT bool IsLink(const FilePath& file_path); - -// Returns information about the given file path. -BASE_EXPORT bool GetFileInfo(const FilePath& file_path, File::Info* info); - -// Sets the time of the last access and the time of the last modification. -BASE_EXPORT bool TouchFile(const FilePath& path, - const Time& last_accessed, - const Time& last_modified); - -// Wrapper for fopen-like calls. Returns non-NULL FILE* on success. -BASE_EXPORT FILE* OpenFile(const FilePath& filename, const char* mode); - -// Closes file opened by OpenFile. Returns true on success. -BASE_EXPORT bool CloseFile(FILE* file); - -// Associates a standard FILE stream with an existing File. Note that this -// functions take ownership of the existing File. -BASE_EXPORT FILE* FileToFILE(File file, const char* mode); - -// Truncates an open file to end at the location of the current file pointer. -// This is a cross-platform analog to Windows' SetEndOfFile() function. -BASE_EXPORT bool TruncateFile(FILE* file); - -// Reads at most the given number of bytes from the file into the buffer. -// Returns the number of read bytes, or -1 on error. -BASE_EXPORT int ReadFile(const FilePath& filename, char* data, int max_size); - -// Writes the given buffer into the file, overwriting any data that was -// previously there. Returns the number of bytes written, or -1 on error. -BASE_EXPORT int WriteFile(const FilePath& filename, const char* data, - int size); - -#if defined(OS_POSIX) -// Append the data to |fd|. Does not close |fd| when done. -BASE_EXPORT int WriteFileDescriptor(const int fd, const char* data, int size); -#endif - -// Append the given buffer into the file. Returns the number of bytes written, -// or -1 on error. -BASE_EXPORT int AppendToFile(const FilePath& filename, - const char* data, int size); - -// Gets the current working directory for the process. -BASE_EXPORT bool GetCurrentDirectory(FilePath* path); - -// Sets the current working directory for the process. -BASE_EXPORT bool SetCurrentDirectory(const FilePath& path); - -// Attempts to find a number that can be appended to the |path| to make it -// unique. If |path| does not exist, 0 is returned. If it fails to find such -// a number, -1 is returned. If |suffix| is not empty, also checks the -// existence of it with the given suffix. -BASE_EXPORT int GetUniquePathNumber(const FilePath& path, - const FilePath::StringType& suffix); - -#if defined(OS_POSIX) -// Test that |path| can only be changed by a given user and members of -// a given set of groups. -// Specifically, test that all parts of |path| under (and including) |base|: -// * Exist. -// * Are owned by a specific user. -// * Are not writable by all users. -// * Are owned by a member of a given set of groups, or are not writable by -// their group. -// * Are not symbolic links. -// This is useful for checking that a config file is administrator-controlled. -// |base| must contain |path|. -BASE_EXPORT bool VerifyPathControlledByUser(const base::FilePath& base, - const base::FilePath& path, - uid_t owner_uid, - const std::set<gid_t>& group_gids); -#endif // defined(OS_POSIX) - -#if defined(OS_MACOSX) && !defined(OS_IOS) -// Is |path| writable only by a user with administrator privileges? -// This function uses Mac OS conventions. The super user is assumed to have -// uid 0, and the administrator group is assumed to be named "admin". -// Testing that |path|, and every parent directory including the root of -// the filesystem, are owned by the superuser, controlled by the group -// "admin", are not writable by all users, and contain no symbolic links. -// Will return false if |path| does not exist. -BASE_EXPORT bool VerifyPathControlledByAdmin(const base::FilePath& path); -#endif // defined(OS_MACOSX) && !defined(OS_IOS) - -// Returns the maximum length of path component on the volume containing -// the directory |path|, in the number of FilePath::CharType, or -1 on failure. -BASE_EXPORT int GetMaximumPathComponentLength(const base::FilePath& path); - -#if defined(OS_LINUX) -// Broad categories of file systems as returned by statfs() on Linux. -enum FileSystemType { - FILE_SYSTEM_UNKNOWN, // statfs failed. - FILE_SYSTEM_0, // statfs.f_type == 0 means unknown, may indicate AFS. - FILE_SYSTEM_ORDINARY, // on-disk filesystem like ext2 - FILE_SYSTEM_NFS, - FILE_SYSTEM_SMB, - FILE_SYSTEM_CODA, - FILE_SYSTEM_MEMORY, // in-memory file system - FILE_SYSTEM_CGROUP, // cgroup control. - FILE_SYSTEM_OTHER, // any other value. - FILE_SYSTEM_TYPE_COUNT -}; - -// Attempts determine the FileSystemType for |path|. -// Returns false if |path| doesn't exist. -BASE_EXPORT bool GetFileSystemType(const FilePath& path, FileSystemType* type); -#endif - -#if defined(OS_POSIX) -// Get a temporary directory for shared memory files. The directory may depend -// on whether the destination is intended for executable files, which in turn -// depends on how /dev/shmem was mounted. As a result, you must supply whether -// you intend to create executable shmem segments so this function can find -// an appropriate location. -BASE_EXPORT bool GetShmemTempDir(bool executable, FilePath* path); -#endif - -// Internal -------------------------------------------------------------------- - -namespace internal { - -// Same as Move but allows paths with traversal components. -// Use only with extreme care. -BASE_EXPORT bool MoveUnsafe(const FilePath& from_path, - const FilePath& to_path); - -// Same as CopyFile but allows paths with traversal components. -// Use only with extreme care. -BASE_EXPORT bool CopyFileUnsafe(const FilePath& from_path, - const FilePath& to_path); - -#if defined(OS_WIN) -// Copy from_path to to_path recursively and then delete from_path recursively. -// Returns true if all operations succeed. -// This function simulates Move(), but unlike Move() it works across volumes. -// This function is not transactional. -BASE_EXPORT bool CopyAndDeleteDirectory(const FilePath& from_path, - const FilePath& to_path); -#endif // defined(OS_WIN) - -} // namespace internal -} // namespace base - -#endif // BASE_FILE_UTIL_H_ +// TODO(brettw) update callers to use the new location and remove this file. +#include "base/files/file_util.h" diff --git a/base/files/file_enumerator.cc b/base/files/file_enumerator.cc index e49f465..9749980 100644 --- a/base/files/file_enumerator.cc +++ b/base/files/file_enumerator.cc @@ -4,7 +4,7 @@ #include "base/files/file_enumerator.h" -#include "base/file_util.h" +#include "base/files/file_util.h" namespace base { diff --git a/base/files/file_path_watcher_browsertest.cc b/base/files/file_path_watcher_browsertest.cc index ff6d9d5..5cf75fc 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_util.h" #include "base/files/file_path.h" +#include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" #include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop_proxy.h" diff --git a/base/files/file_path_watcher_fsevents.cc b/base/files/file_path_watcher_fsevents.cc index edf4d23..f658efe 100644 --- a/base/files/file_path_watcher_fsevents.cc +++ b/base/files/file_path_watcher_fsevents.cc @@ -7,7 +7,7 @@ #include <list> #include "base/bind.h" -#include "base/file_util.h" +#include "base/files/file_util.h" #include "base/lazy_instance.h" #include "base/logging.h" #include "base/mac/libdispatch_task_runner.h" diff --git a/base/files/file_path_watcher_kqueue.cc b/base/files/file_path_watcher_kqueue.cc index c38e344..8941d2e 100644 --- a/base/files/file_path_watcher_kqueue.cc +++ b/base/files/file_path_watcher_kqueue.cc @@ -8,7 +8,7 @@ #include <sys/param.h> #include "base/bind.h" -#include "base/file_util.h" +#include "base/files/file_util.h" #include "base/logging.h" #include "base/strings/stringprintf.h" diff --git a/base/files/file_path_watcher_linux.cc b/base/files/file_path_watcher_linux.cc index 915ad50..26eafb3 100644 --- a/base/files/file_path_watcher_linux.cc +++ b/base/files/file_path_watcher_linux.cc @@ -20,9 +20,9 @@ #include "base/bind.h" #include "base/containers/hash_tables.h" #include "base/debug/trace_event.h" -#include "base/file_util.h" #include "base/files/file_enumerator.h" #include "base/files/file_path.h" +#include "base/files/file_util.h" #include "base/lazy_instance.h" #include "base/location.h" #include "base/logging.h" diff --git a/base/files/file_path_watcher_win.cc b/base/files/file_path_watcher_win.cc index ec2fe6d..a3021404 100644 --- a/base/files/file_path_watcher_win.cc +++ b/base/files/file_path_watcher_win.cc @@ -5,9 +5,9 @@ #include "base/files/file_path_watcher.h" #include "base/bind.h" -#include "base/file_util.h" #include "base/files/file.h" #include "base/files/file_path.h" +#include "base/files/file_util.h" #include "base/logging.h" #include "base/memory/ref_counted.h" #include "base/message_loop/message_loop_proxy.h" diff --git a/base/files/file_proxy.cc b/base/files/file_proxy.cc index 291b98d..53b14fe 100644 --- a/base/files/file_proxy.cc +++ b/base/files/file_proxy.cc @@ -6,8 +6,8 @@ #include "base/bind.h" #include "base/bind_helpers.h" -#include "base/file_util.h" #include "base/files/file.h" +#include "base/files/file_util.h" #include "base/location.h" #include "base/message_loop/message_loop_proxy.h" #include "base/task_runner.h" diff --git a/base/files/file_proxy_unittest.cc b/base/files/file_proxy_unittest.cc index 9be8abf..2c62fa9 100644 --- a/base/files/file_proxy_unittest.cc +++ b/base/files/file_proxy_unittest.cc @@ -5,8 +5,8 @@ #include "base/files/file_proxy.h" #include "base/bind.h" -#include "base/file_util.h" #include "base/files/file.h" +#include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" #include "base/memory/weak_ptr.h" #include "base/message_loop/message_loop.h" diff --git a/base/files/file_unittest.cc b/base/files/file_unittest.cc index de88145..6616f6a 100644 --- a/base/files/file_unittest.cc +++ b/base/files/file_unittest.cc @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/file_util.h" #include "base/files/file.h" +#include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" #include "base/time/time.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/base/file_util.cc b/base/files/file_util.cc index d11cd15..96a7164 100644 --- a/base/file_util.cc +++ b/base/files/file_util.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_util.h" +#include "base/files/file_util.h" #if defined(OS_WIN) #include <io.h> diff --git a/base/files/file_util.h b/base/files/file_util.h new file mode 100644 index 0000000..feebeed --- /dev/null +++ b/base/files/file_util.h @@ -0,0 +1,439 @@ +// 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. + +// This file contains utility functions for dealing with the local +// filesystem. + +#ifndef BASE_FILES_FILE_UTIL_H_ +#define BASE_FILES_FILE_UTIL_H_ + +#include "build/build_config.h" + +#if defined(OS_WIN) +#include <windows.h> +#elif defined(OS_POSIX) +#include <sys/stat.h> +#include <unistd.h> +#endif + +#include <stdio.h> + +#include <set> +#include <string> +#include <vector> + +#include "base/base_export.h" +#include "base/basictypes.h" +#include "base/files/file.h" +#include "base/files/file_path.h" +#include "base/memory/scoped_ptr.h" +#include "base/strings/string16.h" + +#if defined(OS_POSIX) +#include "base/file_descriptor_posix.h" +#include "base/logging.h" +#include "base/posix/eintr_wrapper.h" +#endif + +namespace base { + +class Time; + +//----------------------------------------------------------------------------- +// Functions that involve filesystem access or modification: + +// Returns an absolute version of a relative path. Returns an empty path on +// error. On POSIX, this function fails if the path does not exist. This +// function can result in I/O so it can be slow. +BASE_EXPORT FilePath MakeAbsoluteFilePath(const FilePath& input); + +// Returns the total number of bytes used by all the files under |root_path|. +// If the path does not exist the function returns 0. +// +// This function is implemented using the FileEnumerator class so it is not +// particularly speedy in any platform. +BASE_EXPORT int64 ComputeDirectorySize(const FilePath& root_path); + +// Deletes the given path, whether it's a file or a directory. +// If it's a directory, it's perfectly happy to delete all of the +// directory's contents. Passing true to recursive deletes +// subdirectories and their contents as well. +// Returns true if successful, false otherwise. It is considered successful +// to attempt to delete a file that does not exist. +// +// In posix environment and if |path| is a symbolic link, this deletes only +// the symlink. (even if the symlink points to a non-existent file) +// +// WARNING: USING THIS WITH recursive==true IS EQUIVALENT +// TO "rm -rf", SO USE WITH CAUTION. +BASE_EXPORT bool DeleteFile(const FilePath& path, bool recursive); + +#if defined(OS_WIN) +// Schedules to delete the given path, whether it's a file or a directory, until +// the operating system is restarted. +// Note: +// 1) The file/directory to be deleted should exist in a temp folder. +// 2) The directory to be deleted must be empty. +BASE_EXPORT bool DeleteFileAfterReboot(const FilePath& path); +#endif + +// Moves the given path, whether it's a file or a directory. +// If a simple rename is not possible, such as in the case where the paths are +// on different volumes, this will attempt to copy and delete. Returns +// true for success. +// This function fails if either path contains traversal components ('..'). +BASE_EXPORT bool Move(const FilePath& from_path, const FilePath& to_path); + +// Renames file |from_path| to |to_path|. Both paths must be on the same +// volume, or the function will fail. Destination file will be created +// if it doesn't exist. Prefer this function over Move when dealing with +// temporary files. On Windows it preserves attributes of the target file. +// Returns true on success, leaving *error unchanged. +// Returns false on failure and sets *error appropriately, if it is non-NULL. +BASE_EXPORT bool ReplaceFile(const FilePath& from_path, + const FilePath& to_path, + File::Error* error); + +// Copies a single file. Use CopyDirectory to copy directories. +// This function fails if either path contains traversal components ('..'). +// +// This function keeps the metadata on Windows. The read only bit on Windows is +// not kept. +BASE_EXPORT bool CopyFile(const FilePath& from_path, const FilePath& to_path); + +// Copies the given path, and optionally all subdirectories and their contents +// as well. +// +// If there are files existing under to_path, always overwrite. Returns true +// if successful, false otherwise. Wildcards on the names are not supported. +// +// This function calls into CopyFile() so the same behavior w.r.t. metadata +// applies. +// +// If you only need to copy a file use CopyFile, it's faster. +BASE_EXPORT bool CopyDirectory(const FilePath& from_path, + const FilePath& to_path, + bool recursive); + +// Returns true if the given path exists on the local filesystem, +// false otherwise. +BASE_EXPORT bool PathExists(const FilePath& path); + +// Returns true if the given path is writable by the user, false otherwise. +BASE_EXPORT bool PathIsWritable(const FilePath& path); + +// Returns true if the given path exists and is a directory, false otherwise. +BASE_EXPORT bool DirectoryExists(const FilePath& path); + +// Returns true if the contents of the two files given are equal, false +// otherwise. If either file can't be read, returns false. +BASE_EXPORT bool ContentsEqual(const FilePath& filename1, + const FilePath& filename2); + +// Returns true if the contents of the two text files given are equal, false +// otherwise. This routine treats "\r\n" and "\n" as equivalent. +BASE_EXPORT bool TextContentsEqual(const FilePath& filename1, + const FilePath& filename2); + +// Reads the file at |path| into |contents| and returns true on success and +// false on error. For security reasons, a |path| containing path traversal +// components ('..') is treated as a read error and |contents| is set to empty. +// In case of I/O error, |contents| holds the data that could be read from the +// file before the error occurred. +// |contents| may be NULL, in which case this function is useful for its side +// effect of priming the disk cache (could be used for unit tests). +BASE_EXPORT bool ReadFileToString(const FilePath& path, std::string* contents); + +// Reads the file at |path| into |contents| and returns true on success and +// false on error. For security reasons, a |path| containing path traversal +// components ('..') is treated as a read error and |contents| is set to empty. +// In case of I/O error, |contents| holds the data that could be read from the +// file before the error occurred. When the file size exceeds |max_size|, the +// function returns false with |contents| holding the file truncated to +// |max_size|. +// |contents| may be NULL, in which case this function is useful for its side +// effect of priming the disk cache (could be used for unit tests). +BASE_EXPORT bool ReadFileToString(const FilePath& path, + std::string* contents, + size_t max_size); + +#if defined(OS_POSIX) + +// Read exactly |bytes| bytes from file descriptor |fd|, storing the result +// in |buffer|. This function is protected against EINTR and partial reads. +// Returns true iff |bytes| bytes have been successfully read from |fd|. +BASE_EXPORT bool ReadFromFD(int fd, char* buffer, size_t bytes); + +// Creates a symbolic link at |symlink| pointing to |target|. Returns +// false on failure. +BASE_EXPORT bool CreateSymbolicLink(const FilePath& target, + const FilePath& symlink); + +// Reads the given |symlink| and returns where it points to in |target|. +// Returns false upon failure. +BASE_EXPORT bool ReadSymbolicLink(const FilePath& symlink, FilePath* target); + +// Bits and masks of the file permission. +enum FilePermissionBits { + FILE_PERMISSION_MASK = S_IRWXU | S_IRWXG | S_IRWXO, + FILE_PERMISSION_USER_MASK = S_IRWXU, + FILE_PERMISSION_GROUP_MASK = S_IRWXG, + FILE_PERMISSION_OTHERS_MASK = S_IRWXO, + + FILE_PERMISSION_READ_BY_USER = S_IRUSR, + FILE_PERMISSION_WRITE_BY_USER = S_IWUSR, + FILE_PERMISSION_EXECUTE_BY_USER = S_IXUSR, + FILE_PERMISSION_READ_BY_GROUP = S_IRGRP, + FILE_PERMISSION_WRITE_BY_GROUP = S_IWGRP, + FILE_PERMISSION_EXECUTE_BY_GROUP = S_IXGRP, + FILE_PERMISSION_READ_BY_OTHERS = S_IROTH, + FILE_PERMISSION_WRITE_BY_OTHERS = S_IWOTH, + FILE_PERMISSION_EXECUTE_BY_OTHERS = S_IXOTH, +}; + +// Reads the permission of the given |path|, storing the file permission +// bits in |mode|. If |path| is symbolic link, |mode| is the permission of +// a file which the symlink points to. +BASE_EXPORT bool GetPosixFilePermissions(const FilePath& path, int* mode); +// Sets the permission of the given |path|. If |path| is symbolic link, sets +// the permission of a file which the symlink points to. +BASE_EXPORT bool SetPosixFilePermissions(const FilePath& path, int mode); + +#endif // OS_POSIX + +// Returns true if the given directory is empty +BASE_EXPORT bool IsDirectoryEmpty(const FilePath& dir_path); + +// Get the temporary directory provided by the system. +// +// WARNING: In general, you should use CreateTemporaryFile variants below +// instead of this function. Those variants will ensure that the proper +// permissions are set so that other users on the system can't edit them while +// they're open (which can lead to security issues). +BASE_EXPORT bool GetTempDir(FilePath* path); + +// Get the home directory. This is more complicated than just getenv("HOME") +// as it knows to fall back on getpwent() etc. +// +// You should not generally call this directly. Instead use DIR_HOME with the +// path service which will use this function but cache the value. +// Path service may also override DIR_HOME. +BASE_EXPORT FilePath GetHomeDir(); + +// Creates a temporary file. The full path is placed in |path|, and the +// function returns true if was successful in creating the file. The file will +// be empty and all handles closed after this function returns. +BASE_EXPORT bool CreateTemporaryFile(FilePath* path); + +// Same as CreateTemporaryFile but the file is created in |dir|. +BASE_EXPORT bool CreateTemporaryFileInDir(const FilePath& dir, + FilePath* temp_file); + +// Create and open a temporary file. File is opened for read/write. +// The full path is placed in |path|. +// Returns a handle to the opened file or NULL if an error occurred. +BASE_EXPORT FILE* CreateAndOpenTemporaryFile(FilePath* path); + +// Similar to CreateAndOpenTemporaryFile, but the file is created in |dir|. +BASE_EXPORT FILE* CreateAndOpenTemporaryFileInDir(const FilePath& dir, + FilePath* path); + +// Create a new directory. If prefix is provided, the new directory name is in +// the format of prefixyyyy. +// NOTE: prefix is ignored in the POSIX implementation. +// If success, return true and output the full path of the directory created. +BASE_EXPORT bool CreateNewTempDirectory(const FilePath::StringType& prefix, + FilePath* new_temp_path); + +// Create a directory within another directory. +// Extra characters will be appended to |prefix| to ensure that the +// new directory does not have the same name as an existing directory. +BASE_EXPORT bool CreateTemporaryDirInDir(const FilePath& base_dir, + const FilePath::StringType& prefix, + FilePath* new_dir); + +// Creates a directory, as well as creating any parent directories, if they +// don't exist. Returns 'true' on successful creation, or if the directory +// already exists. The directory is only readable by the current user. +// Returns true on success, leaving *error unchanged. +// Returns false on failure and sets *error appropriately, if it is non-NULL. +BASE_EXPORT bool CreateDirectoryAndGetError(const FilePath& full_path, + File::Error* error); + +// Backward-compatible convenience method for the above. +BASE_EXPORT bool CreateDirectory(const FilePath& full_path); + +// Returns the file size. Returns true on success. +BASE_EXPORT bool GetFileSize(const FilePath& file_path, int64* file_size); + +// Sets |real_path| to |path| with symbolic links and junctions expanded. +// On windows, make sure the path starts with a lettered drive. +// |path| must reference a file. Function will fail if |path| points to +// a directory or to a nonexistent path. On windows, this function will +// fail if |path| is a junction or symlink that points to an empty file, +// or if |real_path| would be longer than MAX_PATH characters. +BASE_EXPORT bool NormalizeFilePath(const FilePath& path, FilePath* real_path); + +#if defined(OS_WIN) + +// Given a path in NT native form ("\Device\HarddiskVolumeXX\..."), +// return in |drive_letter_path| the equivalent path that starts with +// a drive letter ("C:\..."). Return false if no such path exists. +BASE_EXPORT bool DevicePathToDriveLetterPath(const FilePath& device_path, + FilePath* drive_letter_path); + +// Given an existing file in |path|, set |real_path| to the path +// in native NT format, of the form "\Device\HarddiskVolumeXX\..". +// Returns false if the path can not be found. Empty files cannot +// be resolved with this function. +BASE_EXPORT bool NormalizeToNativeFilePath(const FilePath& path, + FilePath* nt_path); +#endif + +// This function will return if the given file is a symlink or not. +BASE_EXPORT bool IsLink(const FilePath& file_path); + +// Returns information about the given file path. +BASE_EXPORT bool GetFileInfo(const FilePath& file_path, File::Info* info); + +// Sets the time of the last access and the time of the last modification. +BASE_EXPORT bool TouchFile(const FilePath& path, + const Time& last_accessed, + const Time& last_modified); + +// Wrapper for fopen-like calls. Returns non-NULL FILE* on success. +BASE_EXPORT FILE* OpenFile(const FilePath& filename, const char* mode); + +// Closes file opened by OpenFile. Returns true on success. +BASE_EXPORT bool CloseFile(FILE* file); + +// Associates a standard FILE stream with an existing File. Note that this +// functions take ownership of the existing File. +BASE_EXPORT FILE* FileToFILE(File file, const char* mode); + +// Truncates an open file to end at the location of the current file pointer. +// This is a cross-platform analog to Windows' SetEndOfFile() function. +BASE_EXPORT bool TruncateFile(FILE* file); + +// Reads at most the given number of bytes from the file into the buffer. +// Returns the number of read bytes, or -1 on error. +BASE_EXPORT int ReadFile(const FilePath& filename, char* data, int max_size); + +// Writes the given buffer into the file, overwriting any data that was +// previously there. Returns the number of bytes written, or -1 on error. +BASE_EXPORT int WriteFile(const FilePath& filename, const char* data, + int size); + +#if defined(OS_POSIX) +// Append the data to |fd|. Does not close |fd| when done. +BASE_EXPORT int WriteFileDescriptor(const int fd, const char* data, int size); +#endif + +// Append the given buffer into the file. Returns the number of bytes written, +// or -1 on error. +BASE_EXPORT int AppendToFile(const FilePath& filename, + const char* data, int size); + +// Gets the current working directory for the process. +BASE_EXPORT bool GetCurrentDirectory(FilePath* path); + +// Sets the current working directory for the process. +BASE_EXPORT bool SetCurrentDirectory(const FilePath& path); + +// Attempts to find a number that can be appended to the |path| to make it +// unique. If |path| does not exist, 0 is returned. If it fails to find such +// a number, -1 is returned. If |suffix| is not empty, also checks the +// existence of it with the given suffix. +BASE_EXPORT int GetUniquePathNumber(const FilePath& path, + const FilePath::StringType& suffix); + +#if defined(OS_POSIX) +// Test that |path| can only be changed by a given user and members of +// a given set of groups. +// Specifically, test that all parts of |path| under (and including) |base|: +// * Exist. +// * Are owned by a specific user. +// * Are not writable by all users. +// * Are owned by a member of a given set of groups, or are not writable by +// their group. +// * Are not symbolic links. +// This is useful for checking that a config file is administrator-controlled. +// |base| must contain |path|. +BASE_EXPORT bool VerifyPathControlledByUser(const base::FilePath& base, + const base::FilePath& path, + uid_t owner_uid, + const std::set<gid_t>& group_gids); +#endif // defined(OS_POSIX) + +#if defined(OS_MACOSX) && !defined(OS_IOS) +// Is |path| writable only by a user with administrator privileges? +// This function uses Mac OS conventions. The super user is assumed to have +// uid 0, and the administrator group is assumed to be named "admin". +// Testing that |path|, and every parent directory including the root of +// the filesystem, are owned by the superuser, controlled by the group +// "admin", are not writable by all users, and contain no symbolic links. +// Will return false if |path| does not exist. +BASE_EXPORT bool VerifyPathControlledByAdmin(const base::FilePath& path); +#endif // defined(OS_MACOSX) && !defined(OS_IOS) + +// Returns the maximum length of path component on the volume containing +// the directory |path|, in the number of FilePath::CharType, or -1 on failure. +BASE_EXPORT int GetMaximumPathComponentLength(const base::FilePath& path); + +#if defined(OS_LINUX) +// Broad categories of file systems as returned by statfs() on Linux. +enum FileSystemType { + FILE_SYSTEM_UNKNOWN, // statfs failed. + FILE_SYSTEM_0, // statfs.f_type == 0 means unknown, may indicate AFS. + FILE_SYSTEM_ORDINARY, // on-disk filesystem like ext2 + FILE_SYSTEM_NFS, + FILE_SYSTEM_SMB, + FILE_SYSTEM_CODA, + FILE_SYSTEM_MEMORY, // in-memory file system + FILE_SYSTEM_CGROUP, // cgroup control. + FILE_SYSTEM_OTHER, // any other value. + FILE_SYSTEM_TYPE_COUNT +}; + +// Attempts determine the FileSystemType for |path|. +// Returns false if |path| doesn't exist. +BASE_EXPORT bool GetFileSystemType(const FilePath& path, FileSystemType* type); +#endif + +#if defined(OS_POSIX) +// Get a temporary directory for shared memory files. The directory may depend +// on whether the destination is intended for executable files, which in turn +// depends on how /dev/shmem was mounted. As a result, you must supply whether +// you intend to create executable shmem segments so this function can find +// an appropriate location. +BASE_EXPORT bool GetShmemTempDir(bool executable, FilePath* path); +#endif + +// Internal -------------------------------------------------------------------- + +namespace internal { + +// Same as Move but allows paths with traversal components. +// Use only with extreme care. +BASE_EXPORT bool MoveUnsafe(const FilePath& from_path, + const FilePath& to_path); + +// Same as CopyFile but allows paths with traversal components. +// Use only with extreme care. +BASE_EXPORT bool CopyFileUnsafe(const FilePath& from_path, + const FilePath& to_path); + +#if defined(OS_WIN) +// Copy from_path to to_path recursively and then delete from_path recursively. +// Returns true if all operations succeed. +// This function simulates Move(), but unlike Move() it works across volumes. +// This function is not transactional. +BASE_EXPORT bool CopyAndDeleteDirectory(const FilePath& from_path, + const FilePath& to_path); +#endif // defined(OS_WIN) + +} // namespace internal +} // namespace base + +#endif // BASE_FILES_FILE_UTIL_H_ diff --git a/base/file_util_android.cc b/base/files/file_util_android.cc index def4d7c..b8b3b37 100644 --- a/base/file_util_android.cc +++ b/base/files/file_util_android.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_util.h" +#include "base/files/file_util.h" #include "base/files/file_path.h" #include "base/path_service.h" diff --git a/base/file_util_linux.cc b/base/files/file_util_linux.cc index 2910c9c..532962f 100644 --- a/base/file_util_linux.cc +++ b/base/files/file_util_linux.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_util.h" +#include "base/files/file_util.h" #include <errno.h> #include <linux/magic.h> diff --git a/base/file_util_mac.mm b/base/files/file_util_mac.mm index 4aa6d55..695935a 100644 --- a/base/file_util_mac.mm +++ b/base/files/file_util_mac.mm @@ -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_util.h" +#include "base/files/file_util.h" #import <Foundation/Foundation.h> #include <copyfile.h> diff --git a/base/file_util_posix.cc b/base/files/file_util_posix.cc index 92e8cad..07c21d1 100644 --- a/base/file_util_posix.cc +++ b/base/files/file_util_posix.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_util.h" +#include "base/files/file_util.h" #include <dirent.h> #include <errno.h> diff --git a/base/files/file_util_proxy.cc b/base/files/file_util_proxy.cc index 72d9436..0942e7a 100644 --- a/base/files/file_util_proxy.cc +++ b/base/files/file_util_proxy.cc @@ -6,7 +6,7 @@ #include "base/bind.h" #include "base/bind_helpers.h" -#include "base/file_util.h" +#include "base/files/file_util.h" #include "base/location.h" #include "base/task_runner.h" #include "base/task_runner_util.h" diff --git a/base/files/file_util_proxy_unittest.cc b/base/files/file_util_proxy_unittest.cc index 52073ae..a18cd43 100644 --- a/base/files/file_util_proxy_unittest.cc +++ b/base/files/file_util_proxy_unittest.cc @@ -5,7 +5,7 @@ #include "base/files/file_util_proxy.h" #include "base/bind.h" -#include "base/file_util.h" +#include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" #include "base/memory/weak_ptr.h" #include "base/message_loop/message_loop.h" diff --git a/base/file_util_unittest.cc b/base/files/file_util_unittest.cc index eb88ba8..e085aef 100644 --- a/base/file_util_unittest.cc +++ b/base/files/file_util_unittest.cc @@ -24,9 +24,9 @@ #include <vector> #include "base/base_paths.h" -#include "base/file_util.h" #include "base/files/file_enumerator.h" #include "base/files/file_path.h" +#include "base/files/file_util.h" #include "base/files/scoped_file.h" #include "base/files/scoped_temp_dir.h" #include "base/path_service.h" @@ -52,8 +52,8 @@ namespace base { namespace { -// To test that file_util::Normalize FilePath() deals with NTFS reparse points -// correctly, we need functions to create and delete reparse points. +// To test that NormalizeFilePath() deals with NTFS reparse points correctly, +// we need functions to create and delete reparse points. #if defined(OS_WIN) typedef struct _REPARSE_DATA_BUFFER { ULONG ReparseTag; diff --git a/base/file_util_win.cc b/base/files/file_util_win.cc index e3cd1f8..82b53c5 100644 --- a/base/file_util_win.cc +++ b/base/files/file_util_win.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_util.h" +#include "base/files/file_util.h" #include <windows.h> #include <io.h> diff --git a/base/files/important_file_writer.cc b/base/files/important_file_writer.cc index bf4e003..6e3be2a 100644 --- a/base/files/important_file_writer.cc +++ b/base/files/important_file_writer.cc @@ -10,9 +10,9 @@ #include "base/bind.h" #include "base/critical_closure.h" -#include "base/file_util.h" #include "base/files/file.h" #include "base/files/file_path.h" +#include "base/files/file_util.h" #include "base/logging.h" #include "base/metrics/histogram.h" #include "base/strings/string_number_conversions.h" diff --git a/base/files/important_file_writer_unittest.cc b/base/files/important_file_writer_unittest.cc index 3f62fe4..c55f0cc 100644 --- a/base/files/important_file_writer_unittest.cc +++ b/base/files/important_file_writer_unittest.cc @@ -6,8 +6,8 @@ #include "base/bind.h" #include "base/compiler_specific.h" -#include "base/file_util.h" #include "base/files/file_path.h" +#include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" #include "base/logging.h" #include "base/message_loop/message_loop.h" diff --git a/base/files/memory_mapped_file_unittest.cc b/base/files/memory_mapped_file_unittest.cc index 21b0df4..6627d40 100644 --- a/base/files/memory_mapped_file_unittest.cc +++ b/base/files/memory_mapped_file_unittest.cc @@ -4,8 +4,8 @@ #include "base/files/memory_mapped_file.h" -#include "base/file_util.h" #include "base/files/file_path.h" +#include "base/files/file_util.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/platform_test.h" diff --git a/base/files/scoped_temp_dir.cc b/base/files/scoped_temp_dir.cc index b893b02..27b758e 100644 --- a/base/files/scoped_temp_dir.cc +++ b/base/files/scoped_temp_dir.cc @@ -4,7 +4,7 @@ #include "base/files/scoped_temp_dir.h" -#include "base/file_util.h" +#include "base/files/file_util.h" #include "base/logging.h" namespace base { diff --git a/base/files/scoped_temp_dir_unittest.cc b/base/files/scoped_temp_dir_unittest.cc index da22230..a19f34d 100644 --- a/base/files/scoped_temp_dir_unittest.cc +++ b/base/files/scoped_temp_dir_unittest.cc @@ -4,8 +4,8 @@ #include <string> -#include "base/file_util.h" #include "base/files/file.h" +#include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/base/i18n/build_utf8_validator_tables.cc b/base/i18n/build_utf8_validator_tables.cc index d37a751..45fc6cb 100644 --- a/base/i18n/build_utf8_validator_tables.cc +++ b/base/i18n/build_utf8_validator_tables.cc @@ -37,8 +37,8 @@ #include "base/basictypes.h" #include "base/command_line.h" -#include "base/file_util.h" #include "base/files/file_path.h" +#include "base/files/file_util.h" #include "base/logging.h" #include "base/numerics/safe_conversions.h" #include "base/strings/stringprintf.h" diff --git a/base/i18n/file_util_icu_unittest.cc b/base/i18n/file_util_icu_unittest.cc index cdb48a1..369345b 100644 --- a/base/i18n/file_util_icu_unittest.cc +++ b/base/i18n/file_util_icu_unittest.cc @@ -4,7 +4,7 @@ #include "base/i18n/file_util_icu.h" -#include "base/file_util.h" +#include "base/files/file_util.h" #include "base/strings/utf_string_conversions.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/platform_test.h" diff --git a/base/json/json_file_value_serializer.cc b/base/json/json_file_value_serializer.cc index e33080c..d7d54f2 100644 --- a/base/json/json_file_value_serializer.cc +++ b/base/json/json_file_value_serializer.cc @@ -4,7 +4,7 @@ #include "base/json/json_file_value_serializer.h" -#include "base/file_util.h" +#include "base/files/file_util.h" #include "base/json/json_string_value_serializer.h" #include "base/logging.h" diff --git a/base/json/json_reader_unittest.cc b/base/json/json_reader_unittest.cc index eceb538..67070ff 100644 --- a/base/json/json_reader_unittest.cc +++ b/base/json/json_reader_unittest.cc @@ -5,7 +5,7 @@ #include "base/json/json_reader.h" #include "base/base_paths.h" -#include "base/file_util.h" +#include "base/files/file_util.h" #include "base/logging.h" #include "base/memory/scoped_ptr.h" #include "base/path_service.h" diff --git a/base/json/json_value_serializer_unittest.cc b/base/json/json_value_serializer_unittest.cc index f8d3a201..3be8bbf 100644 --- a/base/json/json_value_serializer_unittest.cc +++ b/base/json/json_value_serializer_unittest.cc @@ -4,7 +4,7 @@ #include <string> -#include "base/file_util.h" +#include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" #include "base/json/json_file_value_serializer.h" #include "base/json/json_reader.h" diff --git a/base/linux_util.cc b/base/linux_util.cc index 36710f2..29e1980 100644 --- a/base/linux_util.cc +++ b/base/linux_util.cc @@ -15,7 +15,7 @@ #include <vector> #include "base/command_line.h" -#include "base/file_util.h" +#include "base/files/file_util.h" #include "base/memory/scoped_ptr.h" #include "base/memory/singleton.h" #include "base/path_service.h" diff --git a/base/mac/mac_util_unittest.mm b/base/mac/mac_util_unittest.mm index 956036e..aae40a6 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_util.h" #include "base/files/file_path.h" +#include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" #include "base/mac/foundation_util.h" #include "base/mac/scoped_cftyperef.h" diff --git a/base/memory/discardable_memory_ashmem_allocator.cc b/base/memory/discardable_memory_ashmem_allocator.cc index 249952e..3d4af92 100644 --- a/base/memory/discardable_memory_ashmem_allocator.cc +++ b/base/memory/discardable_memory_ashmem_allocator.cc @@ -15,7 +15,7 @@ #include "base/basictypes.h" #include "base/containers/hash_tables.h" -#include "base/file_util.h" +#include "base/files/file_util.h" #include "base/files/scoped_file.h" #include "base/logging.h" #include "base/memory/scoped_vector.h" diff --git a/base/memory/shared_memory.h b/base/memory/shared_memory.h index d48071e..7254950 100644 --- a/base/memory/shared_memory.h +++ b/base/memory/shared_memory.h @@ -21,7 +21,7 @@ #if defined(OS_POSIX) #include "base/file_descriptor_posix.h" -#include "base/file_util.h" +#include "base/files/file_util.h" #include "base/files/scoped_file.h" #endif diff --git a/base/memory/shared_memory_posix.cc b/base/memory/shared_memory_posix.cc index f0a28ba..0358e63 100644 --- a/base/memory/shared_memory_posix.cc +++ b/base/memory/shared_memory_posix.cc @@ -11,7 +11,7 @@ #include <sys/types.h> #include <unistd.h> -#include "base/file_util.h" +#include "base/files/file_util.h" #include "base/files/scoped_file.h" #include "base/lazy_instance.h" #include "base/logging.h" diff --git a/base/native_library_mac.mm b/base/native_library_mac.mm index a24586e..8122c28 100644 --- a/base/native_library_mac.mm +++ b/base/native_library_mac.mm @@ -7,8 +7,8 @@ #include <dlfcn.h> #include <mach-o/getsect.h> -#include "base/file_util.h" #include "base/files/file_path.h" +#include "base/files/file_util.h" #include "base/logging.h" #include "base/mac/scoped_cftyperef.h" #include "base/strings/string_util.h" diff --git a/base/native_library_win.cc b/base/native_library_win.cc index 43528b9..1ca3e92 100644 --- a/base/native_library_win.cc +++ b/base/native_library_win.cc @@ -6,7 +6,7 @@ #include <windows.h> -#include "base/file_util.h" +#include "base/files/file_util.h" #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" #include "base/threading/thread_restrictions.h" diff --git a/base/nix/xdg_util.cc b/base/nix/xdg_util.cc index 4086a3d..e889b56 100644 --- a/base/nix/xdg_util.cc +++ b/base/nix/xdg_util.cc @@ -8,8 +8,8 @@ #include "base/base_paths.h" #include "base/environment.h" -#include "base/file_util.h" #include "base/files/file_path.h" +#include "base/files/file_util.h" #include "base/path_service.h" #include "base/third_party/xdg_user_dirs/xdg_user_dir_lookup.h" diff --git a/base/os_compat_android_unittest.cc b/base/os_compat_android_unittest.cc index a1d1fb1..7fbdc6d 100644 --- a/base/os_compat_android_unittest.cc +++ b/base/os_compat_android_unittest.cc @@ -4,7 +4,7 @@ #include "base/os_compat_android.h" -#include "base/file_util.h" +#include "base/files/file_util.h" #include "testing/gtest/include/gtest/gtest.h" namespace base { diff --git a/base/path_service.cc b/base/path_service.cc index 75833db..ce4966e 100644 --- a/base/path_service.cc +++ b/base/path_service.cc @@ -11,8 +11,8 @@ #endif #include "base/containers/hash_tables.h" -#include "base/file_util.h" #include "base/files/file_path.h" +#include "base/files/file_util.h" #include "base/lazy_instance.h" #include "base/logging.h" #include "base/synchronization/lock.h" diff --git a/base/path_service_unittest.cc b/base/path_service_unittest.cc index a345262..c6cc0e6 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_util.h" #include "base/files/file_path.h" +#include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" #include "base/strings/string_util.h" #include "build/build_config.h" diff --git a/base/posix/unix_domain_socket_linux_unittest.cc b/base/posix/unix_domain_socket_linux_unittest.cc index 7b2e2af..60b2bb8 100644 --- a/base/posix/unix_domain_socket_linux_unittest.cc +++ b/base/posix/unix_domain_socket_linux_unittest.cc @@ -8,7 +8,7 @@ #include "base/bind.h" #include "base/bind_helpers.h" -#include "base/file_util.h" +#include "base/files/file_util.h" #include "base/files/scoped_file.h" #include "base/memory/scoped_vector.h" #include "base/pickle.h" diff --git a/base/prefs/json_pref_store.cc b/base/prefs/json_pref_store.cc index 5275ce1..bc12e8d 100644 --- a/base/prefs/json_pref_store.cc +++ b/base/prefs/json_pref_store.cc @@ -8,8 +8,8 @@ #include "base/bind.h" #include "base/callback.h" -#include "base/file_util.h" #include "base/files/file_path.h" +#include "base/files/file_util.h" #include "base/json/json_file_value_serializer.h" #include "base/json/json_string_value_serializer.h" #include "base/memory/ref_counted.h" diff --git a/base/prefs/json_pref_store_unittest.cc b/base/prefs/json_pref_store_unittest.cc index 441c229..d09d9d3 100644 --- a/base/prefs/json_pref_store_unittest.cc +++ b/base/prefs/json_pref_store_unittest.cc @@ -5,7 +5,7 @@ #include "base/prefs/json_pref_store.h" #include "base/bind.h" -#include "base/file_util.h" +#include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" diff --git a/base/process/internal_linux.cc b/base/process/internal_linux.cc index 57a3ab4..ed7d7f4 100644 --- a/base/process/internal_linux.cc +++ b/base/process/internal_linux.cc @@ -10,7 +10,7 @@ #include <string> #include <vector> -#include "base/file_util.h" +#include "base/files/file_util.h" #include "base/logging.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_split.h" diff --git a/base/process/kill_mac.cc b/base/process/kill_mac.cc index 1589a64..9257ee6 100644 --- a/base/process/kill_mac.cc +++ b/base/process/kill_mac.cc @@ -9,7 +9,7 @@ #include <sys/types.h> #include <sys/wait.h> -#include "base/file_util.h" +#include "base/files/file_util.h" #include "base/files/scoped_file.h" #include "base/logging.h" #include "base/posix/eintr_wrapper.h" diff --git a/base/process/kill_posix.cc b/base/process/kill_posix.cc index 18c14fd..adc1db3 100644 --- a/base/process/kill_posix.cc +++ b/base/process/kill_posix.cc @@ -9,7 +9,7 @@ #include <sys/wait.h> #include <unistd.h> -#include "base/file_util.h" +#include "base/files/file_util.h" #include "base/files/scoped_file.h" #include "base/logging.h" #include "base/posix/eintr_wrapper.h" diff --git a/base/process/launch_posix.cc b/base/process/launch_posix.cc index 78a3be4..bc6294b 100644 --- a/base/process/launch_posix.cc +++ b/base/process/launch_posix.cc @@ -24,8 +24,8 @@ #include "base/compiler_specific.h" #include "base/debug/debugger.h" #include "base/debug/stack_trace.h" -#include "base/file_util.h" #include "base/files/dir_reader_posix.h" +#include "base/files/file_util.h" #include "base/files/scoped_file.h" #include "base/logging.h" #include "base/memory/scoped_ptr.h" diff --git a/base/process/memory_linux.cc b/base/process/memory_linux.cc index befd832..6dbe8b7 100644 --- a/base/process/memory_linux.cc +++ b/base/process/memory_linux.cc @@ -6,8 +6,8 @@ #include <new> -#include "base/file_util.h" #include "base/files/file_path.h" +#include "base/files/file_util.h" #include "base/logging.h" #include "base/process/internal_linux.h" #include "base/strings/string_number_conversions.h" diff --git a/base/process/process_handle_linux.cc b/base/process/process_handle_linux.cc index 6c5cd2f..950b888 100644 --- a/base/process/process_handle_linux.cc +++ b/base/process/process_handle_linux.cc @@ -4,7 +4,7 @@ #include "base/process/process_handle.h" -#include "base/file_util.h" +#include "base/files/file_util.h" #include "base/process/internal_linux.h" namespace base { diff --git a/base/process/process_iterator_linux.cc b/base/process/process_iterator_linux.cc index 8f746aa..3319552 100644 --- a/base/process/process_iterator_linux.cc +++ b/base/process/process_iterator_linux.cc @@ -4,7 +4,7 @@ #include "base/process/process_iterator.h" -#include "base/file_util.h" +#include "base/files/file_util.h" #include "base/logging.h" #include "base/process/internal_linux.h" #include "base/strings/string_util.h" diff --git a/base/process/process_linux.cc b/base/process/process_linux.cc index d92d7c3..2c22d26 100644 --- a/base/process/process_linux.cc +++ b/base/process/process_linux.cc @@ -7,7 +7,7 @@ #include <errno.h> #include <sys/resource.h> -#include "base/file_util.h" +#include "base/files/file_util.h" #include "base/lazy_instance.h" #include "base/logging.h" #include "base/strings/string_split.h" diff --git a/base/process/process_metrics_linux.cc b/base/process/process_metrics_linux.cc index 0e12595..c472d73 100644 --- a/base/process/process_metrics_linux.cc +++ b/base/process/process_metrics_linux.cc @@ -11,7 +11,7 @@ #include <sys/types.h> #include <unistd.h> -#include "base/file_util.h" +#include "base/files/file_util.h" #include "base/logging.h" #include "base/process/internal_linux.h" #include "base/strings/string_number_conversions.h" diff --git a/base/rand_util_posix.cc b/base/rand_util_posix.cc index 0a72a20..fe73b96 100644 --- a/base/rand_util_posix.cc +++ b/base/rand_util_posix.cc @@ -8,7 +8,7 @@ #include <fcntl.h> #include <unistd.h> -#include "base/file_util.h" +#include "base/files/file_util.h" #include "base/lazy_instance.h" #include "base/logging.h" diff --git a/base/security_unittest.cc b/base/security_unittest.cc index 960bc20..0ecaec4 100644 --- a/base/security_unittest.cc +++ b/base/security_unittest.cc @@ -12,7 +12,7 @@ #include <algorithm> #include <limits> -#include "base/file_util.h" +#include "base/files/file_util.h" #include "base/logging.h" #include "base/memory/scoped_ptr.h" #include "build/build_config.h" diff --git a/base/sync_socket_posix.cc b/base/sync_socket_posix.cc index 6d397ff..93a01d1 100644 --- a/base/sync_socket_posix.cc +++ b/base/sync_socket_posix.cc @@ -16,7 +16,7 @@ #include <sys/filio.h> #endif -#include "base/file_util.h" +#include "base/files/file_util.h" #include "base/logging.h" #include "base/threading/thread_restrictions.h" diff --git a/base/sys_info_chromeos.cc b/base/sys_info_chromeos.cc index 4f32f9b..d3a1b2c 100644 --- a/base/sys_info_chromeos.cc +++ b/base/sys_info_chromeos.cc @@ -6,9 +6,9 @@ #include "base/basictypes.h" #include "base/environment.h" -#include "base/file_util.h" #include "base/files/file.h" #include "base/files/file_path.h" +#include "base/files/file_util.h" #include "base/lazy_instance.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_piece.h" diff --git a/base/sys_info_linux.cc b/base/sys_info_linux.cc index 6f1e5eb..eb89e5e 100644 --- a/base/sys_info_linux.cc +++ b/base/sys_info_linux.cc @@ -6,7 +6,7 @@ #include <limits> -#include "base/file_util.h" +#include "base/files/file_util.h" #include "base/lazy_instance.h" #include "base/logging.h" #include "base/strings/string_number_conversions.h" diff --git a/base/sys_info_posix.cc b/base/sys_info_posix.cc index 90baa69..c201ae1 100644 --- a/base/sys_info_posix.cc +++ b/base/sys_info_posix.cc @@ -12,7 +12,7 @@ #include <unistd.h> #include "base/basictypes.h" -#include "base/file_util.h" +#include "base/files/file_util.h" #include "base/lazy_instance.h" #include "base/logging.h" #include "base/strings/utf_string_conversions.h" diff --git a/base/sys_info_unittest.cc b/base/sys_info_unittest.cc index e771b2b..bfd8224 100644 --- a/base/sys_info_unittest.cc +++ b/base/sys_info_unittest.cc @@ -3,7 +3,7 @@ // found in the LICENSE file. #include "base/environment.h" -#include "base/file_util.h" +#include "base/files/file_util.h" #include "base/sys_info.h" #include "base/threading/platform_thread.h" #include "base/time/time.h" diff --git a/base/test/gtest_xml_util.cc b/base/test/gtest_xml_util.cc index f52c2f6..8a153dc 100644 --- a/base/test/gtest_xml_util.cc +++ b/base/test/gtest_xml_util.cc @@ -4,7 +4,7 @@ #include "base/test/gtest_xml_util.h" -#include "base/file_util.h" +#include "base/files/file_util.h" #include "base/logging.h" #include "base/strings/stringprintf.h" #include "base/test/launcher/test_launcher.h" diff --git a/base/test/launcher/test_launcher.cc b/base/test/launcher/test_launcher.cc index e6c1507..25f2234 100644 --- a/base/test/launcher/test_launcher.cc +++ b/base/test/launcher/test_launcher.cc @@ -12,8 +12,8 @@ #include "base/bind.h" #include "base/command_line.h" #include "base/environment.h" -#include "base/file_util.h" #include "base/files/file_path.h" +#include "base/files/file_util.h" #include "base/files/scoped_file.h" #include "base/format_macros.h" #include "base/hash.h" diff --git a/base/test/launcher/test_results_tracker.cc b/base/test/launcher/test_results_tracker.cc index fb2e550..1e3b2b0 100644 --- a/base/test/launcher/test_results_tracker.cc +++ b/base/test/launcher/test_results_tracker.cc @@ -6,8 +6,8 @@ #include "base/base64.h" #include "base/command_line.h" -#include "base/file_util.h" #include "base/files/file_path.h" +#include "base/files/file_util.h" #include "base/format_macros.h" #include "base/json/json_file_value_serializer.h" #include "base/json/string_escape.h" diff --git a/base/test/launcher/unit_test_launcher.cc b/base/test/launcher/unit_test_launcher.cc index 841d5bee..0cbae2f 100644 --- a/base/test/launcher/unit_test_launcher.cc +++ b/base/test/launcher/unit_test_launcher.cc @@ -9,7 +9,7 @@ #include "base/command_line.h" #include "base/compiler_specific.h" #include "base/debug/debugger.h" -#include "base/file_util.h" +#include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" #include "base/format_macros.h" #include "base/message_loop/message_loop.h" diff --git a/base/test/perf_log.cc b/base/test/perf_log.cc index 5d5027d..22884b8 100644 --- a/base/test/perf_log.cc +++ b/base/test/perf_log.cc @@ -4,7 +4,7 @@ #include "base/test/perf_log.h" -#include "base/file_util.h" +#include "base/files/file_util.h" #include "base/logging.h" namespace base { diff --git a/base/test/test_file_util_mac.cc b/base/test/test_file_util_mac.cc index a4ed1d3..11592c3 100644 --- a/base/test/test_file_util_mac.cc +++ b/base/test/test_file_util_mac.cc @@ -7,9 +7,9 @@ #include <sys/mman.h> #include <errno.h> -#include "base/logging.h" -#include "base/file_util.h" +#include "base/files/file_util.h" #include "base/files/memory_mapped_file.h" +#include "base/logging.h" namespace base { diff --git a/base/test/test_file_util_posix.cc b/base/test/test_file_util_posix.cc index cbcabd6..12b892c 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_util.h" #include "base/files/file_path.h" +#include "base/files/file_util.h" #include "base/logging.h" #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" diff --git a/base/test/test_file_util_win.cc b/base/test/test_file_util_win.cc index 2656e31..94eb3ef 100644 --- a/base/test/test_file_util_win.cc +++ b/base/test/test_file_util_win.cc @@ -10,8 +10,8 @@ #include <vector> -#include "base/file_util.h" #include "base/files/file_path.h" +#include "base/files/file_util.h" #include "base/logging.h" #include "base/strings/string_split.h" #include "base/threading/platform_thread.h" diff --git a/base/test/test_suite.cc b/base/test/test_suite.cc index 5777c5d..f12965f 100644 --- a/base/test/test_suite.cc +++ b/base/test/test_suite.cc @@ -11,8 +11,8 @@ #include "base/command_line.h" #include "base/debug/debugger.h" #include "base/debug/stack_trace.h" -#include "base/file_util.h" #include "base/files/file_path.h" +#include "base/files/file_util.h" #include "base/i18n/icu_util.h" #include "base/logging.h" #include "base/memory/scoped_ptr.h" diff --git a/base/win/event_trace_consumer_unittest.cc b/base/win/event_trace_consumer_unittest.cc index 8544f5e..3231240 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_util.h" #include "base/files/file_path.h" +#include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" #include "base/logging.h" #include "base/process/process.h" diff --git a/base/win/event_trace_controller_unittest.cc b/base/win/event_trace_controller_unittest.cc index 4d23edd..8ca9cf5 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_util.h" #include "base/files/file_path.h" +#include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" #include "base/logging.h" #include "base/process/process.h" diff --git a/base/win/shortcut.cc b/base/win/shortcut.cc index 7dace59..f56db9f 100644 --- a/base/win/shortcut.cc +++ b/base/win/shortcut.cc @@ -8,7 +8,7 @@ #include <shlobj.h> #include <propkey.h> -#include "base/file_util.h" +#include "base/files/file_util.h" #include "base/threading/thread_restrictions.h" #include "base/win/scoped_comptr.h" #include "base/win/scoped_propvariant.h" diff --git a/base/win/shortcut_unittest.cc b/base/win/shortcut_unittest.cc index 7a6f41d..53fbd34 100644 --- a/base/win/shortcut_unittest.cc +++ b/base/win/shortcut_unittest.cc @@ -6,8 +6,8 @@ #include <string> -#include "base/file_util.h" #include "base/files/file_path.h" +#include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" #include "base/test/test_file_util.h" #include "base/test/test_shortcut_win.h" |