diff options
63 files changed, 322 insertions, 330 deletions
diff --git a/base/file_util.cc b/base/file_util.cc index 1198636..6140cea 100644 --- a/base/file_util.cc +++ b/base/file_util.cc @@ -167,7 +167,7 @@ bool CreateDirectory(const FilePath& full_path) { bool GetFileSize(const FilePath& file_path, int64* file_size) { PlatformFileInfo info; - if (!file_util::GetFileInfo(file_path, &info)) + if (!GetFileInfo(file_path, &info)) return false; *file_size = info.size; return true; diff --git a/base/file_util.h b/base/file_util.h index 8407f5a..5282888 100644 --- a/base/file_util.h +++ b/base/file_util.h @@ -272,34 +272,33 @@ BASE_EXPORT bool GetFileSize(const FilePath& file_path, int64* file_size); // or if |real_path| would be longer than MAX_PATH characters. BASE_EXPORT bool NormalizeFilePath(const FilePath& path, FilePath* real_path); -} // namespace base - -// ----------------------------------------------------------------------------- - -namespace file_util { - #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 base::FilePath& device_path, - base::FilePath* drive_letter_path); +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 base::FilePath& path, - base::FilePath* nt_path); +BASE_EXPORT bool NormalizeToNativeFilePath(const FilePath& path, + FilePath* nt_path); #endif // This function will return if the given file is a symlink or not. -BASE_EXPORT bool IsLink(const base::FilePath& file_path); +BASE_EXPORT bool IsLink(const FilePath& file_path); // Returns information about the given file path. -BASE_EXPORT bool GetFileInfo(const base::FilePath& file_path, - base::PlatformFileInfo* info); +BASE_EXPORT bool GetFileInfo(const FilePath& file_path, PlatformFileInfo* info); + +} // namespace base + +// ----------------------------------------------------------------------------- + +namespace file_util { // Sets the time of the last access and the time of the last modification. BASE_EXPORT bool TouchFile(const base::FilePath& path, diff --git a/base/file_util_posix.cc b/base/file_util_posix.cc index f3a7553..fdf196e 100644 --- a/base/file_util_posix.cc +++ b/base/file_util_posix.cc @@ -639,40 +639,6 @@ bool NormalizeFilePath(const FilePath& path, FilePath* normalized_path) { return true; } -} // namespace base - -// ----------------------------------------------------------------------------- - -namespace file_util { - -using base::stat_wrapper_t; -using base::CallStat; -using base::CallLstat; -using base::CreateAndOpenFdForTemporaryFile; -using base::DirectoryExists; -using base::FileEnumerator; -using base::FilePath; -using base::MakeAbsoluteFilePath; -using base::VerifySpecificPathControlledByUser; - -base::FilePath MakeUniqueDirectory(const base::FilePath& path) { - const int kMaxAttempts = 20; - for (int attempts = 0; attempts < kMaxAttempts; attempts++) { - int uniquifier = - GetUniquePathNumber(path, base::FilePath::StringType()); - if (uniquifier < 0) - break; - base::FilePath test_path = (uniquifier == 0) ? path : - path.InsertBeforeExtensionASCII( - base::StringPrintf(" (%d)", uniquifier)); - if (mkdir(test_path.value().c_str(), 0777) == 0) - return test_path; - else if (errno != EEXIST) - break; - } - return base::FilePath(); -} - // TODO(rkc): Refactor GetFileInfo and FileEnumerator to handle symlinks // correctly. http://code.google.com/p/chromium-os/issues/detail?id=15948 bool IsLink(const FilePath& file_path) { @@ -688,15 +654,15 @@ bool IsLink(const FilePath& file_path) { return false; } -bool GetFileInfo(const FilePath& file_path, base::PlatformFileInfo* results) { +bool GetFileInfo(const FilePath& file_path, PlatformFileInfo* results) { stat_wrapper_t file_info; #if defined(OS_ANDROID) if (file_path.IsContentUri()) { int fd = OpenContentUriForRead(file_path); if (fd < 0) return false; - ScopedFD scoped_fd(&fd); - if (base::CallFstat(fd, &file_info) != 0) + file_util::ScopedFD scoped_fd(&fd); + if (CallFstat(fd, &file_info) != 0) return false; } else { #endif // defined(OS_ANDROID) @@ -708,21 +674,55 @@ bool GetFileInfo(const FilePath& file_path, base::PlatformFileInfo* results) { results->is_directory = S_ISDIR(file_info.st_mode); results->size = file_info.st_size; #if defined(OS_MACOSX) - results->last_modified = base::Time::FromTimeSpec(file_info.st_mtimespec); - results->last_accessed = base::Time::FromTimeSpec(file_info.st_atimespec); - results->creation_time = base::Time::FromTimeSpec(file_info.st_ctimespec); + results->last_modified = Time::FromTimeSpec(file_info.st_mtimespec); + results->last_accessed = Time::FromTimeSpec(file_info.st_atimespec); + results->creation_time = Time::FromTimeSpec(file_info.st_ctimespec); #elif defined(OS_ANDROID) - results->last_modified = base::Time::FromTimeT(file_info.st_mtime); - results->last_accessed = base::Time::FromTimeT(file_info.st_atime); - results->creation_time = base::Time::FromTimeT(file_info.st_ctime); + results->last_modified = Time::FromTimeT(file_info.st_mtime); + results->last_accessed = Time::FromTimeT(file_info.st_atime); + results->creation_time = Time::FromTimeT(file_info.st_ctime); #else - results->last_modified = base::Time::FromTimeSpec(file_info.st_mtim); - results->last_accessed = base::Time::FromTimeSpec(file_info.st_atim); - results->creation_time = base::Time::FromTimeSpec(file_info.st_ctim); + results->last_modified = Time::FromTimeSpec(file_info.st_mtim); + results->last_accessed = Time::FromTimeSpec(file_info.st_atim); + results->creation_time = Time::FromTimeSpec(file_info.st_ctim); #endif return true; } +} // namespace base + +// ----------------------------------------------------------------------------- + +namespace file_util { + +using base::stat_wrapper_t; +using base::CallStat; +using base::CallLstat; +using base::CreateAndOpenFdForTemporaryFile; +using base::DirectoryExists; +using base::FileEnumerator; +using base::FilePath; +using base::MakeAbsoluteFilePath; +using base::VerifySpecificPathControlledByUser; + +base::FilePath MakeUniqueDirectory(const base::FilePath& path) { + const int kMaxAttempts = 20; + for (int attempts = 0; attempts < kMaxAttempts; attempts++) { + int uniquifier = + GetUniquePathNumber(path, base::FilePath::StringType()); + if (uniquifier < 0) + break; + base::FilePath test_path = (uniquifier == 0) ? path : + path.InsertBeforeExtensionASCII( + base::StringPrintf(" (%d)", uniquifier)); + if (mkdir(test_path.value().c_str(), 0777) == 0) + return test_path; + else if (errno != EEXIST) + break; + } + return base::FilePath(); +} + bool GetInode(const FilePath& path, ino_t* inode) { base::ThreadRestrictions::AssertIOAllowed(); // For call to stat(). struct stat buffer; diff --git a/base/file_util_unittest.cc b/base/file_util_unittest.cc index 0460c6e..38bfbc0 100644 --- a/base/file_util_unittest.cc +++ b/base/file_util_unittest.cc @@ -434,14 +434,13 @@ TEST_F(FileUtilTest, DevicePathToDriveLetter) { // Run DevicePathToDriveLetterPath() on the NT style path we got from // QueryDosDevice(). Expect the drive letter we started with. - ASSERT_TRUE(file_util::DevicePathToDriveLetterPath(actual_device_path, - &win32_path)); + ASSERT_TRUE(DevicePathToDriveLetterPath(actual_device_path, &win32_path)); ASSERT_EQ(real_drive_letter, win32_path.value()); // Add some directories to the path. Expect those extra path componenets // to be preserved. FilePath kRelativePath(FPL("dir1\\dir2\\file.txt")); - ASSERT_TRUE(file_util::DevicePathToDriveLetterPath( + ASSERT_TRUE(DevicePathToDriveLetterPath( actual_device_path.Append(kRelativePath), &win32_path)); EXPECT_EQ(FilePath(real_drive_letter + L"\\").Append(kRelativePath).value(), @@ -459,11 +458,10 @@ TEST_F(FileUtilTest, DevicePathToDriveLetter) { ASSERT_LT(0, new_length); FilePath prefix_of_real_device_path( actual_device_path.value().substr(0, new_length)); - ASSERT_FALSE(file_util::DevicePathToDriveLetterPath( - prefix_of_real_device_path, - &win32_path)); + ASSERT_FALSE(DevicePathToDriveLetterPath(prefix_of_real_device_path, + &win32_path)); - ASSERT_FALSE(file_util::DevicePathToDriveLetterPath( + ASSERT_FALSE(DevicePathToDriveLetterPath( prefix_of_real_device_path.Append(kRelativePath), &win32_path)); @@ -478,11 +476,11 @@ TEST_F(FileUtilTest, DevicePathToDriveLetter) { FilePath real_device_path_plus_numbers( actual_device_path.value() + kExtraChars); - ASSERT_FALSE(file_util::DevicePathToDriveLetterPath( + ASSERT_FALSE(DevicePathToDriveLetterPath( real_device_path_plus_numbers, &win32_path)); - ASSERT_FALSE(file_util::DevicePathToDriveLetterPath( + ASSERT_FALSE(DevicePathToDriveLetterPath( real_device_path_plus_numbers.Append(kRelativePath), &win32_path)); } @@ -696,14 +694,14 @@ TEST_F(FileUtilTest, DeleteSymlinkToNonExistentFile) { << "Failed to create symlink."; // Make sure the symbolic link is exist. - EXPECT_TRUE(file_util::IsLink(file_link)); + EXPECT_TRUE(IsLink(file_link)); EXPECT_FALSE(PathExists(file_link)); // Delete the symbolic link. EXPECT_TRUE(DeleteFile(file_link, false)); // Make sure the symbolic link is deleted. - EXPECT_FALSE(file_util::IsLink(file_link)); + EXPECT_FALSE(IsLink(file_link)); } TEST_F(FileUtilTest, ChangeFilePermissionsAndRead) { @@ -1915,7 +1913,7 @@ TEST_F(FileUtilTest, TouchFile) { ASSERT_TRUE(file_util::TouchFile(foobar, access_time, modification_time)); PlatformFileInfo file_info; - ASSERT_TRUE(file_util::GetFileInfo(foobar, &file_info)); + ASSERT_TRUE(GetFileInfo(foobar, &file_info)); EXPECT_EQ(file_info.last_accessed.ToInternalValue(), access_time.ToInternalValue()); EXPECT_EQ(file_info.last_modified.ToInternalValue(), diff --git a/base/file_util_win.cc b/base/file_util_win.cc index e655204..b9683d6 100644 --- a/base/file_util_win.cc +++ b/base/file_util_win.cc @@ -92,7 +92,7 @@ bool DeleteFile(const FilePath& path, bool recursive) { // If not recursing, then first check to see if |path| is a directory. // If it is, then remove it with RemoveDirectory. PlatformFileInfo file_info; - if (file_util::GetFileInfo(path, &file_info) && file_info.is_directory) + if (GetFileInfo(path, &file_info) && file_info.is_directory) return RemoveDirectory(path.value().c_str()) != 0; // Otherwise, it's a file, wildcard or non-existant. Try DeleteFile first @@ -393,24 +393,113 @@ bool CreateDirectoryAndGetError(const FilePath& full_path, bool NormalizeFilePath(const FilePath& path, FilePath* real_path) { ThreadRestrictions::AssertIOAllowed(); FilePath mapped_file; - if (!file_util::NormalizeToNativeFilePath(path, &mapped_file)) + if (!NormalizeToNativeFilePath(path, &mapped_file)) return false; // NormalizeToNativeFilePath() will return a path that starts with // "\Device\Harddisk...". Helper DevicePathToDriveLetterPath() // will find a drive letter which maps to the path's device, so // that we return a path starting with a drive letter. - return file_util::DevicePathToDriveLetterPath(mapped_file, real_path); + return DevicePathToDriveLetterPath(mapped_file, real_path); } -} // namespace base +bool DevicePathToDriveLetterPath(const FilePath& nt_device_path, + FilePath* out_drive_letter_path) { + ThreadRestrictions::AssertIOAllowed(); -// ----------------------------------------------------------------------------- + // Get the mapping of drive letters to device paths. + const int kDriveMappingSize = 1024; + wchar_t drive_mapping[kDriveMappingSize] = {'\0'}; + if (!::GetLogicalDriveStrings(kDriveMappingSize - 1, drive_mapping)) { + DLOG(ERROR) << "Failed to get drive mapping."; + return false; + } -namespace file_util { + // The drive mapping is a sequence of null terminated strings. + // The last string is empty. + wchar_t* drive_map_ptr = drive_mapping; + wchar_t device_path_as_string[MAX_PATH]; + wchar_t drive[] = L" :"; -using base::DirectoryExists; -using base::FilePath; -using base::kFileShareAll; + // For each string in the drive mapping, get the junction that links + // to it. If that junction is a prefix of |device_path|, then we + // know that |drive| is the real path prefix. + while (*drive_map_ptr) { + drive[0] = drive_map_ptr[0]; // Copy the drive letter. + + if (QueryDosDevice(drive, device_path_as_string, MAX_PATH)) { + FilePath device_path(device_path_as_string); + if (device_path == nt_device_path || + device_path.IsParent(nt_device_path)) { + *out_drive_letter_path = FilePath(drive + + nt_device_path.value().substr(wcslen(device_path_as_string))); + return true; + } + } + // Move to the next drive letter string, which starts one + // increment after the '\0' that terminates the current string. + while (*drive_map_ptr++); + } + + // No drive matched. The path does not start with a device junction + // that is mounted as a drive letter. This means there is no drive + // letter path to the volume that holds |device_path|, so fail. + return false; +} + +bool NormalizeToNativeFilePath(const FilePath& path, FilePath* nt_path) { + ThreadRestrictions::AssertIOAllowed(); + // In Vista, GetFinalPathNameByHandle() would give us the real path + // from a file handle. If we ever deprecate XP, consider changing the + // code below to a call to GetFinalPathNameByHandle(). The method this + // function uses is explained in the following msdn article: + // http://msdn.microsoft.com/en-us/library/aa366789(VS.85).aspx + base::win::ScopedHandle file_handle( + ::CreateFile(path.value().c_str(), + GENERIC_READ, + kFileShareAll, + NULL, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL)); + if (!file_handle) + return false; + + // Create a file mapping object. Can't easily use MemoryMappedFile, because + // we only map the first byte, and need direct access to the handle. You can + // not map an empty file, this call fails in that case. + base::win::ScopedHandle file_map_handle( + ::CreateFileMapping(file_handle.Get(), + NULL, + PAGE_READONLY, + 0, + 1, // Just one byte. No need to look at the data. + NULL)); + if (!file_map_handle) + return false; + + // Use a view of the file to get the path to the file. + void* file_view = MapViewOfFile(file_map_handle.Get(), + FILE_MAP_READ, 0, 0, 1); + if (!file_view) + return false; + + // The expansion of |path| into a full path may make it longer. + // GetMappedFileName() will fail if the result is longer than MAX_PATH. + // Pad a bit to be safe. If kMaxPathLength is ever changed to be less + // than MAX_PATH, it would be nessisary to test that GetMappedFileName() + // not return kMaxPathLength. This would mean that only part of the + // path fit in |mapped_file_path|. + const int kMaxPathLength = MAX_PATH + 10; + wchar_t mapped_file_path[kMaxPathLength]; + bool success = false; + HANDLE cp = GetCurrentProcess(); + if (::GetMappedFileNameW(cp, file_view, mapped_file_path, kMaxPathLength)) { + *nt_path = FilePath(mapped_file_path); + success = true; + } + ::UnmapViewOfFile(file_view); + return success; +} // TODO(rkc): Work out if we want to handle NTFS junctions here or not, handle // them if we do decide to. @@ -418,8 +507,8 @@ bool IsLink(const FilePath& file_path) { return false; } -bool GetFileInfo(const FilePath& file_path, base::PlatformFileInfo* results) { - base::ThreadRestrictions::AssertIOAllowed(); +bool GetFileInfo(const FilePath& file_path, PlatformFileInfo* results) { + ThreadRestrictions::AssertIOAllowed(); WIN32_FILE_ATTRIBUTE_DATA attr; if (!GetFileAttributesEx(file_path.value().c_str(), @@ -434,13 +523,23 @@ bool GetFileInfo(const FilePath& file_path, base::PlatformFileInfo* results) { results->is_directory = (attr.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0; - results->last_modified = base::Time::FromFileTime(attr.ftLastWriteTime); - results->last_accessed = base::Time::FromFileTime(attr.ftLastAccessTime); - results->creation_time = base::Time::FromFileTime(attr.ftCreationTime); + results->last_modified = Time::FromFileTime(attr.ftLastWriteTime); + results->last_accessed = Time::FromFileTime(attr.ftLastAccessTime); + results->creation_time = Time::FromFileTime(attr.ftCreationTime); return true; } +} // namespace base + +// ----------------------------------------------------------------------------- + +namespace file_util { + +using base::DirectoryExists; +using base::FilePath; +using base::kFileShareAll; + FILE* OpenFile(const FilePath& filename, const char* mode) { base::ThreadRestrictions::AssertIOAllowed(); std::wstring w_mode = ASCIIToWide(std::string(mode)); @@ -559,105 +658,6 @@ bool SetCurrentDirectory(const FilePath& directory) { return ret != 0; } -bool DevicePathToDriveLetterPath(const FilePath& nt_device_path, - FilePath* out_drive_letter_path) { - base::ThreadRestrictions::AssertIOAllowed(); - - // Get the mapping of drive letters to device paths. - const int kDriveMappingSize = 1024; - wchar_t drive_mapping[kDriveMappingSize] = {'\0'}; - if (!::GetLogicalDriveStrings(kDriveMappingSize - 1, drive_mapping)) { - DLOG(ERROR) << "Failed to get drive mapping."; - return false; - } - - // The drive mapping is a sequence of null terminated strings. - // The last string is empty. - wchar_t* drive_map_ptr = drive_mapping; - wchar_t device_path_as_string[MAX_PATH]; - wchar_t drive[] = L" :"; - - // For each string in the drive mapping, get the junction that links - // to it. If that junction is a prefix of |device_path|, then we - // know that |drive| is the real path prefix. - while (*drive_map_ptr) { - drive[0] = drive_map_ptr[0]; // Copy the drive letter. - - if (QueryDosDevice(drive, device_path_as_string, MAX_PATH)) { - FilePath device_path(device_path_as_string); - if (device_path == nt_device_path || - device_path.IsParent(nt_device_path)) { - *out_drive_letter_path = FilePath(drive + - nt_device_path.value().substr(wcslen(device_path_as_string))); - return true; - } - } - // Move to the next drive letter string, which starts one - // increment after the '\0' that terminates the current string. - while (*drive_map_ptr++); - } - - // No drive matched. The path does not start with a device junction - // that is mounted as a drive letter. This means there is no drive - // letter path to the volume that holds |device_path|, so fail. - return false; -} - -bool NormalizeToNativeFilePath(const FilePath& path, FilePath* nt_path) { - base::ThreadRestrictions::AssertIOAllowed(); - // In Vista, GetFinalPathNameByHandle() would give us the real path - // from a file handle. If we ever deprecate XP, consider changing the - // code below to a call to GetFinalPathNameByHandle(). The method this - // function uses is explained in the following msdn article: - // http://msdn.microsoft.com/en-us/library/aa366789(VS.85).aspx - base::win::ScopedHandle file_handle( - ::CreateFile(path.value().c_str(), - GENERIC_READ, - kFileShareAll, - NULL, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - NULL)); - if (!file_handle) - return false; - - // Create a file mapping object. Can't easily use MemoryMappedFile, because - // we only map the first byte, and need direct access to the handle. You can - // not map an empty file, this call fails in that case. - base::win::ScopedHandle file_map_handle( - ::CreateFileMapping(file_handle.Get(), - NULL, - PAGE_READONLY, - 0, - 1, // Just one byte. No need to look at the data. - NULL)); - if (!file_map_handle) - return false; - - // Use a view of the file to get the path to the file. - void* file_view = MapViewOfFile(file_map_handle.Get(), - FILE_MAP_READ, 0, 0, 1); - if (!file_view) - return false; - - // The expansion of |path| into a full path may make it longer. - // GetMappedFileName() will fail if the result is longer than MAX_PATH. - // Pad a bit to be safe. If kMaxPathLength is ever changed to be less - // than MAX_PATH, it would be nessisary to test that GetMappedFileName() - // not return kMaxPathLength. This would mean that only part of the - // path fit in |mapped_file_path|. - const int kMaxPathLength = MAX_PATH + 10; - wchar_t mapped_file_path[kMaxPathLength]; - bool success = false; - HANDLE cp = GetCurrentProcess(); - if (::GetMappedFileNameW(cp, file_view, mapped_file_path, kMaxPathLength)) { - *nt_path = FilePath(mapped_file_path); - success = true; - } - ::UnmapViewOfFile(file_view); - return success; -} - int GetMaximumPathComponentLength(const FilePath& path) { base::ThreadRestrictions::AssertIOAllowed(); diff --git a/base/files/file_path_watcher_linux.cc b/base/files/file_path_watcher_linux.cc index 1e986e1..d5052e2 100644 --- a/base/files/file_path_watcher_linux.cc +++ b/base/files/file_path_watcher_linux.cc @@ -446,7 +446,7 @@ bool FilePathWatcherImpl::UpdateWatches() { if (path_valid) { watch_entry->watch_ = g_inotify_reader.Get().AddWatch(path, this); if ((watch_entry->watch_ == InotifyReader::kInvalidWatch) && - file_util::IsLink(path)) { + base::IsLink(path)) { FilePath link; if (ReadSymbolicLink(path, &link)) { if (!link.IsAbsolute()) diff --git a/base/files/file_path_watcher_win.cc b/base/files/file_path_watcher_win.cc index ac092a9..2abbcea 100644 --- a/base/files/file_path_watcher_win.cc +++ b/base/files/file_path_watcher_win.cc @@ -76,11 +76,11 @@ class FilePathWatcherImpl : public FilePathWatcher::PlatformDelegate, // Keep track of the last modified time of the file. We use nulltime // to represent the file not existing. - base::Time last_modified_; + Time last_modified_; // The time at which we processed the first notification with the // |last_modified_| time stamp. - base::Time first_notification_; + Time first_notification_; DISALLOW_COPY_AND_ASSIGN(FilePathWatcherImpl); }; @@ -90,7 +90,7 @@ bool FilePathWatcherImpl::Watch(const FilePath& path, const FilePathWatcher::Callback& callback) { DCHECK(target_.value().empty()); // Can only watch one path. - set_message_loop(base::MessageLoopProxy::current()); + set_message_loop(MessageLoopProxy::current()); callback_ = callback; target_ = path; recursive_watch_ = recursive; @@ -114,8 +114,8 @@ void FilePathWatcherImpl::Cancel() { // Switch to the file thread if necessary so we can stop |watcher_|. if (!message_loop()->BelongsToCurrentThread()) { message_loop()->PostTask(FROM_HERE, - base::Bind(&FilePathWatcher::CancelWatch, - make_scoped_refptr(this))); + Bind(&FilePathWatcher::CancelWatch, + make_scoped_refptr(this))); } else { CancelOnMessageLoopThread(); } @@ -148,12 +148,12 @@ void FilePathWatcherImpl::OnObjectSignaled(HANDLE object) { } // Check whether the event applies to |target_| and notify the callback. - base::PlatformFileInfo file_info; - bool file_exists = file_util::GetFileInfo(target_, &file_info); + PlatformFileInfo file_info; + bool file_exists = GetFileInfo(target_, &file_info); if (file_exists && (last_modified_.is_null() || last_modified_ != file_info.last_modified)) { last_modified_ = file_info.last_modified; - first_notification_ = base::Time::Now(); + first_notification_ = Time::Now(); callback_.Run(target_, false); } else if (file_exists && !first_notification_.is_null()) { // The target's last modification time is equal to what's on record. This @@ -170,14 +170,13 @@ void FilePathWatcherImpl::OnObjectSignaled(HANDLE object) { // clock has advanced one second from the initial notification. After that // interval, client code is guaranteed to having seen the current revision // of the file. - if (base::Time::Now() - first_notification_ > - base::TimeDelta::FromSeconds(1)) { + if (Time::Now() - first_notification_ > TimeDelta::FromSeconds(1)) { // Stop further notifications for this |last_modification_| time stamp. - first_notification_ = base::Time(); + first_notification_ = Time(); } callback_.Run(target_, false); } else if (!file_exists && !last_modified_.is_null()) { - last_modified_ = base::Time(); + last_modified_ = Time(); callback_.Run(target_, false); } @@ -230,10 +229,10 @@ bool FilePathWatcherImpl::UpdateWatch() { if (handle_ != INVALID_HANDLE_VALUE) DestroyWatch(); - base::PlatformFileInfo file_info; - if (file_util::GetFileInfo(target_, &file_info)) { + PlatformFileInfo file_info; + if (GetFileInfo(target_, &file_info)) { last_modified_ = file_info.last_modified; - first_notification_ = base::Time::Now(); + first_notification_ = Time::Now(); } // Start at the target and walk up the directory chain until we succesfully diff --git a/base/files/file_util_proxy.cc b/base/files/file_util_proxy.cc index a36328e..eefb7a1 100644 --- a/base/files/file_util_proxy.cc +++ b/base/files/file_util_proxy.cc @@ -111,7 +111,7 @@ class GetFileInfoHelper { error_ = PLATFORM_FILE_ERROR_NOT_FOUND; return; } - if (!file_util::GetFileInfo(file_path, &file_info_)) + if (!GetFileInfo(file_path, &file_info_)) error_ = PLATFORM_FILE_ERROR_FAILED; } diff --git a/base/files/file_util_proxy_unittest.cc b/base/files/file_util_proxy_unittest.cc index 7691d44..fa4a78c 100644 --- a/base/files/file_util_proxy_unittest.cc +++ b/base/files/file_util_proxy_unittest.cc @@ -226,7 +226,7 @@ TEST_F(FileUtilProxyTest, GetFileInfo_File) { // Setup. ASSERT_EQ(4, file_util::WriteFile(test_path(), "test", 4)); PlatformFileInfo expected_info; - file_util::GetFileInfo(test_path(), &expected_info); + GetFileInfo(test_path(), &expected_info); // Run. FileUtilProxy::GetFileInfo( @@ -249,7 +249,7 @@ TEST_F(FileUtilProxyTest, GetFileInfo_Directory) { // Setup. ASSERT_TRUE(base::CreateDirectory(test_path())); PlatformFileInfo expected_info; - file_util::GetFileInfo(test_path(), &expected_info); + GetFileInfo(test_path(), &expected_info); // Run. FileUtilProxy::GetFileInfo( @@ -342,7 +342,7 @@ TEST_F(FileUtilProxyTest, Touch) { EXPECT_EQ(PLATFORM_FILE_OK, error_); PlatformFileInfo info; - file_util::GetFileInfo(test_path(), &info); + GetFileInfo(test_path(), &info); // The returned values may only have the seconds precision, so we cast // the double values to int here. @@ -357,7 +357,7 @@ TEST_F(FileUtilProxyTest, Truncate_Shrink) { const char kTestData[] = "0123456789"; ASSERT_EQ(10, file_util::WriteFile(test_path(), kTestData, 10)); PlatformFileInfo info; - file_util::GetFileInfo(test_path(), &info); + GetFileInfo(test_path(), &info); ASSERT_EQ(10, info.size); // Run. @@ -369,7 +369,7 @@ TEST_F(FileUtilProxyTest, Truncate_Shrink) { MessageLoop::current()->Run(); // Verify. - file_util::GetFileInfo(test_path(), &info); + GetFileInfo(test_path(), &info); ASSERT_EQ(7, info.size); char buffer[7]; @@ -384,7 +384,7 @@ TEST_F(FileUtilProxyTest, Truncate_Expand) { const char kTestData[] = "9876543210"; ASSERT_EQ(10, file_util::WriteFile(test_path(), kTestData, 10)); PlatformFileInfo info; - file_util::GetFileInfo(test_path(), &info); + GetFileInfo(test_path(), &info); ASSERT_EQ(10, info.size); // Run. @@ -396,7 +396,7 @@ TEST_F(FileUtilProxyTest, Truncate_Expand) { MessageLoop::current()->Run(); // Verify. - file_util::GetFileInfo(test_path(), &info); + GetFileInfo(test_path(), &info); ASSERT_EQ(53, info.size); char buffer[53]; diff --git a/base/nix/mime_util_xdg.cc b/base/nix/mime_util_xdg.cc index a5a97f4..d695d15 100644 --- a/base/nix/mime_util_xdg.cc +++ b/base/nix/mime_util_xdg.cc @@ -32,13 +32,12 @@ class IconTheme; // None of the XDG stuff is thread-safe, so serialize all access under // this lock. -base::LazyInstance<base::Lock>::Leaky - g_mime_util_xdg_lock = LAZY_INSTANCE_INITIALIZER; +LazyInstance<Lock>::Leaky g_mime_util_xdg_lock = LAZY_INSTANCE_INITIALIZER; class MimeUtilConstants { public: typedef std::map<std::string, IconTheme*> IconThemeMap; - typedef std::map<FilePath, base::Time> IconDirMtimeMap; + typedef std::map<FilePath, Time> IconDirMtimeMap; typedef std::vector<std::string> IconFormats; // Specified by XDG icon theme specs. @@ -62,7 +61,7 @@ class MimeUtilConstants { // The default theme. IconTheme* default_themes_[kDefaultThemeNum]; - base::TimeTicks last_check_time_; + TimeTicks last_check_time_; // The current icon theme, usually set through GTK theme integration. std::string icon_theme_name_; @@ -159,7 +158,7 @@ class IconTheme { IconTheme::IconTheme(const std::string& name) : index_theme_loaded_(false) { - base::ThreadRestrictions::AssertIOAllowed(); + ThreadRestrictions::AssertIOAllowed(); // Iterate on all icon directories to find directories of the specified // theme and load the first encountered index.theme. MimeUtilConstants::IconDirMtimeMap::iterator iter; @@ -281,7 +280,7 @@ bool IconTheme::LoadIndexTheme(const FilePath& file) { std::string key, value; std::vector<std::string> r; - base::SplitStringDontTrim(entry, '=', &r); + SplitStringDontTrim(entry, '=', &r); if (r.size() < 2) continue; @@ -385,12 +384,11 @@ bool IconTheme::SetDirectories(const std::string& dirs) { return true; } -bool CheckDirExistsAndGetMtime(const FilePath& dir, - base::Time* last_modified) { +bool CheckDirExistsAndGetMtime(const FilePath& dir, Time* last_modified) { if (!DirectoryExists(dir)) return false; - base::PlatformFileInfo file_info; - if (!file_util::GetFileInfo(dir, &file_info)) + PlatformFileInfo file_info; + if (!GetFileInfo(dir, &file_info)) return false; *last_modified = file_info.last_modified; return true; @@ -398,7 +396,7 @@ bool CheckDirExistsAndGetMtime(const FilePath& dir, // Make sure |dir| exists and add it to the list of icon directories. void TryAddIconDir(const FilePath& dir) { - base::Time last_modified; + Time last_modified; if (!CheckDirExistsAndGetMtime(dir, &last_modified)) return; MimeUtilConstants::GetInstance()->icon_dirs_[dir] = last_modified; @@ -449,15 +447,15 @@ void InitIconDir() { void EnsureUpdated() { MimeUtilConstants* constants = MimeUtilConstants::GetInstance(); if (constants->last_check_time_.is_null()) { - constants->last_check_time_ = base::TimeTicks::Now(); + constants->last_check_time_ = TimeTicks::Now(); InitIconDir(); return; } // Per xdg theme spec, we should check the icon directories every so often // for newly added icons. - base::TimeDelta time_since_last_check = - base::TimeTicks::Now() - constants->last_check_time_; + TimeDelta time_since_last_check = + TimeTicks::Now() - constants->last_check_time_; if (time_since_last_check.InSeconds() > constants->kUpdateIntervalInSeconds) { constants->last_check_time_ += time_since_last_check; @@ -465,7 +463,7 @@ void EnsureUpdated() { MimeUtilConstants::IconDirMtimeMap* icon_dirs = &constants->icon_dirs_; MimeUtilConstants::IconDirMtimeMap::iterator iter; for (iter = icon_dirs->begin(); iter != icon_dirs->end(); ++iter) { - base::Time last_modified; + Time last_modified; if (!CheckDirExistsAndGetMtime(iter->first, &last_modified) || last_modified != iter->second) { rescan_icon_dirs = true; @@ -502,7 +500,7 @@ void InitDefaultThemes() { IconTheme** default_themes = MimeUtilConstants::GetInstance()->default_themes_; - scoped_ptr<base::Environment> env(base::Environment::Create()); + scoped_ptr<Environment> env(Environment::Create()); base::nix::DesktopEnvironment desktop_env = base::nix::GetDesktopEnvironment(env.get()); if (desktop_env == base::nix::DESKTOP_ENVIRONMENT_KDE3 || @@ -577,14 +575,14 @@ MimeUtilConstants::~MimeUtilConstants() { std::string GetFileMimeType(const FilePath& filepath) { if (filepath.empty()) return std::string(); - base::ThreadRestrictions::AssertIOAllowed(); - base::AutoLock scoped_lock(g_mime_util_xdg_lock.Get()); + ThreadRestrictions::AssertIOAllowed(); + AutoLock scoped_lock(g_mime_util_xdg_lock.Get()); return xdg_mime_get_mime_type_from_file_name(filepath.value().c_str()); } std::string GetDataMimeType(const std::string& data) { - base::ThreadRestrictions::AssertIOAllowed(); - base::AutoLock scoped_lock(g_mime_util_xdg_lock.Get()); + ThreadRestrictions::AssertIOAllowed(); + AutoLock scoped_lock(g_mime_util_xdg_lock.Get()); return xdg_mime_get_mime_type_for_data(data.data(), data.length(), NULL); } @@ -599,13 +597,13 @@ void SetIconThemeName(const std::string& name) { } FilePath GetMimeIcon(const std::string& mime_type, size_t size) { - base::ThreadRestrictions::AssertIOAllowed(); + ThreadRestrictions::AssertIOAllowed(); std::vector<std::string> icon_names; std::string icon_name; FilePath icon_file; if (!mime_type.empty()) { - base::AutoLock scoped_lock(g_mime_util_xdg_lock.Get()); + AutoLock scoped_lock(g_mime_util_xdg_lock.Get()); const char *icon = xdg_mime_get_icon(mime_type.c_str()); icon_name = std::string(icon ? icon : ""); } diff --git a/base/sys_info_chromeos.cc b/base/sys_info_chromeos.cc index e0f8b4f..7cf6975 100644 --- a/base/sys_info_chromeos.cc +++ b/base/sys_info_chromeos.cc @@ -56,14 +56,14 @@ class ChromeOSVersionInfo { is_running_on_chromeos_ = false; std::string lsb_release, lsb_release_time_str; - scoped_ptr<base::Environment> env(base::Environment::Create()); + scoped_ptr<Environment> env(Environment::Create()); bool parsed_from_env = env->GetVar(kLsbReleaseKey, &lsb_release) && env->GetVar(kLsbReleaseTimeKey, &lsb_release_time_str); if (parsed_from_env) { double us = 0; if (StringToDouble(lsb_release_time_str, &us)) - lsb_release_time_ = base::Time::FromDoubleT(us); + lsb_release_time_ = Time::FromDoubleT(us); } else { // If the LSB_RELEASE and LSB_RELEASE_TIME environment variables are not // set, fall back to a blocking read of the lsb_release file. This should @@ -71,8 +71,8 @@ class ChromeOSVersionInfo { ThreadRestrictions::ScopedAllowIO allow_io; FilePath path(kLinuxStandardBaseReleaseFile); ReadFileToString(path, &lsb_release); - base::PlatformFileInfo fileinfo; - if (file_util::GetFileInfo(path, &fileinfo)) + PlatformFileInfo fileinfo; + if (GetFileInfo(path, &fileinfo)) lsb_release_time_ = fileinfo.creation_time; } ParseLsbRelease(lsb_release); @@ -97,7 +97,7 @@ class ChromeOSVersionInfo { *bugfix_version = bugfix_version_; } - const base::Time& lsb_release_time() const { return lsb_release_time_; } + const Time& lsb_release_time() const { return lsb_release_time_; } const SysInfo::LsbReleaseMap& lsb_release_map() const { return lsb_release_map_; } @@ -109,7 +109,7 @@ class ChromeOSVersionInfo { // of entries so the overhead for this will be small, and it can be // useful for debugging. std::vector<std::pair<std::string, std::string> > pairs; - base::SplitStringIntoKeyValuePairs(lsb_release, '=', '\n', &pairs); + SplitStringIntoKeyValuePairs(lsb_release, '=', '\n', &pairs); for (size_t i = 0; i < pairs.size(); ++i) { std::string key, value; TrimWhitespaceASCII(pairs[i].first, TRIM_ALL, &key); @@ -151,7 +151,7 @@ class ChromeOSVersionInfo { } } - base::Time lsb_release_time_; + Time lsb_release_time_; SysInfo::LsbReleaseMap lsb_release_map_; int32 major_version_; int32 minor_version_; @@ -196,7 +196,7 @@ std::string SysInfo::GetLsbReleaseBoard() { } // static -base::Time SysInfo::GetLsbReleaseTime() { +Time SysInfo::GetLsbReleaseTime() { return GetChromeOSVersionInfo().lsb_release_time(); } @@ -208,10 +208,10 @@ bool SysInfo::IsRunningOnChromeOS() { // static void SysInfo::SetChromeOSVersionInfoForTest(const std::string& lsb_release, const Time& lsb_release_time) { - scoped_ptr<base::Environment> env(base::Environment::Create()); + scoped_ptr<Environment> env(Environment::Create()); env->SetVar(kLsbReleaseKey, lsb_release); env->SetVar(kLsbReleaseTimeKey, - base::DoubleToString(lsb_release_time.ToDoubleT())); + DoubleToString(lsb_release_time.ToDoubleT())); g_chrome_os_version_info.Get().Parse(); } diff --git a/chrome/browser/browsing_data/browsing_data_database_helper.cc b/chrome/browser/browsing_data/browsing_data_database_helper.cc index 5cd0fb5..8e9f6b8 100644 --- a/chrome/browser/browsing_data/browsing_data_database_helper.cc +++ b/chrome/browser/browsing_data/browsing_data_database_helper.cc @@ -88,7 +88,7 @@ void BrowsingDataDatabaseHelper::FetchDatabaseInfoOnFileThread() { base::FilePath file_path = tracker_->GetFullDBFilePath(ori->GetOriginIdentifier(), *db); base::PlatformFileInfo file_info; - if (file_util::GetFileInfo(file_path, &file_info)) { + if (base::GetFileInfo(file_path, &file_info)) { database_info_.push_back(DatabaseInfo( identifier, UTF16ToUTF8(*db), diff --git a/chrome/browser/chromeos/drive/file_system.cc b/chrome/browser/chromeos/drive/file_system.cc index c8426c9..615f494 100644 --- a/chrome/browser/chromeos/drive/file_system.cc +++ b/chrome/browser/chromeos/drive/file_system.cc @@ -77,7 +77,7 @@ FileError GetLocallyStoredResourceEntry( return error; base::PlatformFileInfo file_info; - if (!file_util::GetFileInfo(local_cache_path, &file_info)) + if (!base::GetFileInfo(local_cache_path, &file_info)) return FILE_ERROR_NOT_FOUND; SetPlatformFileInfoToResourceEntry(file_info, entry); diff --git a/chrome/browser/chromeos/drive/file_system/download_operation.cc b/chrome/browser/chromeos/drive/file_system/download_operation.cc index 2e1aa51..6707102 100644 --- a/chrome/browser/chromeos/drive/file_system/download_operation.cc +++ b/chrome/browser/chromeos/drive/file_system/download_operation.cc @@ -67,7 +67,7 @@ FileError CheckPreConditionForEnsureFileDownloaded( !util::CreateGDocFile(gdoc_file_path, GURL(entry->file_specific_info().alternate_url()), entry->resource_id()) || - !file_util::GetFileInfo(gdoc_file_path, &file_info)) + !base::GetFileInfo(gdoc_file_path, &file_info)) return FILE_ERROR_FAILED; *cache_file_path = gdoc_file_path; @@ -98,7 +98,7 @@ FileError CheckPreConditionForEnsureFileDownloaded( // the drive::FS side is also converted to run fully on blocking pool. if (cache_entry.is_dirty()) { base::PlatformFileInfo file_info; - if (file_util::GetFileInfo(*cache_file_path, &file_info)) + if (base::GetFileInfo(*cache_file_path, &file_info)) SetPlatformFileInfoToResourceEntry(file_info, entry); } diff --git a/chrome/browser/chromeos/extensions/echo_private_api.cc b/chrome/browser/chromeos/extensions/echo_private_api.cc index cf1c11d..505ffc3 100644 --- a/chrome/browser/chromeos/extensions/echo_private_api.cc +++ b/chrome/browser/chromeos/extensions/echo_private_api.cc @@ -171,7 +171,7 @@ bool EchoPrivateGetOobeTimestampFunction::GetOobeTimestampOnFileThread() { const char kOobeTimestampFile[] = "/home/chronos/.oobe_completed"; std::string timestamp = ""; base::PlatformFileInfo fileInfo; - if (file_util::GetFileInfo(base::FilePath(kOobeTimestampFile), &fileInfo)) { + if (base::GetFileInfo(base::FilePath(kOobeTimestampFile), &fileInfo)) { base::Time::Exploded ctime; fileInfo.creation_time.UTCExplode(&ctime); timestamp += base::StringPrintf("%u-%u-%u", diff --git a/chrome/browser/chromeos/extensions/external_cache.cc b/chrome/browser/chromeos/extensions/external_cache.cc index d56d301..9e1ac78 100644 --- a/chrome/browser/chromeos/extensions/external_cache.cc +++ b/chrome/browser/chromeos/extensions/external_cache.cc @@ -309,7 +309,7 @@ void ExternalCache::BackendCheckCacheContentsInternal( base::FileEnumerator::FileInfo info = enumerator.GetInfo(); std::string basename = path.BaseName().value(); - if (info.IsDirectory() || file_util::IsLink(info.GetName())) { + if (info.IsDirectory() || base::IsLink(info.GetName())) { LOG(ERROR) << "Erasing bad file in ExternalCache directory: " << basename; base::DeleteFile(path, true /* recursive */); continue; diff --git a/chrome/browser/chromeos/file_manager/file_browser_handlers.cc b/chrome/browser/chromeos/file_manager/file_browser_handlers.cc index 4ec8220..8adbe5f 100644 --- a/chrome/browser/chromeos/file_manager/file_browser_handlers.cc +++ b/chrome/browser/chromeos/file_manager/file_browser_handlers.cc @@ -250,8 +250,8 @@ FileBrowserHandlerExecutor::SetupFileAccessPermissions( // found on the url.path(). if (!is_drive_file) { if (!base::PathExists(local_path) || - file_util::IsLink(local_path) || - !file_util::GetFileInfo(local_path, &file_info)) { + base::IsLink(local_path) || + !base::GetFileInfo(local_path, &file_info)) { continue; } } diff --git a/chrome/browser/extensions/api/file_handlers/app_file_handler_util.cc b/chrome/browser/extensions/api/file_handlers/app_file_handler_util.cc index ca64e69..505c72d 100644 --- a/chrome/browser/extensions/api/file_handlers/app_file_handler_util.cc +++ b/chrome/browser/extensions/api/file_handlers/app_file_handler_util.cc @@ -61,7 +61,7 @@ bool FileHandlerCanHandleFileWithMimeType( bool DoCheckWritableFile(const base::FilePath& path, bool is_directory) { // Don't allow links. - if (base::PathExists(path) && file_util::IsLink(path)) + if (base::PathExists(path) && base::IsLink(path)) return false; if (is_directory) diff --git a/chrome/browser/extensions/extension_protocols.cc b/chrome/browser/extensions/extension_protocols.cc index 2b24eea..30a0cf2 100644 --- a/chrome/browser/extensions/extension_protocols.cc +++ b/chrome/browser/extensions/extension_protocols.cc @@ -232,7 +232,7 @@ class GeneratedBackgroundPageJob : public net::URLRequestSimpleJob { base::Time GetFileLastModifiedTime(const base::FilePath& filename) { if (base::PathExists(filename)) { base::PlatformFileInfo info; - if (file_util::GetFileInfo(filename, &info)) + if (base::GetFileInfo(filename, &info)) return info.last_modified; } return base::Time(); @@ -241,7 +241,7 @@ base::Time GetFileLastModifiedTime(const base::FilePath& filename) { base::Time GetFileCreationTime(const base::FilePath& filename) { if (base::PathExists(filename)) { base::PlatformFileInfo info; - if (file_util::GetFileInfo(filename, &info)) + if (base::GetFileInfo(filename, &info)) return info.creation_time; } return base::Time(); diff --git a/chrome/browser/first_run/upgrade_util_linux.cc b/chrome/browser/first_run/upgrade_util_linux.cc index 8d6d8a9..8a7618d 100644 --- a/chrome/browser/first_run/upgrade_util_linux.cc +++ b/chrome/browser/first_run/upgrade_util_linux.cc @@ -41,7 +41,7 @@ double GetLastModifiedTimeOfExe() { return saved_last_modified_time_of_exe; } base::PlatformFileInfo exe_file_info; - if (!file_util::GetFileInfo(exe_file_path, &exe_file_info)) { + if (!base::GetFileInfo(exe_file_path, &exe_file_info)) { LOG(WARNING) << "Failed to get FileInfo object for FILE_EXE - " << exe_file_path.value(); return saved_last_modified_time_of_exe; diff --git a/chrome/browser/media_galleries/fileapi/iapps_finder_impl_mac.mm b/chrome/browser/media_galleries/fileapi/iapps_finder_impl_mac.mm index bf0e5af..04abf15 100644 --- a/chrome/browser/media_galleries/fileapi/iapps_finder_impl_mac.mm +++ b/chrome/browser/media_galleries/fileapi/iapps_finder_impl_mac.mm @@ -57,7 +57,7 @@ void FindMostRecentDatabase( continue; base::PlatformFileInfo file_info; - if (!file_util::GetFileInfo(db_path, &file_info)) + if (!base::GetFileInfo(db_path, &file_info)) continue; // In case of two databases with the same modified time, tie breaker goes diff --git a/chrome/browser/media_galleries/fileapi/iphoto_file_util.cc b/chrome/browser/media_galleries/fileapi/iphoto_file_util.cc index c2df495..e4fdde4 100644 --- a/chrome/browser/media_galleries/fileapi/iphoto_file_util.cc +++ b/chrome/browser/media_galleries/fileapi/iphoto_file_util.cc @@ -249,7 +249,7 @@ base::PlatformFileError IPhotoFileUtil::ReadDirectorySync( locations.begin(); it != locations.end(); it++) { base::PlatformFileInfo info; - if (!file_util::GetFileInfo(it->second, &info)) + if (!base::GetFileInfo(it->second, &info)) return base::PLATFORM_FILE_ERROR_IO; file_list->push_back(DirectoryEntry(it->first, DirectoryEntry::FILE, info.size, info.last_modified)); @@ -264,7 +264,7 @@ base::PlatformFileError IPhotoFileUtil::ReadDirectorySync( originals.begin(); it != originals.end(); it++) { base::PlatformFileInfo info; - if (!file_util::GetFileInfo(it->second, &info)) + if (!base::GetFileInfo(it->second, &info)) return base::PLATFORM_FILE_ERROR_IO; file_list->push_back(DirectoryEntry(it->first, DirectoryEntry::FILE, info.size, info.last_modified)); diff --git a/chrome/browser/media_galleries/fileapi/itunes_file_util.cc b/chrome/browser/media_galleries/fileapi/itunes_file_util.cc index 316dd32..12fba52 100644 --- a/chrome/browser/media_galleries/fileapi/itunes_file_util.cc +++ b/chrome/browser/media_galleries/fileapi/itunes_file_util.cc @@ -159,7 +159,7 @@ base::PlatformFileError ITunesFileUtil::ReadDirectorySync( if (components.size() == 0) { base::PlatformFileInfo xml_info; - if (!file_util::GetFileInfo(GetDataProvider()->library_path(), &xml_info)) + if (!base::GetFileInfo(GetDataProvider()->library_path(), &xml_info)) return base::PLATFORM_FILE_ERROR_IO; file_list->push_back(DirectoryEntry(kITunesLibraryXML, DirectoryEntry::FILE, @@ -227,7 +227,7 @@ base::PlatformFileError ITunesFileUtil::ReadDirectorySync( for (it = album.begin(); it != album.end(); ++it) { base::PlatformFileInfo file_info; if (media_path_filter()->Match(it->second) && - file_util::GetFileInfo(it->second, &file_info)) { + base::GetFileInfo(it->second, &file_info)) { file_list->push_back(DirectoryEntry(it->first, DirectoryEntry::FILE, file_info.size, file_info.last_modified)); diff --git a/chrome/browser/media_galleries/fileapi/native_media_file_util.cc b/chrome/browser/media_galleries/fileapi/native_media_file_util.cc index 21e1efa..086b4b9 100644 --- a/chrome/browser/media_galleries/fileapi/native_media_file_util.cc +++ b/chrome/browser/media_galleries/fileapi/native_media_file_util.cc @@ -494,7 +494,7 @@ base::PlatformFileError NativeMediaFileUtil::GetFileInfoSync( base::PlatformFileError error = GetLocalFilePath(context, url, &file_path); if (error != base::PLATFORM_FILE_OK) return error; - if (file_util::IsLink(file_path)) + if (base::IsLink(file_path)) return base::PLATFORM_FILE_ERROR_NOT_FOUND; error = fileapi::NativeFileUtil::GetFileInfo(file_path, file_info); if (error != base::PLATFORM_FILE_OK) @@ -549,7 +549,7 @@ base::PlatformFileError NativeMediaFileUtil::ReadDirectorySync( !enum_path.empty(); enum_path = file_enum.Next()) { // Skip symlinks. - if (file_util::IsLink(enum_path)) + if (base::IsLink(enum_path)) continue; base::FileEnumerator::FileInfo info = file_enum.GetInfo(); @@ -651,7 +651,7 @@ NativeMediaFileUtil::GetFilteredLocalFilePathForExistingFileOrDirectory( if (!base::PathExists(file_path)) return failure_error; base::PlatformFileInfo file_info; - if (!file_util::GetFileInfo(file_path, &file_info)) + if (!base::GetFileInfo(file_path, &file_info)) return base::PLATFORM_FILE_ERROR_FAILED; if (!file_info.is_directory && diff --git a/chrome/browser/password_manager/password_store_x_unittest.cc b/chrome/browser/password_manager/password_store_x_unittest.cc index aae8733..253a23a 100644 --- a/chrome/browser/password_manager/password_store_x_unittest.cc +++ b/chrome/browser/password_manager/password_store_x_unittest.cc @@ -378,7 +378,7 @@ TEST_P(PasswordStoreXTest, NativeMigration) { // This will be used later to make sure it gets back to this size. const base::FilePath login_db_file = temp_dir_.path().Append("login_test"); base::PlatformFileInfo db_file_start_info; - ASSERT_TRUE(file_util::GetFileInfo(login_db_file, &db_file_start_info)); + ASSERT_TRUE(base::GetFileInfo(login_db_file, &db_file_start_info)); LoginDatabase* login_db = login_db_.get(); @@ -394,7 +394,7 @@ TEST_P(PasswordStoreXTest, NativeMigration) { // Get the new size of the login DB file. We expect it to be larger. base::PlatformFileInfo db_file_full_info; - ASSERT_TRUE(file_util::GetFileInfo(login_db_file, &db_file_full_info)); + ASSERT_TRUE(base::GetFileInfo(login_db_file, &db_file_full_info)); EXPECT_GT(db_file_full_info.size, db_file_start_info.size); // Initializing the PasswordStore shouldn't trigger a native migration (yet). @@ -468,7 +468,7 @@ TEST_P(PasswordStoreXTest, NativeMigration) { // size is equal to the size before we populated it, even though it was // larger after populating it. base::PlatformFileInfo db_file_end_info; - ASSERT_TRUE(file_util::GetFileInfo(login_db_file, &db_file_end_info)); + ASSERT_TRUE(base::GetFileInfo(login_db_file, &db_file_end_info)); EXPECT_EQ(db_file_start_info.size, db_file_end_info.size); } diff --git a/chrome/browser/policy/cloud/resource_cache.cc b/chrome/browser/policy/cloud/resource_cache.cc index 4a9932a..0ee7e3a 100644 --- a/chrome/browser/policy/cloud/resource_cache.cc +++ b/chrome/browser/policy/cloud/resource_cache.cc @@ -94,7 +94,7 @@ bool ResourceCache::Load(const std::string& key, base::FilePath subkey_path; // Only read from |subkey_path| if it is not a symlink. if (!VerifyKeyPathAndGetSubkeyPath(key, false, subkey, &subkey_path) || - file_util::IsLink(subkey_path)) { + base::IsLink(subkey_path)) { return false; } data->clear(); @@ -118,7 +118,7 @@ void ResourceCache::LoadAllSubkeys( std::string data; // Only read from |subkey_path| if it is not a symlink and its name is // a base64-encoded string. - if (!file_util::IsLink(path) && + if (!base::IsLink(path) && Base64Decode(encoded_subkey, &subkey) && base::ReadFileToString(path, &data)) { (*contents)[subkey].swap(data); diff --git a/chrome/browser/policy/config_dir_policy_loader.cc b/chrome/browser/policy/config_dir_policy_loader.cc index ea7f4ff..b35064d 100644 --- a/chrome/browser/policy/config_dir_policy_loader.cc +++ b/chrome/browser/policy/config_dir_policy_loader.cc @@ -98,7 +98,7 @@ base::Time ConfigDirPolicyLoader::LastModificationTime() { base::FilePath path(config_dir_.Append(kConfigDirSuffixes[i])); // Skip if the file doesn't exist, or it isn't a directory. - if (!file_util::GetFileInfo(path, &info) || !info.is_directory) + if (!base::GetFileInfo(path, &info) || !info.is_directory) continue; // Enumerate the files and find the most recent modification timestamp. @@ -107,7 +107,7 @@ base::Time ConfigDirPolicyLoader::LastModificationTime() { for (base::FilePath config_file = file_enumerator.Next(); !config_file.empty(); config_file = file_enumerator.Next()) { - if (file_util::GetFileInfo(config_file, &info) && !info.is_directory) + if (base::GetFileInfo(config_file, &info) && !info.is_directory) last_modification = std::max(last_modification, info.last_modified); } } diff --git a/chrome/browser/policy/policy_loader_mac.cc b/chrome/browser/policy/policy_loader_mac.cc index 3355c83..04a5e6f 100644 --- a/chrome/browser/policy/policy_loader_mac.cc +++ b/chrome/browser/policy/policy_loader_mac.cc @@ -120,7 +120,7 @@ scoped_ptr<PolicyBundle> PolicyLoaderMac::Load() { base::Time PolicyLoaderMac::LastModificationTime() { base::PlatformFileInfo file_info; - if (!file_util::GetFileInfo(managed_policy_path_, &file_info) || + if (!base::GetFileInfo(managed_policy_path_, &file_info) || file_info.is_directory) { return base::Time(); } diff --git a/chrome/browser/safe_browsing/safe_browsing_database.cc b/chrome/browser/safe_browsing/safe_browsing_database.cc index 8aa5dad..3eef5a9 100644 --- a/chrome/browser/safe_browsing/safe_browsing_database.cc +++ b/chrome/browser/safe_browsing/safe_browsing_database.cc @@ -612,7 +612,7 @@ void SafeBrowsingDatabaseNew::Init(const base::FilePath& filename_base) { // If there is no database, the filter cannot be used. base::PlatformFileInfo db_info; - if (file_util::GetFileInfo(side_effect_free_whitelist_filename_, &db_info) + if (base::GetFileInfo(side_effect_free_whitelist_filename_, &db_info) && db_info.size != 0) { const base::TimeTicks before = base::TimeTicks::Now(); side_effect_free_whitelist_prefix_set_.reset( @@ -1609,7 +1609,7 @@ void SafeBrowsingDatabaseNew::LoadPrefixSet() { // If there is no database, the filter cannot be used. base::PlatformFileInfo db_info; - if (!file_util::GetFileInfo(browse_filename_, &db_info) || db_info.size == 0) + if (!base::GetFileInfo(browse_filename_, &db_info) || db_info.size == 0) return; // Cleanup any stale bloom filter (no longer used). diff --git a/chrome/browser/safe_browsing/safe_browsing_database_unittest.cc b/chrome/browser/safe_browsing/safe_browsing_database_unittest.cc index 94b71bd..8d3f21f 100644 --- a/chrome/browser/safe_browsing/safe_browsing_database_unittest.cc +++ b/chrome/browser/safe_browsing/safe_browsing_database_unittest.cc @@ -1636,7 +1636,7 @@ TEST_F(SafeBrowsingDatabaseTest, EmptyUpdate) { // Get an older time to reset the lastmod time for detecting whether // the file has been updated. base::PlatformFileInfo before_info, after_info; - ASSERT_TRUE(file_util::GetFileInfo(filename, &before_info)); + ASSERT_TRUE(base::GetFileInfo(filename, &before_info)); const base::Time old_last_modified = before_info.last_modified - base::TimeDelta::FromSeconds(10); @@ -1644,7 +1644,7 @@ TEST_F(SafeBrowsingDatabaseTest, EmptyUpdate) { // needed because otherwise the entire test can finish w/in the // resolution of the lastmod time. ASSERT_TRUE(file_util::SetLastModifiedTime(filename, old_last_modified)); - ASSERT_TRUE(file_util::GetFileInfo(filename, &before_info)); + ASSERT_TRUE(base::GetFileInfo(filename, &before_info)); EXPECT_TRUE(database_->UpdateStarted(&lists)); chunk.hosts.clear(); InsertAddChunkHostPrefixUrl(&chunk, 2, "www.foo.com/", @@ -1653,25 +1653,25 @@ TEST_F(SafeBrowsingDatabaseTest, EmptyUpdate) { chunks.push_back(chunk); database_->InsertChunks(safe_browsing_util::kMalwareList, chunks); database_->UpdateFinished(true); - ASSERT_TRUE(file_util::GetFileInfo(filename, &after_info)); + ASSERT_TRUE(base::GetFileInfo(filename, &after_info)); EXPECT_LT(before_info.last_modified, after_info.last_modified); // Deleting a chunk updates the database file. ASSERT_TRUE(file_util::SetLastModifiedTime(filename, old_last_modified)); - ASSERT_TRUE(file_util::GetFileInfo(filename, &before_info)); + ASSERT_TRUE(base::GetFileInfo(filename, &before_info)); EXPECT_TRUE(database_->UpdateStarted(&lists)); AddDelChunk(safe_browsing_util::kMalwareList, chunk.chunk_number); database_->UpdateFinished(true); - ASSERT_TRUE(file_util::GetFileInfo(filename, &after_info)); + ASSERT_TRUE(base::GetFileInfo(filename, &after_info)); EXPECT_LT(before_info.last_modified, after_info.last_modified); // Simply calling |UpdateStarted()| then |UpdateFinished()| does not // update the database file. ASSERT_TRUE(file_util::SetLastModifiedTime(filename, old_last_modified)); - ASSERT_TRUE(file_util::GetFileInfo(filename, &before_info)); + ASSERT_TRUE(base::GetFileInfo(filename, &before_info)); EXPECT_TRUE(database_->UpdateStarted(&lists)); database_->UpdateFinished(true); - ASSERT_TRUE(file_util::GetFileInfo(filename, &after_info)); + ASSERT_TRUE(base::GetFileInfo(filename, &after_info)); EXPECT_EQ(before_info.last_modified, after_info.last_modified); } diff --git a/chrome/browser/ui/pdf/pdf_browsertest.cc b/chrome/browser/ui/pdf/pdf_browsertest.cc index 1a51904..784741b 100644 --- a/chrome/browser/ui/pdf/pdf_browsertest.cc +++ b/chrome/browser/ui/pdf/pdf_browsertest.cc @@ -130,7 +130,7 @@ class PDFBrowserTest : public InProcessBrowserTest, GetPDFTestDir(), base::FilePath().AppendASCII(expected_filename_)); base::PlatformFileInfo info; - ASSERT_TRUE(file_util::GetFileInfo(reference, &info)); + ASSERT_TRUE(base::GetFileInfo(reference, &info)); int size = static_cast<size_t>(info.size); scoped_ptr<char[]> data(new char[size]); ASSERT_EQ(size, file_util::ReadFile(reference, data.get(), size)); diff --git a/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc b/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc index 4876a46..096f368 100644 --- a/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc +++ b/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc @@ -80,7 +80,7 @@ void GetGCacheContents(const base::FilePath& root_path, base::FileEnumerator::FileInfo info = enumerator.GetInfo(); int64 size = info.GetSize(); const bool is_directory = info.IsDirectory(); - const bool is_symbolic_link = file_util::IsLink(info.GetName()); + const bool is_symbolic_link = base::IsLink(info.GetName()); const base::Time last_modified = info.GetLastModifiedTime(); base::DictionaryValue* entry = new base::DictionaryValue; diff --git a/chrome/installer/util/duplicate_tree_detector.cc b/chrome/installer/util/duplicate_tree_detector.cc index 62d9b51..a55c048 100644 --- a/chrome/installer/util/duplicate_tree_detector.cc +++ b/chrome/installer/util/duplicate_tree_detector.cc @@ -17,8 +17,8 @@ bool IsIdenticalFileHierarchy(const base::FilePath& src_path, base::PlatformFileInfo dest_info; bool is_identical = false; - if (file_util::GetFileInfo(src_path, &src_info) && - file_util::GetFileInfo(dest_path, &dest_info)) { + if (base::GetFileInfo(src_path, &src_info) && + base::GetFileInfo(dest_path, &dest_info)) { // Both paths exist, check the types: if (!src_info.is_directory && !dest_info.is_directory) { // Two files are "identical" if the file sizes are equivalent. diff --git a/content/browser/fileapi/blob_url_request_job_unittest.cc b/content/browser/fileapi/blob_url_request_job_unittest.cc index 607bb10..a09456b 100644 --- a/content/browser/fileapi/blob_url_request_job_unittest.cc +++ b/content/browser/fileapi/blob_url_request_job_unittest.cc @@ -146,7 +146,7 @@ class BlobURLRequestJobTest : public testing::Test { file_util::WriteFile(temp_file1_, kTestFileData1, arraysize(kTestFileData1) - 1)); base::PlatformFileInfo file_info1; - file_util::GetFileInfo(temp_file1_, &file_info1); + base::GetFileInfo(temp_file1_, &file_info1); temp_file_modification_time1_ = file_info1.last_modified; temp_file2_ = temp_dir_.path().AppendASCII("BlobFile2.dat"); @@ -154,7 +154,7 @@ class BlobURLRequestJobTest : public testing::Test { file_util::WriteFile(temp_file2_, kTestFileData2, arraysize(kTestFileData2) - 1)); base::PlatformFileInfo file_info2; - file_util::GetFileInfo(temp_file2_, &file_info2); + base::GetFileInfo(temp_file2_, &file_info2); temp_file_modification_time2_ = file_info2.last_modified; url_request_job_factory_.SetProtocolHandler("blob", diff --git a/content/browser/fileapi/dragged_file_util_unittest.cc b/content/browser/fileapi/dragged_file_util_unittest.cc index 3c34bec..17b29cc 100644 --- a/content/browser/fileapi/dragged_file_util_unittest.cc +++ b/content/browser/fileapi/dragged_file_util_unittest.cc @@ -326,8 +326,7 @@ TEST_F(DraggedFileUtilTest, UnregisteredPathsTest) { // Make sure regular GetFileInfo succeeds. base::PlatformFileInfo info; - ASSERT_TRUE(file_util::GetFileInfo( - root_path().Append(test_case.path), &info)); + ASSERT_TRUE(base::GetFileInfo(root_path().Append(test_case.path), &info)); if (!test_case.is_directory) ASSERT_EQ(test_case.data_file_size, info.size); ASSERT_EQ(test_case.is_directory, info.is_directory); diff --git a/content/browser/fileapi/file_system_operation_impl_unittest.cc b/content/browser/fileapi/file_system_operation_impl_unittest.cc index 06489b8..236cc8e 100644 --- a/content/browser/fileapi/file_system_operation_impl_unittest.cc +++ b/content/browser/fileapi/file_system_operation_impl_unittest.cc @@ -159,7 +159,7 @@ class FileSystemOperationImplTest int64 GetFileSize(const std::string& path) { base::PlatformFileInfo info; - EXPECT_TRUE(file_util::GetFileInfo(PlatformPath(path), &info)); + EXPECT_TRUE(base::GetFileInfo(PlatformPath(path), &info)); return info.size; } @@ -1065,7 +1065,7 @@ TEST_F(FileSystemOperationImplTest, TestTouchFile) { base::FilePath platform_path = PlatformPath("file"); base::PlatformFileInfo info; - EXPECT_TRUE(file_util::GetFileInfo(platform_path, &info)); + EXPECT_TRUE(base::GetFileInfo(platform_path, &info)); EXPECT_FALSE(info.is_directory); EXPECT_EQ(0, info.size); const base::Time last_modified = info.last_modified; @@ -1083,7 +1083,7 @@ TEST_F(FileSystemOperationImplTest, TestTouchFile) { EXPECT_EQ(base::PLATFORM_FILE_OK, status()); EXPECT_TRUE(change_observer()->HasNoChange()); - EXPECT_TRUE(file_util::GetFileInfo(platform_path, &info)); + EXPECT_TRUE(base::GetFileInfo(platform_path, &info)); // We compare as time_t here to lower our resolution, to avoid false // negatives caused by conversion to the local filesystem's native // representation and back. diff --git a/content/browser/fileapi/local_file_util_unittest.cc b/content/browser/fileapi/local_file_util_unittest.cc index fd28035..40995d6 100644 --- a/content/browser/fileapi/local_file_util_unittest.cc +++ b/content/browser/fileapi/local_file_util_unittest.cc @@ -85,7 +85,7 @@ class LocalFileUtilTest : public testing::Test { int64 GetSize(const char *file_name) { base::PlatformFileInfo info; - file_util::GetFileInfo(LocalPath(file_name), &info); + base::GetFileInfo(LocalPath(file_name), &info); return info.size; } @@ -192,7 +192,7 @@ TEST_F(LocalFileUtilTest, TouchFile) { scoped_ptr<FileSystemOperationContext> context(NewContext()); base::PlatformFileInfo info; - ASSERT_TRUE(file_util::GetFileInfo(LocalPath(file_name), &info)); + ASSERT_TRUE(base::GetFileInfo(LocalPath(file_name), &info)); const base::Time new_accessed = info.last_accessed + base::TimeDelta::FromHours(10); const base::Time new_modified = @@ -202,7 +202,7 @@ TEST_F(LocalFileUtilTest, TouchFile) { file_util()->Touch(context.get(), CreateURL(file_name), new_accessed, new_modified)); - ASSERT_TRUE(file_util::GetFileInfo(LocalPath(file_name), &info)); + ASSERT_TRUE(base::GetFileInfo(LocalPath(file_name), &info)); EXPECT_EQ(new_accessed, info.last_accessed); EXPECT_EQ(new_modified, info.last_modified); @@ -220,7 +220,7 @@ TEST_F(LocalFileUtilTest, TouchDirectory) { false /* recursive */)); base::PlatformFileInfo info; - ASSERT_TRUE(file_util::GetFileInfo(LocalPath(dir_name), &info)); + ASSERT_TRUE(base::GetFileInfo(LocalPath(dir_name), &info)); const base::Time new_accessed = info.last_accessed + base::TimeDelta::FromHours(10); const base::Time new_modified = @@ -230,7 +230,7 @@ TEST_F(LocalFileUtilTest, TouchDirectory) { file_util()->Touch(context.get(), CreateURL(dir_name), new_accessed, new_modified)); - ASSERT_TRUE(file_util::GetFileInfo(LocalPath(dir_name), &info)); + ASSERT_TRUE(base::GetFileInfo(LocalPath(dir_name), &info)); EXPECT_EQ(new_accessed, info.last_accessed); EXPECT_EQ(new_modified, info.last_modified); } diff --git a/content/browser/indexed_db/indexed_db_context_impl.cc b/content/browser/indexed_db/indexed_db_context_impl.cc index 37548c8..521b526 100644 --- a/content/browser/indexed_db/indexed_db_context_impl.cc +++ b/content/browser/indexed_db/indexed_db_context_impl.cc @@ -295,7 +295,7 @@ base::Time IndexedDBContextImpl::GetOriginLastModified(const GURL& origin_url) { return base::Time(); base::FilePath idb_directory = GetFilePath(origin_url); base::PlatformFileInfo file_info; - if (!file_util::GetFileInfo(idb_directory, &file_info)) + if (!base::GetFileInfo(idb_directory, &file_info)) return base::Time(); return file_info.last_modified; } diff --git a/content/browser/net/sqlite_persistent_cookie_store_unittest.cc b/content/browser/net/sqlite_persistent_cookie_store_unittest.cc index 4adb790..49ac64b 100644 --- a/content/browser/net/sqlite_persistent_cookie_store_unittest.cc +++ b/content/browser/net/sqlite_persistent_cookie_store_unittest.cc @@ -289,7 +289,7 @@ TEST_F(SQLitePersistentCookieStoreTest, TestFlush) { // whether the DB file has been modified by checking its size. base::FilePath path = temp_dir_.path().Append(kCookieFilename); base::PlatformFileInfo info; - ASSERT_TRUE(file_util::GetFileInfo(path, &info)); + ASSERT_TRUE(base::GetFileInfo(path, &info)); int64 base_size = info.size; // Write some large cookies, so the DB will have to expand by several KB. @@ -304,7 +304,7 @@ TEST_F(SQLitePersistentCookieStoreTest, TestFlush) { Flush(); // We forced a write, so now the file will be bigger. - ASSERT_TRUE(file_util::GetFileInfo(path, &info)); + ASSERT_TRUE(base::GetFileInfo(path, &info)); ASSERT_GT(info.size, base_size); } diff --git a/content/browser/renderer_host/file_utilities_message_filter.cc b/content/browser/renderer_host/file_utilities_message_filter.cc index 65645e0..5daa6ff 100644 --- a/content/browser/renderer_host/file_utilities_message_filter.cc +++ b/content/browser/renderer_host/file_utilities_message_filter.cc @@ -48,7 +48,7 @@ void FileUtilitiesMessageFilter::OnGetFileInfo( return; } - if (!file_util::GetFileInfo(path, result)) + if (!base::GetFileInfo(path, result)) *status = base::PLATFORM_FILE_ERROR_FAILED; } diff --git a/content/browser/renderer_host/pepper/pepper_flash_file_message_filter.cc b/content/browser/renderer_host/pepper/pepper_flash_file_message_filter.cc index 9c02fd1..ba8a8b9 100644 --- a/content/browser/renderer_host/pepper/pepper_flash_file_message_filter.cc +++ b/content/browser/renderer_host/pepper/pepper_flash_file_message_filter.cc @@ -210,7 +210,7 @@ int32_t PepperFlashFileMessageFilter::OnQueryFile( } base::PlatformFileInfo info; - bool result = file_util::GetFileInfo(full_path, &info); + bool result = base::GetFileInfo(full_path, &info); context->reply_msg = PpapiPluginMsg_FlashFile_QueryFileReply(info); return ppapi::PlatformFileErrorToPepperError(result ? base::PLATFORM_FILE_OK : base::PLATFORM_FILE_ERROR_ACCESS_DENIED); diff --git a/content/child/npapi/plugin_host.cc b/content/child/npapi/plugin_host.cc index 22fe6d0..e53f900 100644 --- a/content/child/npapi/plugin_host.cc +++ b/content/child/npapi/plugin_host.cc @@ -470,7 +470,7 @@ static NPError PostURLNotify(NPP id, } base::PlatformFileInfo post_file_info; - if (!file_util::GetFileInfo(file_path, &post_file_info) || + if (!base::GetFileInfo(file_path, &post_file_info) || post_file_info.is_directory) return NPERR_FILE_NOT_FOUND; diff --git a/content/common/plugin_list_posix.cc b/content/common/plugin_list_posix.cc index 47856b3..afe35d2 100644 --- a/content/common/plugin_list_posix.cc +++ b/content/common/plugin_list_posix.cc @@ -545,7 +545,7 @@ void PluginList::GetPluginsInDir( // Get mtime. base::PlatformFileInfo info; - if (!file_util::GetFileInfo(path, &info)) + if (!base::GetFileInfo(path, &info)) continue; files.push_back(std::make_pair(path, info.last_modified)); diff --git a/net/base/upload_data_stream_unittest.cc b/net/base/upload_data_stream_unittest.cc index 0dca21e..24855a8 100644 --- a/net/base/upload_data_stream_unittest.cc +++ b/net/base/upload_data_stream_unittest.cc @@ -555,7 +555,7 @@ TEST_F(UploadDataStreamTest, FileChanged) { file_util::WriteFile(temp_file_path, kTestData, kTestDataSize)); base::PlatformFileInfo file_info; - ASSERT_TRUE(file_util::GetFileInfo(temp_file_path, &file_info)); + ASSERT_TRUE(base::GetFileInfo(temp_file_path, &file_info)); // Test file not changed. FileChangedHelper(temp_file_path, file_info.last_modified, false); diff --git a/net/base/upload_file_element_reader.cc b/net/base/upload_file_element_reader.cc index e7bf0c12..ab7dd9e 100644 --- a/net/base/upload_file_element_reader.cc +++ b/net/base/upload_file_element_reader.cc @@ -62,7 +62,7 @@ int InitInternal(const base::FilePath& path, // time_t to compare. This check is used for sliced files. if (!expected_modification_time.is_null()) { base::PlatformFileInfo info; - if (!file_util::GetFileInfo(path, &info)) { + if (!base::GetFileInfo(path, &info)) { DLOG(WARNING) << "Failed to get file info of \"" << path.value() << "\""; return ERR_FILE_NOT_FOUND; } diff --git a/net/base/upload_file_element_reader_unittest.cc b/net/base/upload_file_element_reader_unittest.cc index 3e7c110..f3ccb41 100644 --- a/net/base/upload_file_element_reader_unittest.cc +++ b/net/base/upload_file_element_reader_unittest.cc @@ -205,7 +205,7 @@ TEST_F(UploadFileElementReaderTest, Range) { TEST_F(UploadFileElementReaderTest, FileChanged) { base::PlatformFileInfo info; - ASSERT_TRUE(file_util::GetFileInfo(temp_file_path_, &info)); + ASSERT_TRUE(base::GetFileInfo(temp_file_path_, &info)); // Expect one second before the actual modification time to simulate change. const base::Time expected_modification_time = @@ -350,7 +350,7 @@ TEST_F(UploadFileElementReaderSyncTest, Range) { TEST_F(UploadFileElementReaderSyncTest, FileChanged) { base::PlatformFileInfo info; - ASSERT_TRUE(file_util::GetFileInfo(temp_file_path_, &info)); + ASSERT_TRUE(base::GetFileInfo(temp_file_path_, &info)); // Expect one second before the actual modification time to simulate change. const base::Time expected_modification_time = diff --git a/net/disk_cache/entry_unittest.cc b/net/disk_cache/entry_unittest.cc index dabc391..291dedf 100644 --- a/net/disk_cache/entry_unittest.cc +++ b/net/disk_cache/entry_unittest.cc @@ -3014,7 +3014,7 @@ TEST_F(DiskCacheEntryTest, SimpleCacheCreateDoomRace) { base::FilePath entry_file_path = cache_path_.AppendASCII( disk_cache::simple_util::GetFilenameFromKeyAndFileIndex(key, i)); base::PlatformFileInfo info; - EXPECT_FALSE(file_util::GetFileInfo(entry_file_path, &info)); + EXPECT_FALSE(base::GetFileInfo(entry_file_path, &info)); } } diff --git a/net/disk_cache/simple/simple_index_file.cc b/net/disk_cache/simple/simple_index_file.cc index 7fead5e..abd9f7a 100644 --- a/net/disk_cache/simple/simple_index_file.cc +++ b/net/disk_cache/simple/simple_index_file.cc @@ -96,7 +96,7 @@ void ProcessEntryFile(SimpleIndex::EntrySet* entries, } base::PlatformFileInfo file_info; - if (!file_util::GetFileInfo(file_path, &file_info)) { + if (!base::GetFileInfo(file_path, &file_info)) { LOG(ERROR) << "Could not get file info for " << file_path.value(); return; } diff --git a/net/disk_cache/simple/simple_util.cc b/net/disk_cache/simple/simple_util.cc index 4afdc59..0ad2a05 100644 --- a/net/disk_cache/simple/simple_util.cc +++ b/net/disk_cache/simple/simple_util.cc @@ -126,7 +126,7 @@ bool GetMTime(const base::FilePath& path, base::Time* out_mtime) { } #endif base::PlatformFileInfo file_info; - if (!file_util::GetFileInfo(path, &file_info)) + if (!base::GetFileInfo(path, &file_info)) return false; *out_mtime = file_info.last_modified; return true; diff --git a/net/proxy/proxy_config_service_linux.cc b/net/proxy/proxy_config_service_linux.cc index 2c21283..c39dd87 100644 --- a/net/proxy/proxy_config_service_linux.cc +++ b/net/proxy/proxy_config_service_linux.cc @@ -886,8 +886,8 @@ class SettingGetterImplKDE : public ProxyConfigServiceLinux::SettingGetter, if (base::DirectoryExists(kde4_path)) { base::PlatformFileInfo kde3_info; base::PlatformFileInfo kde4_info; - if (file_util::GetFileInfo(kde4_config, &kde4_info)) { - if (file_util::GetFileInfo(kde3_config, &kde3_info)) { + if (base::GetFileInfo(kde4_config, &kde4_info)) { + if (base::GetFileInfo(kde3_config, &kde3_info)) { use_kde4 = kde4_info.last_modified >= kde3_info.last_modified; } else { use_kde4 = true; diff --git a/net/url_request/url_request_file_job.cc b/net/url_request/url_request_file_job.cc index 053a22e..723e6a0 100644 --- a/net/url_request/url_request_file_job.cc +++ b/net/url_request/url_request_file_job.cc @@ -198,7 +198,7 @@ URLRequestFileJob::~URLRequestFileJob() { void URLRequestFileJob::FetchMetaInfo(const base::FilePath& file_path, FileMetaInfo* meta_info) { base::PlatformFileInfo platform_info; - meta_info->file_exists = file_util::GetFileInfo(file_path, &platform_info); + meta_info->file_exists = base::GetFileInfo(file_path, &platform_info); if (meta_info->file_exists) { meta_info->file_size = platform_info.size; meta_info->is_directory = platform_info.is_directory; diff --git a/net/url_request/url_request_unittest.cc b/net/url_request/url_request_unittest.cc index d22d24f..79e7967 100644 --- a/net/url_request/url_request_unittest.cc +++ b/net/url_request/url_request_unittest.cc @@ -1008,7 +1008,7 @@ TEST_F(URLRequestTest, FileDirOutputSanity) { // Generate entry for the sentinel file. base::FilePath sentinel_path = path.AppendASCII(sentinel_name); base::PlatformFileInfo info; - EXPECT_TRUE(file_util::GetFileInfo(sentinel_path, &info)); + EXPECT_TRUE(base::GetFileInfo(sentinel_path, &info)); EXPECT_GT(info.size, 0); std::string sentinel_output = GetDirectoryListingEntry( base::string16(sentinel_name, sentinel_name + strlen(sentinel_name)), diff --git a/remoting/host/policy_hack/policy_watcher_linux.cc b/remoting/host/policy_hack/policy_watcher_linux.cc index 0a50b64..da57f68 100644 --- a/remoting/host/policy_hack/policy_watcher_linux.cc +++ b/remoting/host/policy_hack/policy_watcher_linux.cc @@ -103,7 +103,7 @@ class PolicyWatcherLinux : public PolicyWatcher { base::PlatformFileInfo file_info; // If the path does not exist or points to a directory, it's safe to load. - if (!file_util::GetFileInfo(config_dir_, &file_info) || + if (!base::GetFileInfo(config_dir_, &file_info) || !file_info.is_directory) { return last_modification; } @@ -115,7 +115,7 @@ class PolicyWatcherLinux : public PolicyWatcher { for (base::FilePath config_file = file_enumerator.Next(); !config_file.empty(); config_file = file_enumerator.Next()) { - if (file_util::GetFileInfo(config_file, &file_info) && + if (base::GetFileInfo(config_file, &file_info) && !file_info.is_directory) { last_modification = std::max(last_modification, file_info.last_modified); diff --git a/ui/shell_dialogs/select_file_dialog_win.cc b/ui/shell_dialogs/select_file_dialog_win.cc index ed5597d..1f8e364 100644 --- a/ui/shell_dialogs/select_file_dialog_win.cc +++ b/ui/shell_dialogs/select_file_dialog_win.cc @@ -86,7 +86,7 @@ bool CallGetSaveFileName(OPENFILENAME* ofn) { // Distinguish directories from regular files. bool IsDirectory(const base::FilePath& path) { base::PlatformFileInfo file_info; - return file_util::GetFileInfo(path, &file_info) ? + return base::GetFileInfo(path, &file_info) ? file_info.is_directory : path.EndsWithSeparator(); } diff --git a/webkit/browser/blob/local_file_stream_reader_unittest.cc b/webkit/browser/blob/local_file_stream_reader_unittest.cc index 501d62f7..ef7fb60 100644 --- a/webkit/browser/blob/local_file_stream_reader_unittest.cc +++ b/webkit/browser/blob/local_file_stream_reader_unittest.cc @@ -68,7 +68,7 @@ class LocalFileStreamReaderTest : public testing::Test { file_util::WriteFile(test_path(), kTestData, kTestDataSize); base::PlatformFileInfo info; - ASSERT_TRUE(file_util::GetFileInfo(test_path(), &info)); + ASSERT_TRUE(base::GetFileInfo(test_path(), &info)); test_file_modification_time_ = info.last_modified; } diff --git a/webkit/browser/database/database_tracker.cc b/webkit/browser/database/database_tracker.cc index 50a3bf1..ae4adc9 100644 --- a/webkit/browser/database/database_tracker.cc +++ b/webkit/browser/database/database_tracker.cc @@ -692,7 +692,7 @@ int DatabaseTracker::DeleteDataModifiedSince( db != details.end(); ++db) { base::FilePath db_file = GetFullDBFilePath(*ori, db->database_name); base::PlatformFileInfo file_info; - file_util::GetFileInfo(db_file, &file_info); + base::GetFileInfo(db_file, &file_info); if (file_info.last_modified < cutoff) continue; diff --git a/webkit/browser/fileapi/dragged_file_util.cc b/webkit/browser/fileapi/dragged_file_util.cc index b4536a7..3e81242 100644 --- a/webkit/browser/fileapi/dragged_file_util.cc +++ b/webkit/browser/fileapi/dragged_file_util.cc @@ -81,7 +81,7 @@ PlatformFileError DraggedFileUtil::GetFileInfo( } base::PlatformFileError error = NativeFileUtil::GetFileInfo(url.path(), file_info); - if (file_util::IsLink(url.path()) && !base::FilePath().IsParent(url.path())) { + if (base::IsLink(url.path()) && !base::FilePath().IsParent(url.path())) { // Don't follow symlinks unless it's the one that are selected by the user. return base::PLATFORM_FILE_ERROR_NOT_FOUND; } diff --git a/webkit/browser/fileapi/local_file_util.cc b/webkit/browser/fileapi/local_file_util.cc index 3357c69..db2e50c 100644 --- a/webkit/browser/fileapi/local_file_util.cc +++ b/webkit/browser/fileapi/local_file_util.cc @@ -51,7 +51,7 @@ class LocalFileEnumerator : public FileSystemFileUtil::AbstractFileEnumerator { base::FilePath LocalFileEnumerator::Next() { base::FilePath next = file_enum_.Next(); // Don't return symlinks. - while (!next.empty() && file_util::IsLink(next)) + while (!next.empty() && base::IsLink(next)) next = file_enum_.Next(); if (next.empty()) return next; @@ -88,7 +88,7 @@ PlatformFileError LocalFileUtil::CreateOrOpen( if (error != base::PLATFORM_FILE_OK) return error; // Disallow opening files in symlinked paths. - if (file_util::IsLink(file_path)) + if (base::IsLink(file_path)) return base::PLATFORM_FILE_ERROR_NOT_FOUND; return NativeFileUtil::CreateOrOpen( file_path, file_flags, file_handle, created); @@ -132,7 +132,7 @@ PlatformFileError LocalFileUtil::GetFileInfo( if (error != base::PLATFORM_FILE_OK) return error; // We should not follow symbolic links in sandboxed file system. - if (file_util::IsLink(file_path)) + if (base::IsLink(file_path)) return base::PLATFORM_FILE_ERROR_NOT_FOUND; error = NativeFileUtil::GetFileInfo(file_path, file_info); if (error == base::PLATFORM_FILE_OK) diff --git a/webkit/browser/fileapi/native_file_util.cc b/webkit/browser/fileapi/native_file_util.cc index e5ff2e7..d195d1e 100644 --- a/webkit/browser/fileapi/native_file_util.cc +++ b/webkit/browser/fileapi/native_file_util.cc @@ -155,7 +155,7 @@ PlatformFileError NativeFileUtil::GetFileInfo( base::PlatformFileInfo* file_info) { if (!base::PathExists(path)) return base::PLATFORM_FILE_ERROR_NOT_FOUND; - if (!file_util::GetFileInfo(path, file_info)) + if (!base::GetFileInfo(path, file_info)) return base::PLATFORM_FILE_ERROR_FAILED; return base::PLATFORM_FILE_OK; } diff --git a/webkit/browser/fileapi/native_file_util_unittest.cc b/webkit/browser/fileapi/native_file_util_unittest.cc index 47f88ea..c41a0cb 100644 --- a/webkit/browser/fileapi/native_file_util_unittest.cc +++ b/webkit/browser/fileapi/native_file_util_unittest.cc @@ -37,7 +37,7 @@ class NativeFileUtilTest : public testing::Test { int64 GetSize(const base::FilePath& path) { base::PlatformFileInfo info; - file_util::GetFileInfo(path, &info); + base::GetFileInfo(path, &info); return info.size; } @@ -126,7 +126,7 @@ TEST_F(NativeFileUtilTest, TouchFileAndGetFileInfo) { ASSERT_TRUE(created); base::PlatformFileInfo info; - ASSERT_TRUE(file_util::GetFileInfo(file_name, &info)); + ASSERT_TRUE(base::GetFileInfo(file_name, &info)); ASSERT_EQ(base::PLATFORM_FILE_OK, NativeFileUtil::GetFileInfo(file_name, &native_info)); ASSERT_EQ(info.size, native_info.size); @@ -145,7 +145,7 @@ TEST_F(NativeFileUtilTest, TouchFileAndGetFileInfo) { NativeFileUtil::Touch(file_name, new_accessed, new_modified)); - ASSERT_TRUE(file_util::GetFileInfo(file_name, &info)); + ASSERT_TRUE(base::GetFileInfo(file_name, &info)); EXPECT_EQ(new_accessed, info.last_accessed); EXPECT_EQ(new_modified, info.last_modified); } diff --git a/webkit/browser/fileapi/obfuscated_file_util.cc b/webkit/browser/fileapi/obfuscated_file_util.cc index 9b28d57..239b493 100644 --- a/webkit/browser/fileapi/obfuscated_file_util.cc +++ b/webkit/browser/fileapi/obfuscated_file_util.cc @@ -647,7 +647,7 @@ PlatformFileError ObfuscatedFileUtil::CopyInForeignFile( return base::PLATFORM_FILE_ERROR_FAILED; base::PlatformFileInfo src_platform_file_info; - if (!file_util::GetFileInfo(src_file_path, &src_platform_file_info)) + if (!base::GetFileInfo(src_file_path, &src_platform_file_info)) return base::PLATFORM_FILE_ERROR_NOT_FOUND; FileId dest_file_id; @@ -1028,7 +1028,7 @@ PlatformFileError ObfuscatedFileUtil::GetFileInfoInternal( base::PlatformFileError error = NativeFileUtil::GetFileInfo( local_path, file_info); // We should not follow symbolic links in sandboxed file system. - if (file_util::IsLink(local_path)) { + if (base::IsLink(local_path)) { LOG(WARNING) << "Found a symbolic file."; error = base::PLATFORM_FILE_ERROR_NOT_FOUND; } diff --git a/webkit/browser/fileapi/sandbox_directory_database.cc b/webkit/browser/fileapi/sandbox_directory_database.cc index 4e4dd87..dd37611 100644 --- a/webkit/browser/fileapi/sandbox_directory_database.cc +++ b/webkit/browser/fileapi/sandbox_directory_database.cc @@ -244,7 +244,7 @@ bool DatabaseCheckHelper::ScanDatabase() { // Ensure the backing file exists as a normal file. base::PlatformFileInfo platform_file_info; - if (!file_util::GetFileInfo( + if (!base::GetFileInfo( path_.Append(file_info.data_path), &platform_file_info) || platform_file_info.is_directory || platform_file_info.is_symbolic_link) { diff --git a/webkit/glue/webfileutilities_impl.cc b/webkit/glue/webfileutilities_impl.cc index 8c40b96..c7f4c7c 100644 --- a/webkit/glue/webfileutilities_impl.cc +++ b/webkit/glue/webfileutilities_impl.cc @@ -32,8 +32,7 @@ bool WebFileUtilitiesImpl::getFileInfo(const WebString& path, return false; } base::PlatformFileInfo file_info; - if (!file_util::GetFileInfo(base::FilePath::FromUTF16Unsafe(path), - &file_info)) + if (!base::GetFileInfo(base::FilePath::FromUTF16Unsafe(path), &file_info)) return false; webkit_glue::PlatformFileInfoToWebFileInfo(file_info, &web_file_info); |