diff options
80 files changed, 295 insertions, 317 deletions
diff --git a/base/event_recorder_win.cc b/base/event_recorder_win.cc index 11bf0f0..39c4220 100644 --- a/base/event_recorder_win.cc +++ b/base/event_recorder_win.cc @@ -49,7 +49,7 @@ bool EventRecorder::StartRecording(const FilePath& filename) { // Open the recording file. DCHECK(!file_); - file_ = file_util::OpenFile(filename, "wb+"); + file_ = OpenFile(filename, "wb+"); if (!file_) { DLOG(ERROR) << "EventRecorder could not open log file"; return false; @@ -63,7 +63,7 @@ bool EventRecorder::StartRecording(const FilePath& filename) { GetModuleHandle(NULL), 0); if (!journal_hook_) { DLOG(ERROR) << "EventRecorder Record Hook failed"; - file_util::CloseFile(file_); + CloseFile(file_); return false; } @@ -84,7 +84,7 @@ void EventRecorder::StopRecording() { ::timeEndPeriod(1); DCHECK(file_ != NULL); - file_util::CloseFile(file_); + CloseFile(file_); file_ = NULL; journal_hook_ = NULL; @@ -100,7 +100,7 @@ bool EventRecorder::StartPlayback(const FilePath& filename) { // Open the recording file. DCHECK(!file_); - file_ = file_util::OpenFile(filename, "rb"); + file_ = OpenFile(filename, "rb"); if (!file_) { DLOG(ERROR) << "EventRecorder Playback could not open log file"; return false; @@ -108,7 +108,7 @@ bool EventRecorder::StartPlayback(const FilePath& filename) { // Read the first event from the record. if (fread(&playback_msg_, sizeof(EVENTMSG), 1, file_) != 1) { DLOG(ERROR) << "EventRecorder Playback has no records!"; - file_util::CloseFile(file_); + CloseFile(file_); return false; } @@ -150,7 +150,7 @@ void EventRecorder::StopPlayback() { } DCHECK(file_ != NULL); - file_util::CloseFile(file_); + CloseFile(file_); file_ = NULL; ::timeEndPeriod(1); diff --git a/base/file_util.cc b/base/file_util.cc index 8bcf1a4..1575a07 100644 --- a/base/file_util.cc +++ b/base/file_util.cc @@ -129,7 +129,7 @@ bool TextContentsEqual(const FilePath& filename1, const FilePath& filename2) { bool ReadFileToString(const FilePath& path, std::string* contents) { if (path.ReferencesParent()) return false; - FILE* file = file_util::OpenFile(path, "rb"); + FILE* file = OpenFile(path, "rb"); if (!file) { return false; } @@ -140,7 +140,7 @@ bool ReadFileToString(const FilePath& path, std::string* contents) { if (contents) contents->append(buf, len); } - file_util::CloseFile(file); + CloseFile(file); return true; } @@ -194,16 +194,6 @@ bool TouchFile(const FilePath& path, return false; } -} // namespace base - -// ----------------------------------------------------------------------------- - -namespace file_util { - -using base::FileEnumerator; -using base::FilePath; -using base::kMaxUniqueFiles; - bool CloseFile(FILE* file) { if (file == NULL) return true; @@ -228,6 +218,15 @@ bool TruncateFile(FILE* file) { return true; } +} // namespace base + +// ----------------------------------------------------------------------------- + +namespace file_util { + +using base::FilePath; +using base::kMaxUniqueFiles; + int GetUniquePathNumber( const FilePath& path, const FilePath::StringType& suffix) { diff --git a/base/file_util.h b/base/file_util.h index 1fea6e8..3f892e3 100644 --- a/base/file_util.h +++ b/base/file_util.h @@ -299,19 +299,8 @@ BASE_EXPORT bool TouchFile(const FilePath& path, const Time& last_accessed, const Time& last_modified); -} // namespace base - -// ----------------------------------------------------------------------------- - -namespace file_util { - -#if defined(OS_POSIX) -// Store inode number of |path| in |inode|. Return true on success. -BASE_EXPORT bool GetInode(const base::FilePath& path, ino_t* inode); -#endif - // Wrapper for fopen-like calls. Returns non-NULL FILE* on success. -BASE_EXPORT FILE* OpenFile(const base::FilePath& filename, const char* mode); +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); @@ -324,6 +313,12 @@ BASE_EXPORT bool TruncateFile(FILE* file); // the number of read bytes, or -1 on error. BASE_EXPORT int ReadFile(const base::FilePath& filename, char* data, int size); +} // namespace base + +// ----------------------------------------------------------------------------- + +namespace file_util { + // 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 base::FilePath& filename, const char* data, diff --git a/base/file_util_posix.cc b/base/file_util_posix.cc index fdf196e..ddcd5dd 100644 --- a/base/file_util_posix.cc +++ b/base/file_util_posix.cc @@ -689,6 +689,27 @@ bool GetFileInfo(const FilePath& file_path, PlatformFileInfo* results) { return true; } +FILE* OpenFile(const FilePath& filename, const char* mode) { + ThreadRestrictions::AssertIOAllowed(); + FILE* result = NULL; + do { + result = fopen(filename.value().c_str(), mode); + } while (!result && errno == EINTR); + return result; +} + +int ReadFile(const FilePath& filename, char* data, int size) { + ThreadRestrictions::AssertIOAllowed(); + int fd = HANDLE_EINTR(open(filename.value().c_str(), O_RDONLY)); + if (fd < 0) + return -1; + + ssize_t bytes_read = HANDLE_EINTR(read(fd, data, size)); + if (int ret = IGNORE_EINTR(close(fd)) < 0) + return ret; + return bytes_read; +} + } // namespace base // ----------------------------------------------------------------------------- @@ -723,42 +744,10 @@ base::FilePath MakeUniqueDirectory(const base::FilePath& path) { return base::FilePath(); } -bool GetInode(const FilePath& path, ino_t* inode) { - base::ThreadRestrictions::AssertIOAllowed(); // For call to stat(). - struct stat buffer; - int result = stat(path.value().c_str(), &buffer); - if (result < 0) - return false; - - *inode = buffer.st_ino; - return true; -} - FILE* OpenFile(const std::string& filename, const char* mode) { return OpenFile(FilePath(filename), mode); } -FILE* OpenFile(const FilePath& filename, const char* mode) { - base::ThreadRestrictions::AssertIOAllowed(); - FILE* result = NULL; - do { - result = fopen(filename.value().c_str(), mode); - } while (!result && errno == EINTR); - return result; -} - -int ReadFile(const FilePath& filename, char* data, int size) { - base::ThreadRestrictions::AssertIOAllowed(); - int fd = HANDLE_EINTR(open(filename.value().c_str(), O_RDONLY)); - if (fd < 0) - return -1; - - ssize_t bytes_read = HANDLE_EINTR(read(fd, data, size)); - if (int ret = IGNORE_EINTR(close(fd)) < 0) - return ret; - return bytes_read; -} - int WriteFile(const FilePath& filename, const char* data, int size) { base::ThreadRestrictions::AssertIOAllowed(); int fd = HANDLE_EINTR(creat(filename.value().c_str(), 0666)); diff --git a/base/file_util_unittest.cc b/base/file_util_unittest.cc index 4ffa4ba..b65e171 100644 --- a/base/file_util_unittest.cc +++ b/base/file_util_unittest.cc @@ -254,7 +254,7 @@ TEST_F(FileUtilTest, FileAndDirectorySize) { EXPECT_EQ(20ll, size_f1); FilePath subdir_path = temp_dir_.path().Append(FPL("Level2")); - base::CreateDirectory(subdir_path); + CreateDirectory(subdir_path); FilePath file_02 = subdir_path.Append(FPL("The file 02.txt")); CreateTextFile(file_02, L"123456789012345678901234567890"); @@ -263,7 +263,7 @@ TEST_F(FileUtilTest, FileAndDirectorySize) { EXPECT_EQ(30ll, size_f2); FilePath subsubdir_path = subdir_path.Append(FPL("Level3")); - base::CreateDirectory(subsubdir_path); + CreateDirectory(subsubdir_path); FilePath file_03 = subsubdir_path.Append(FPL("The file 03.txt")); CreateTextFile(file_03, L"123"); @@ -278,7 +278,7 @@ TEST_F(FileUtilTest, NormalizeFilePathBasic) { FilePath file_a_path = temp_dir_.path().Append(FPL("file_a")); FilePath dir_path = temp_dir_.path().Append(FPL("dir")); FilePath file_b_path = dir_path.Append(FPL("file_b")); - base::CreateDirectory(dir_path); + CreateDirectory(dir_path); FilePath normalized_file_a_path, normalized_file_b_path; ASSERT_FALSE(PathExists(file_a_path)); @@ -318,10 +318,10 @@ TEST_F(FileUtilTest, NormalizeFilePathReparsePoints) { // |-> to_sub_long (reparse point to temp_dir\sub_a\long_name_\sub_long) FilePath base_a = temp_dir_.path().Append(FPL("base_a")); - ASSERT_TRUE(base::CreateDirectory(base_a)); + ASSERT_TRUE(CreateDirectory(base_a)); FilePath sub_a = base_a.Append(FPL("sub_a")); - ASSERT_TRUE(base::CreateDirectory(sub_a)); + ASSERT_TRUE(CreateDirectory(sub_a)); FilePath file_txt = sub_a.Append(FPL("file.txt")); CreateTextFile(file_txt, bogus_content); @@ -349,26 +349,26 @@ TEST_F(FileUtilTest, NormalizeFilePathReparsePoints) { ASSERT_EQ(MAX_PATH - kCreateDirLimit, deep_file.value().length()); FilePath sub_long = deep_file.DirName(); - ASSERT_TRUE(base::CreateDirectory(sub_long)); + ASSERT_TRUE(CreateDirectory(sub_long)); CreateTextFile(deep_file, bogus_content); FilePath base_b = temp_dir_.path().Append(FPL("base_b")); - ASSERT_TRUE(base::CreateDirectory(base_b)); + ASSERT_TRUE(CreateDirectory(base_b)); FilePath to_sub_a = base_b.Append(FPL("to_sub_a")); - ASSERT_TRUE(base::CreateDirectory(to_sub_a)); + ASSERT_TRUE(CreateDirectory(to_sub_a)); FilePath normalized_path; { ReparsePoint reparse_to_sub_a(to_sub_a, sub_a); ASSERT_TRUE(reparse_to_sub_a.IsValid()); FilePath to_base_b = base_b.Append(FPL("to_base_b")); - ASSERT_TRUE(base::CreateDirectory(to_base_b)); + ASSERT_TRUE(CreateDirectory(to_base_b)); ReparsePoint reparse_to_base_b(to_base_b, base_b); ASSERT_TRUE(reparse_to_base_b.IsValid()); FilePath to_sub_long = base_b.Append(FPL("to_sub_long")); - ASSERT_TRUE(base::CreateDirectory(to_sub_long)); + ASSERT_TRUE(CreateDirectory(to_sub_long)); ReparsePoint reparse_to_sub_long(to_sub_long, sub_long); ASSERT_TRUE(reparse_to_sub_long.IsValid()); @@ -487,7 +487,7 @@ TEST_F(FileUtilTest, DevicePathToDriveLetter) { TEST_F(FileUtilTest, GetPlatformFileInfoForDirectory) { FilePath empty_dir = temp_dir_.path().Append(FPL("gpfi_test")); - ASSERT_TRUE(base::CreateDirectory(empty_dir)); + ASSERT_TRUE(CreateDirectory(empty_dir)); win::ScopedHandle dir( ::CreateFile(empty_dir.value().c_str(), FILE_ALL_ACCESS, @@ -513,7 +513,7 @@ TEST_F(FileUtilTest, CreateTemporaryFileInDirLongPathTest) { const FilePath::CharType kLongDirName[] = FPL("A long path"); const FilePath::CharType kTestSubDirName[] = FPL("test"); FilePath long_test_dir = temp_dir_.path().Append(kLongDirName); - ASSERT_TRUE(base::CreateDirectory(long_test_dir)); + ASSERT_TRUE(CreateDirectory(long_test_dir)); // kLongDirName is not a 8.3 component. So GetShortName() should give us a // different short name. @@ -526,7 +526,7 @@ TEST_F(FileUtilTest, CreateTemporaryFileInDirLongPathTest) { ASSERT_STRNE(kLongDirName, short_test_dir.BaseName().value().c_str()); FilePath temp_file; - ASSERT_TRUE(base::CreateTemporaryFileInDir(short_test_dir, &temp_file)); + ASSERT_TRUE(CreateTemporaryFileInDir(short_test_dir, &temp_file)); EXPECT_STREQ(kLongDirName, temp_file.DirName().BaseName().value().c_str()); EXPECT_TRUE(PathExists(temp_file)); @@ -538,12 +538,12 @@ TEST_F(FileUtilTest, CreateTemporaryFileInDirLongPathTest) { // directories. (Note that this assumption is true for NTFS, but not for some // network file systems. E.g. AFS). FilePath access_test_dir = long_test_dir.Append(kTestSubDirName); - ASSERT_TRUE(base::CreateDirectory(access_test_dir)); + ASSERT_TRUE(CreateDirectory(access_test_dir)); file_util::PermissionRestorer long_test_dir_restorer(long_test_dir); ASSERT_TRUE(file_util::MakeFileUnreadable(long_test_dir)); // Use the short form of the directory to create a temporary filename. - ASSERT_TRUE(base::CreateTemporaryFileInDir( + ASSERT_TRUE(CreateTemporaryFileInDir( short_test_dir.Append(kTestSubDirName), &temp_file)); EXPECT_TRUE(PathExists(temp_file)); EXPECT_TRUE(short_test_dir.IsParent(temp_file.DirName())); @@ -578,7 +578,7 @@ TEST_F(FileUtilTest, CreateAndReadSymlinks) { // Link to a directory. link_from = temp_dir_.path().Append(FPL("from_dir")); link_to = temp_dir_.path().Append(FPL("to_dir")); - ASSERT_TRUE(base::CreateDirectory(link_to)); + ASSERT_TRUE(CreateDirectory(link_to)); ASSERT_TRUE(CreateSymbolicLink(link_to, link_from)) << "Failed to create directory symlink."; @@ -613,7 +613,7 @@ TEST_F(FileUtilTest, NormalizeFilePathSymlinks) { // Link to a directory. link_from = temp_dir_.path().Append(FPL("from_dir")); link_to = temp_dir_.path().Append(FPL("to_dir")); - ASSERT_TRUE(base::CreateDirectory(link_to)); + ASSERT_TRUE(CreateDirectory(link_to)); ASSERT_TRUE(CreateSymbolicLink(link_to, link_from)) << "Failed to create directory symlink."; @@ -729,7 +729,7 @@ TEST_F(FileUtilTest, ChangeFilePermissionsAndRead) { EXPECT_TRUE(GetPosixFilePermissions(file_name, &mode)); EXPECT_FALSE(mode & FILE_PERMISSION_READ_BY_USER); // Make sure the file can't be read. - EXPECT_EQ(-1, file_util::ReadFile(file_name, buffer, buffer_size)); + EXPECT_EQ(-1, ReadFile(file_name, buffer, buffer_size)); // Give the read permission. EXPECT_TRUE(SetPosixFilePermissions(file_name, FILE_PERMISSION_READ_BY_USER)); @@ -737,7 +737,7 @@ TEST_F(FileUtilTest, ChangeFilePermissionsAndRead) { EXPECT_TRUE(mode & FILE_PERMISSION_READ_BY_USER); // Make sure the file can be read. EXPECT_EQ(static_cast<int>(kData.length()), - file_util::ReadFile(file_name, buffer, buffer_size)); + ReadFile(file_name, buffer, buffer_size)); // Delete the file. EXPECT_TRUE(DeleteFile(file_name, false)); @@ -792,7 +792,7 @@ TEST_F(FileUtilTest, ChangeDirectoryPermissionsAndEnumerate) { // Create a directory path. FilePath subdir_path = temp_dir_.path().Append(FPL("PermissionTest1")); - base::CreateDirectory(subdir_path); + CreateDirectory(subdir_path); ASSERT_TRUE(PathExists(subdir_path)); // Create a dummy file to enumerate. @@ -849,7 +849,7 @@ TEST_F(FileUtilTest, DeleteWildCard) { ASSERT_TRUE(PathExists(file_name)); FilePath subdir_path = temp_dir_.path().Append(FPL("DeleteWildCardDir")); - base::CreateDirectory(subdir_path); + CreateDirectory(subdir_path); ASSERT_TRUE(PathExists(subdir_path)); // Create the wildcard path @@ -872,7 +872,7 @@ TEST_F(FileUtilTest, DeleteNonExistantWildCard) { // Create a file and a directory FilePath subdir_path = temp_dir_.path().Append(FPL("DeleteNonExistantWildCard")); - base::CreateDirectory(subdir_path); + CreateDirectory(subdir_path); ASSERT_TRUE(PathExists(subdir_path)); // Create the wildcard path @@ -893,7 +893,7 @@ TEST_F(FileUtilTest, DeleteNonExistantWildCard) { TEST_F(FileUtilTest, DeleteDirNonRecursive) { // Create a subdirectory and put a file and two directories inside. FilePath test_subdir = temp_dir_.path().Append(FPL("DeleteDirNonRecursive")); - base::CreateDirectory(test_subdir); + CreateDirectory(test_subdir); ASSERT_TRUE(PathExists(test_subdir)); FilePath file_name = test_subdir.Append(FPL("Test DeleteDir.txt")); @@ -901,11 +901,11 @@ TEST_F(FileUtilTest, DeleteDirNonRecursive) { ASSERT_TRUE(PathExists(file_name)); FilePath subdir_path1 = test_subdir.Append(FPL("TestSubDir1")); - base::CreateDirectory(subdir_path1); + CreateDirectory(subdir_path1); ASSERT_TRUE(PathExists(subdir_path1)); FilePath subdir_path2 = test_subdir.Append(FPL("TestSubDir2")); - base::CreateDirectory(subdir_path2); + CreateDirectory(subdir_path2); ASSERT_TRUE(PathExists(subdir_path2)); // Delete non-recursively and check that the empty dir got deleted @@ -923,7 +923,7 @@ TEST_F(FileUtilTest, DeleteDirNonRecursive) { TEST_F(FileUtilTest, DeleteDirRecursive) { // Create a subdirectory and put a file and two directories inside. FilePath test_subdir = temp_dir_.path().Append(FPL("DeleteDirRecursive")); - base::CreateDirectory(test_subdir); + CreateDirectory(test_subdir); ASSERT_TRUE(PathExists(test_subdir)); FilePath file_name = test_subdir.Append(FPL("Test DeleteDirRecursive.txt")); @@ -931,11 +931,11 @@ TEST_F(FileUtilTest, DeleteDirRecursive) { ASSERT_TRUE(PathExists(file_name)); FilePath subdir_path1 = test_subdir.Append(FPL("TestSubDir1")); - base::CreateDirectory(subdir_path1); + CreateDirectory(subdir_path1); ASSERT_TRUE(PathExists(subdir_path1)); FilePath subdir_path2 = test_subdir.Append(FPL("TestSubDir2")); - base::CreateDirectory(subdir_path2); + CreateDirectory(subdir_path2); ASSERT_TRUE(PathExists(subdir_path2)); // Delete recursively and check that the empty dir got deleted @@ -999,7 +999,7 @@ TEST_F(FileUtilTest, MoveFileDirExists) { // The destination directory FilePath dir_name_to = temp_dir_.path().Append(FILE_PATH_LITERAL("Destination")); - base::CreateDirectory(dir_name_to); + CreateDirectory(dir_name_to); ASSERT_TRUE(PathExists(dir_name_to)); EXPECT_FALSE(Move(file_name_from, dir_name_to)); @@ -1010,7 +1010,7 @@ TEST_F(FileUtilTest, MoveNew) { // Create a directory FilePath dir_name_from = temp_dir_.path().Append(FILE_PATH_LITERAL("Move_From_Subdir")); - base::CreateDirectory(dir_name_from); + CreateDirectory(dir_name_from); ASSERT_TRUE(PathExists(dir_name_from)); // Create a file under the directory @@ -1051,7 +1051,7 @@ TEST_F(FileUtilTest, MoveExist) { // Create a directory FilePath dir_name_from = temp_dir_.path().Append(FILE_PATH_LITERAL("Move_From_Subdir")); - base::CreateDirectory(dir_name_from); + CreateDirectory(dir_name_from); ASSERT_TRUE(PathExists(dir_name_from)); // Create a file under the directory @@ -1070,7 +1070,7 @@ TEST_F(FileUtilTest, MoveExist) { dir_name_to.Append(FILE_PATH_LITERAL("Move_Test_File.txt")); // Create the destination directory. - base::CreateDirectory(dir_name_exists); + CreateDirectory(dir_name_exists); ASSERT_TRUE(PathExists(dir_name_exists)); EXPECT_TRUE(Move(dir_name_from, dir_name_to)); @@ -1086,7 +1086,7 @@ TEST_F(FileUtilTest, CopyDirectoryRecursivelyNew) { // Create a directory. FilePath dir_name_from = temp_dir_.path().Append(FILE_PATH_LITERAL("Copy_From_Subdir")); - base::CreateDirectory(dir_name_from); + CreateDirectory(dir_name_from); ASSERT_TRUE(PathExists(dir_name_from)); // Create a file under the directory. @@ -1098,7 +1098,7 @@ TEST_F(FileUtilTest, CopyDirectoryRecursivelyNew) { // Create a subdirectory. FilePath subdir_name_from = dir_name_from.Append(FILE_PATH_LITERAL("Subdir")); - base::CreateDirectory(subdir_name_from); + CreateDirectory(subdir_name_from); ASSERT_TRUE(PathExists(subdir_name_from)); // Create a file under the subdirectory. @@ -1136,7 +1136,7 @@ TEST_F(FileUtilTest, CopyDirectoryRecursivelyExists) { // Create a directory. FilePath dir_name_from = temp_dir_.path().Append(FILE_PATH_LITERAL("Copy_From_Subdir")); - base::CreateDirectory(dir_name_from); + CreateDirectory(dir_name_from); ASSERT_TRUE(PathExists(dir_name_from)); // Create a file under the directory. @@ -1148,7 +1148,7 @@ TEST_F(FileUtilTest, CopyDirectoryRecursivelyExists) { // Create a subdirectory. FilePath subdir_name_from = dir_name_from.Append(FILE_PATH_LITERAL("Subdir")); - base::CreateDirectory(subdir_name_from); + CreateDirectory(subdir_name_from); ASSERT_TRUE(PathExists(subdir_name_from)); // Create a file under the subdirectory. @@ -1171,7 +1171,7 @@ TEST_F(FileUtilTest, CopyDirectoryRecursivelyExists) { subdir_name_to.Append(FILE_PATH_LITERAL("Copy_Test_File.txt")); // Create the destination directory. - base::CreateDirectory(dir_name_exists); + CreateDirectory(dir_name_exists); ASSERT_TRUE(PathExists(dir_name_exists)); EXPECT_TRUE(CopyDirectory(dir_name_from, dir_name_exists, true)); @@ -1191,7 +1191,7 @@ TEST_F(FileUtilTest, CopyDirectoryNew) { // Create a directory. FilePath dir_name_from = temp_dir_.path().Append(FILE_PATH_LITERAL("Copy_From_Subdir")); - base::CreateDirectory(dir_name_from); + CreateDirectory(dir_name_from); ASSERT_TRUE(PathExists(dir_name_from)); // Create a file under the directory. @@ -1203,7 +1203,7 @@ TEST_F(FileUtilTest, CopyDirectoryNew) { // Create a subdirectory. FilePath subdir_name_from = dir_name_from.Append(FILE_PATH_LITERAL("Subdir")); - base::CreateDirectory(subdir_name_from); + CreateDirectory(subdir_name_from); ASSERT_TRUE(PathExists(subdir_name_from)); // Create a file under the subdirectory. @@ -1238,7 +1238,7 @@ TEST_F(FileUtilTest, CopyDirectoryExists) { // Create a directory. FilePath dir_name_from = temp_dir_.path().Append(FILE_PATH_LITERAL("Copy_From_Subdir")); - base::CreateDirectory(dir_name_from); + CreateDirectory(dir_name_from); ASSERT_TRUE(PathExists(dir_name_from)); // Create a file under the directory. @@ -1250,7 +1250,7 @@ TEST_F(FileUtilTest, CopyDirectoryExists) { // Create a subdirectory. FilePath subdir_name_from = dir_name_from.Append(FILE_PATH_LITERAL("Subdir")); - base::CreateDirectory(subdir_name_from); + CreateDirectory(subdir_name_from); ASSERT_TRUE(PathExists(subdir_name_from)); // Create a file under the subdirectory. @@ -1268,7 +1268,7 @@ TEST_F(FileUtilTest, CopyDirectoryExists) { dir_name_to.Append(FILE_PATH_LITERAL("Subdir")); // Create the destination directory. - base::CreateDirectory(dir_name_to); + CreateDirectory(dir_name_to); ASSERT_TRUE(PathExists(dir_name_to)); EXPECT_TRUE(CopyDirectory(dir_name_from, dir_name_to, false)); @@ -1331,7 +1331,7 @@ TEST_F(FileUtilTest, CopyFileWithCopyDirectoryRecursiveToExistingDirectory) { // The destination FilePath dir_name_to = temp_dir_.path().Append(FILE_PATH_LITERAL("Destination")); - base::CreateDirectory(dir_name_to); + CreateDirectory(dir_name_to); ASSERT_TRUE(PathExists(dir_name_to)); FilePath file_name_to = dir_name_to.Append(FILE_PATH_LITERAL("Copy_Test_File.txt")); @@ -1346,7 +1346,7 @@ TEST_F(FileUtilTest, CopyDirectoryWithTrailingSeparators) { // Create a directory. FilePath dir_name_from = temp_dir_.path().Append(FILE_PATH_LITERAL("Copy_From_Subdir")); - base::CreateDirectory(dir_name_from); + CreateDirectory(dir_name_from); ASSERT_TRUE(PathExists(dir_name_from)); // Create a file under the directory. @@ -1383,7 +1383,7 @@ TEST_F(FileUtilTest, CopyFile) { // Create a directory FilePath dir_name_from = temp_dir_.path().Append(FILE_PATH_LITERAL("Copy_From_Subdir")); - base::CreateDirectory(dir_name_from); + CreateDirectory(dir_name_from); ASSERT_TRUE(PathExists(dir_name_from)); // Create a file under the directory @@ -1518,7 +1518,7 @@ TEST_F(FileUtilTest, CopyAndDeleteDirectoryTest) { // Create a directory FilePath dir_name_from = temp_dir_.path().Append(FILE_PATH_LITERAL("CopyAndDelete_From_Subdir")); - base::CreateDirectory(dir_name_from); + CreateDirectory(dir_name_from); ASSERT_TRUE(PathExists(dir_name_from)); // Create a file under the directory @@ -1559,7 +1559,7 @@ TEST_F(FileUtilTest, GetTempDirTest) { for (unsigned int i = 0; i < arraysize(kTmpValues); ++i) { FilePath path; ::_tputenv_s(kTmpKey, kTmpValues[i]); - base::GetTempDir(&path); + GetTempDir(&path); EXPECT_TRUE(path.IsAbsolute()) << "$TMP=" << kTmpValues[i] << " result=" << path.value(); } @@ -1577,7 +1577,7 @@ TEST_F(FileUtilTest, GetTempDirTest) { TEST_F(FileUtilTest, CreateTemporaryFileTest) { FilePath temp_files[3]; for (int i = 0; i < 3; i++) { - ASSERT_TRUE(base::CreateTemporaryFile(&(temp_files[i]))); + ASSERT_TRUE(CreateTemporaryFile(&(temp_files[i]))); EXPECT_TRUE(PathExists(temp_files[i])); EXPECT_FALSE(DirectoryExists(temp_files[i])); } @@ -1594,7 +1594,7 @@ TEST_F(FileUtilTest, CreateAndOpenTemporaryFileTest) { // Create; make sure they are open and exist. for (i = 0; i < 3; ++i) { - fps[i] = base::CreateAndOpenTemporaryFile(&(names[i])); + fps[i] = CreateAndOpenTemporaryFile(&(names[i])); ASSERT_TRUE(fps[i]); EXPECT_TRUE(PathExists(names[i])); } @@ -1606,21 +1606,21 @@ TEST_F(FileUtilTest, CreateAndOpenTemporaryFileTest) { // Close and delete. for (i = 0; i < 3; ++i) { - EXPECT_TRUE(file_util::CloseFile(fps[i])); + EXPECT_TRUE(CloseFile(fps[i])); EXPECT_TRUE(DeleteFile(names[i], false)); } } TEST_F(FileUtilTest, CreateNewTempDirectoryTest) { FilePath temp_dir; - ASSERT_TRUE(base::CreateNewTempDirectory(FilePath::StringType(), &temp_dir)); + ASSERT_TRUE(CreateNewTempDirectory(FilePath::StringType(), &temp_dir)); EXPECT_TRUE(PathExists(temp_dir)); EXPECT_TRUE(DeleteFile(temp_dir, false)); } TEST_F(FileUtilTest, CreateNewTemporaryDirInDirTest) { FilePath new_dir; - ASSERT_TRUE(base::CreateTemporaryDirInDir( + ASSERT_TRUE(CreateTemporaryDirInDir( temp_dir_.path(), FILE_PATH_LITERAL("CreateNewTemporaryDirInDirTest"), &new_dir)); @@ -1647,17 +1647,17 @@ TEST_F(FileUtilTest, CreateDirectoryTest) { #endif EXPECT_FALSE(PathExists(test_path)); - EXPECT_TRUE(base::CreateDirectory(test_path)); + EXPECT_TRUE(CreateDirectory(test_path)); EXPECT_TRUE(PathExists(test_path)); // CreateDirectory returns true if the DirectoryExists returns true. - EXPECT_TRUE(base::CreateDirectory(test_path)); + EXPECT_TRUE(CreateDirectory(test_path)); // Doesn't work to create it on top of a non-dir test_path = test_path.Append(FILE_PATH_LITERAL("foobar.txt")); EXPECT_FALSE(PathExists(test_path)); CreateTextFile(test_path, L"test file"); EXPECT_TRUE(PathExists(test_path)); - EXPECT_FALSE(base::CreateDirectory(test_path)); + EXPECT_FALSE(CreateDirectory(test_path)); EXPECT_TRUE(DeleteFile(test_root, true)); EXPECT_FALSE(PathExists(test_root)); @@ -1675,16 +1675,16 @@ TEST_F(FileUtilTest, CreateDirectoryTest) { // Given these assumptions hold, it should be safe to // test that "creating" these directories succeeds. - EXPECT_TRUE(base::CreateDirectory( + EXPECT_TRUE(CreateDirectory( FilePath(FilePath::kCurrentDirectory))); - EXPECT_TRUE(base::CreateDirectory(top_level)); + EXPECT_TRUE(CreateDirectory(top_level)); #if defined(OS_WIN) FilePath invalid_drive(FILE_PATH_LITERAL("o:\\")); FilePath invalid_path = invalid_drive.Append(FILE_PATH_LITERAL("some\\inaccessible\\dir")); if (!PathExists(invalid_drive)) { - EXPECT_FALSE(base::CreateDirectory(invalid_path)); + EXPECT_FALSE(CreateDirectory(invalid_path)); } #endif } @@ -1694,7 +1694,7 @@ TEST_F(FileUtilTest, DetectDirectoryTest) { FilePath test_root = temp_dir_.path().Append(FILE_PATH_LITERAL("detect_directory_test")); EXPECT_FALSE(PathExists(test_root)); - EXPECT_TRUE(base::CreateDirectory(test_root)); + EXPECT_TRUE(CreateDirectory(test_root)); EXPECT_TRUE(PathExists(test_root)); EXPECT_TRUE(DirectoryExists(test_root)); // Check a file @@ -1724,11 +1724,11 @@ TEST_F(FileUtilTest, FileEnumeratorTest) { // create the directories FilePath dir1 = temp_dir_.path().Append(FPL("dir1")); - EXPECT_TRUE(base::CreateDirectory(dir1)); + EXPECT_TRUE(CreateDirectory(dir1)); FilePath dir2 = temp_dir_.path().Append(FPL("dir2")); - EXPECT_TRUE(base::CreateDirectory(dir2)); + EXPECT_TRUE(CreateDirectory(dir2)); FilePath dir2inner = dir2.Append(FPL("inner")); - EXPECT_TRUE(base::CreateDirectory(dir2inner)); + EXPECT_TRUE(CreateDirectory(dir2inner)); // create the files FilePath dir2file = dir2.Append(FPL("dir2file.txt")); @@ -1814,7 +1814,7 @@ TEST_F(FileUtilTest, FileEnumeratorTest) { ReparsePoint reparse_point(dir1, dir2); EXPECT_TRUE(reparse_point.IsValid()); - if ((win::GetVersion() >= base::win::VERSION_VISTA)) { + if ((win::GetVersion() >= win::VERSION_VISTA)) { // There can be a delay for the enumeration code to see the change on // the file system so skip this test for XP. // Enumerate the reparse point. @@ -1865,13 +1865,13 @@ TEST_F(FileUtilTest, AppendToFile) { if (PathExists(data_dir)) { ASSERT_TRUE(DeleteFile(data_dir, true)); } - ASSERT_TRUE(base::CreateDirectory(data_dir)); + ASSERT_TRUE(CreateDirectory(data_dir)); // Create a fresh, empty copy of this directory. if (PathExists(data_dir)) { ASSERT_TRUE(DeleteFile(data_dir, true)); } - ASSERT_TRUE(base::CreateDirectory(data_dir)); + ASSERT_TRUE(CreateDirectory(data_dir)); FilePath foobar(data_dir.Append(FILE_PATH_LITERAL("foobar.txt"))); std::string data("hello"); @@ -1925,15 +1925,15 @@ TEST_F(FileUtilTest, IsDirectoryEmpty) { ASSERT_FALSE(PathExists(empty_dir)); - ASSERT_TRUE(base::CreateDirectory(empty_dir)); + ASSERT_TRUE(CreateDirectory(empty_dir)); - EXPECT_TRUE(base::IsDirectoryEmpty(empty_dir)); + EXPECT_TRUE(IsDirectoryEmpty(empty_dir)); FilePath foo(empty_dir.Append(FILE_PATH_LITERAL("foo.txt"))); std::string bar("baz"); ASSERT_TRUE(file_util::WriteFile(foo, bar.c_str(), bar.length())); - EXPECT_FALSE(base::IsDirectoryEmpty(empty_dir)); + EXPECT_FALSE(IsDirectoryEmpty(empty_dir)); } #if defined(OS_POSIX) @@ -1957,10 +1957,10 @@ class VerifyPathControlledByUserTest : public FileUtilTest { // |-> text_file_ base_dir_ = temp_dir_.path().AppendASCII("base_dir"); - ASSERT_TRUE(base::CreateDirectory(base_dir_)); + ASSERT_TRUE(CreateDirectory(base_dir_)); sub_dir_ = base_dir_.AppendASCII("sub_dir"); - ASSERT_TRUE(base::CreateDirectory(sub_dir_)); + ASSERT_TRUE(CreateDirectory(sub_dir_)); text_file_ = sub_dir_.AppendASCII("file.txt"); CreateTextFile(text_file_, L"This text file has some text in it."); diff --git a/base/file_util_win.cc b/base/file_util_win.cc index b9683d6..323102c 100644 --- a/base/file_util_win.cc +++ b/base/file_util_win.cc @@ -264,7 +264,7 @@ FILE* CreateAndOpenTemporaryFileInDir(const FilePath& dir, FilePath* path) { // Open file in binary mode, to avoid problems with fwrite. On Windows // it replaces \n's with \r\n's, which may surprise you. // Reference: http://msdn.microsoft.com/en-us/library/h9t88zwz(VS.71).aspx - return file_util::OpenFile(*path, "wb+"); + return OpenFile(*path, "wb+"); } bool CreateTemporaryFileInDir(const FilePath& dir, FilePath* temp_file) { @@ -530,29 +530,14 @@ bool GetFileInfo(const FilePath& file_path, PlatformFileInfo* results) { 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(); + ThreadRestrictions::AssertIOAllowed(); std::wstring w_mode = ASCIIToWide(std::string(mode)); return _wfsopen(filename.value().c_str(), w_mode.c_str(), _SH_DENYNO); } -FILE* OpenFile(const std::string& filename, const char* mode) { - base::ThreadRestrictions::AssertIOAllowed(); - return _fsopen(filename.c_str(), mode, _SH_DENYNO); -} - int ReadFile(const FilePath& filename, char* data, int size) { - base::ThreadRestrictions::AssertIOAllowed(); + ThreadRestrictions::AssertIOAllowed(); base::win::ScopedHandle file(CreateFile(filename.value().c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, @@ -570,6 +555,21 @@ int ReadFile(const FilePath& filename, char* data, int size) { return -1; } +} // namespace base + +// ----------------------------------------------------------------------------- + +namespace file_util { + +using base::DirectoryExists; +using base::FilePath; +using base::kFileShareAll; + +FILE* OpenFile(const std::string& filename, const char* mode) { + base::ThreadRestrictions::AssertIOAllowed(); + return _fsopen(filename.c_str(), mode, _SH_DENYNO); +} + int WriteFile(const FilePath& filename, const char* data, int size) { base::ThreadRestrictions::AssertIOAllowed(); base::win::ScopedHandle file(CreateFile(filename.value().c_str(), diff --git a/base/files/file_util_proxy_unittest.cc b/base/files/file_util_proxy_unittest.cc index fa4a78c..17c7a3f 100644 --- a/base/files/file_util_proxy_unittest.cc +++ b/base/files/file_util_proxy_unittest.cc @@ -320,7 +320,7 @@ TEST_F(FileUtilProxyTest, WriteAndFlush) { // Verify the written data. char buffer[10]; - EXPECT_EQ(data_bytes, file_util::ReadFile(test_path(), buffer, data_bytes)); + EXPECT_EQ(data_bytes, base::ReadFile(test_path(), buffer, data_bytes)); for (int i = 0; i < data_bytes; ++i) { EXPECT_EQ(data[i], buffer[i]); } @@ -373,7 +373,7 @@ TEST_F(FileUtilProxyTest, Truncate_Shrink) { ASSERT_EQ(7, info.size); char buffer[7]; - EXPECT_EQ(7, file_util::ReadFile(test_path(), buffer, 7)); + EXPECT_EQ(7, base::ReadFile(test_path(), buffer, 7)); int i = 0; for (; i < 7; ++i) EXPECT_EQ(kTestData[i], buffer[i]); @@ -400,7 +400,7 @@ TEST_F(FileUtilProxyTest, Truncate_Expand) { ASSERT_EQ(53, info.size); char buffer[53]; - EXPECT_EQ(53, file_util::ReadFile(test_path(), buffer, 53)); + EXPECT_EQ(53, base::ReadFile(test_path(), buffer, 53)); int i = 0; for (; i < 10; ++i) EXPECT_EQ(kTestData[i], buffer[i]); diff --git a/base/memory/shared_memory_posix.cc b/base/memory/shared_memory_posix.cc index 4620247..35d8c7d 100644 --- a/base/memory/shared_memory_posix.cc +++ b/base/memory/shared_memory_posix.cc @@ -264,7 +264,7 @@ bool SharedMemory::Open(const std::string& name, bool read_only) { read_only_ = read_only; const char *mode = read_only ? "r" : "r+"; - ScopedFILE fp(file_util::OpenFile(path, mode)); + ScopedFILE fp(base::OpenFile(path, mode)); int readonly_fd_storage = -1; ScopedFD readonly_fd(&readonly_fd_storage); *readonly_fd = HANDLE_EINTR(open(path.value().c_str(), O_RDONLY)); diff --git a/base/nix/mime_util_xdg.cc b/base/nix/mime_util_xdg.cc index d695d15..dd2c7eb 100644 --- a/base/nix/mime_util_xdg.cc +++ b/base/nix/mime_util_xdg.cc @@ -255,7 +255,7 @@ FilePath IconTheme::GetIconPathUnderSubdir(const std::string& icon_name, } bool IconTheme::LoadIndexTheme(const FilePath& file) { - FILE* fp = file_util::OpenFile(file, "r"); + FILE* fp = base::OpenFile(file, "r"); SubDirInfo* current_info = NULL; if (!fp) return false; @@ -316,7 +316,7 @@ bool IconTheme::LoadIndexTheme(const FilePath& file) { } } - file_util::CloseFile(fp); + base::CloseFile(fp); return info_array_.get() != NULL; } diff --git a/base/test/gtest_xml_util.cc b/base/test/gtest_xml_util.cc index bcba363..75d023a 100644 --- a/base/test/gtest_xml_util.cc +++ b/base/test/gtest_xml_util.cc @@ -33,13 +33,13 @@ XmlUnitTestResultPrinter::~XmlUnitTestResultPrinter() { if (output_file_) { fprintf(output_file_, "</testsuites>\n"); fflush(output_file_); - file_util::CloseFile(output_file_); + base::CloseFile(output_file_); } } bool XmlUnitTestResultPrinter::Initialize(const FilePath& output_file_path) { DCHECK(!output_file_); - output_file_ = file_util::OpenFile(output_file_path, "w"); + output_file_ = OpenFile(output_file_path, "w"); if (!output_file_) return false; diff --git a/base/test/launcher/test_results_tracker.cc b/base/test/launcher/test_results_tracker.cc index b2140da..7b8dbeb 100644 --- a/base/test/launcher/test_results_tracker.cc +++ b/base/test/launcher/test_results_tracker.cc @@ -135,7 +135,7 @@ bool TestResultsTracker::Init(const CommandLine& command_line) { return false; } } - out_ = file_util::OpenFile(path, "w"); + out_ = OpenFile(path, "w"); if (!out_) { LOG(ERROR) << "Cannot open output file: " << path.value() << "."; diff --git a/base/test/perf_log.cc b/base/test/perf_log.cc index aaeb26c..efc1d42 100644 --- a/base/test/perf_log.cc +++ b/base/test/perf_log.cc @@ -18,7 +18,7 @@ bool InitPerfLog(const FilePath& log_file) { return false; } - perf_log_file = file_util::OpenFile(log_file, "w"); + perf_log_file = OpenFile(log_file, "w"); return perf_log_file != NULL; } @@ -28,7 +28,7 @@ void FinalizePerfLog() { NOTREACHED(); return; } - file_util::CloseFile(perf_log_file); + base::CloseFile(perf_log_file); } void LogPerfResult(const char* test_name, double value, const char* units) { diff --git a/base/win/shortcut_unittest.cc b/base/win/shortcut_unittest.cc index 6db5741..eaf152e 100644 --- a/base/win/shortcut_unittest.cc +++ b/base/win/shortcut_unittest.cc @@ -91,7 +91,7 @@ TEST_F(ShortcutTest, CreateAndResolveShortcut) { EXPECT_TRUE(ResolveShortcut(link_file_, &resolved_name, NULL)); char read_contents[arraysize(kFileContents)]; - file_util::ReadFile(resolved_name, read_contents, arraysize(read_contents)); + base::ReadFile(resolved_name, read_contents, arraysize(read_contents)); EXPECT_STREQ(kFileContents, read_contents); } @@ -104,7 +104,7 @@ TEST_F(ShortcutTest, ResolveShortcutWithArgs) { EXPECT_TRUE(ResolveShortcut(link_file_, &resolved_name, &args)); char read_contents[arraysize(kFileContents)]; - file_util::ReadFile(resolved_name, read_contents, arraysize(read_contents)); + base::ReadFile(resolved_name, read_contents, arraysize(read_contents)); EXPECT_STREQ(kFileContents, read_contents); EXPECT_EQ(link_properties_.arguments, args); } @@ -157,7 +157,7 @@ TEST_F(ShortcutTest, UpdateShortcutUpdateOnlyTargetAndResolve) { EXPECT_TRUE(ResolveShortcut(link_file_, &resolved_name, NULL)); char read_contents[arraysize(kFileContents2)]; - file_util::ReadFile(resolved_name, read_contents, arraysize(read_contents)); + base::ReadFile(resolved_name, read_contents, arraysize(read_contents)); EXPECT_STREQ(kFileContents2, read_contents); } diff --git a/chrome/browser/chromeos/boot_times_loader.cc b/chrome/browser/chromeos/boot_times_loader.cc index f7ee861..451c6a0 100644 --- a/chrome/browser/chromeos/boot_times_loader.cc +++ b/chrome/browser/chromeos/boot_times_loader.cc @@ -129,12 +129,12 @@ BootTimesLoader* BootTimesLoader::Get() { static int AppendFile(const base::FilePath& file_path, const char* data, int size) { - FILE* file = file_util::OpenFile(file_path, "a"); + FILE* file = base::OpenFile(file_path, "a"); if (!file) { return -1; } const int num_bytes_written = fwrite(data, 1, size, file); - file_util::CloseFile(file); + base::CloseFile(file); return num_bytes_written; } diff --git a/chrome/browser/chromeos/drive/file_cache.cc b/chrome/browser/chromeos/drive/file_cache.cc index 7b96f93..876df69 100644 --- a/chrome/browser/chromeos/drive/file_cache.cc +++ b/chrome/browser/chromeos/drive/file_cache.cc @@ -429,7 +429,7 @@ bool FileCache::RecoverFilesFromCacheDirectory( // Read file contents to sniff mime type. std::vector<char> content(net::kMaxBytesToSniff); const int read_result = - file_util::ReadFile(current, &content[0], content.size()); + base::ReadFile(current, &content[0], content.size()); if (read_result < 0) { LOG(WARNING) << "Cannot read: " << current.value(); return false; diff --git a/chrome/browser/chromeos/login/parallel_authenticator_unittest.cc b/chrome/browser/chromeos/login/parallel_authenticator_unittest.cc index 831c626..1a61dc2 100644 --- a/chrome/browser/chromeos/login/parallel_authenticator_unittest.cc +++ b/chrome/browser/chromeos/login/parallel_authenticator_unittest.cc @@ -98,7 +98,7 @@ class ParallelAuthenticatorTest : public testing::Test { FILE* tmp_file = base::CreateAndOpenTemporaryFile(&out); EXPECT_NE(tmp_file, static_cast<FILE*>(NULL)); EXPECT_EQ(file_util::WriteFile(out, data, data_len), data_len); - EXPECT_TRUE(file_util::CloseFile(tmp_file)); + EXPECT_TRUE(base::CloseFile(tmp_file)); return out; } diff --git a/chrome/browser/chromeos/login/startup_utils.cc b/chrome/browser/chromeos/login/startup_utils.cc index 70a4244..153182b 100644 --- a/chrome/browser/chromeos/login/startup_utils.cc +++ b/chrome/browser/chromeos/login/startup_utils.cc @@ -95,11 +95,11 @@ static void CreateOobeCompleteFlagFile() { // Create flag file for boot-time init scripts. base::FilePath oobe_complete_path = GetOobeCompleteFlagPath(); if (!base::PathExists(oobe_complete_path)) { - FILE* oobe_flag_file = file_util::OpenFile(oobe_complete_path, "w+b"); + FILE* oobe_flag_file = base::OpenFile(oobe_complete_path, "w+b"); if (oobe_flag_file == NULL) DLOG(WARNING) << oobe_complete_path.value() << " doesn't exist."; else - file_util::CloseFile(oobe_flag_file); + base::CloseFile(oobe_flag_file); } } diff --git a/chrome/browser/chromeos/policy/enterprise_install_attributes.cc b/chrome/browser/chromeos/policy/enterprise_install_attributes.cc index 278309d..7c96eb8 100644 --- a/chrome/browser/chromeos/policy/enterprise_install_attributes.cc +++ b/chrome/browser/chromeos/policy/enterprise_install_attributes.cc @@ -107,7 +107,7 @@ void EnterpriseInstallAttributes::ReadCacheFile( device_locked_ = true; char buf[16384]; - int len = file_util::ReadFile(cache_file, buf, sizeof(buf)); + int len = base::ReadFile(cache_file, buf, sizeof(buf)); if (len == -1 || len >= static_cast<int>(sizeof(buf))) { PLOG(ERROR) << "Failed to read " << cache_file.value(); return; diff --git a/chrome/browser/chromeos/policy/user_cloud_policy_store_chromeos.cc b/chrome/browser/chromeos/policy/user_cloud_policy_store_chromeos.cc index cf9eeb3..980bfdf 100644 --- a/chrome/browser/chromeos/policy/user_cloud_policy_store_chromeos.cc +++ b/chrome/browser/chromeos/policy/user_cloud_policy_store_chromeos.cc @@ -505,7 +505,7 @@ void UserCloudPolicyStoreChromeOS::LoadPolicyKey(const base::FilePath& path, LOG(ERROR) << "Key at " << path.value() << " has bad size " << size; } else { key->resize(size); - int read_size = file_util::ReadFile( + int read_size = base::ReadFile( path, reinterpret_cast<char*>(vector_as_array(key)), size); if (read_size != size) { LOG(ERROR) << "Failed to read key at " << path.value(); diff --git a/chrome/browser/chromeos/settings/owner_key_util.cc b/chrome/browser/chromeos/settings/owner_key_util.cc index 560a6ce..d98fe07 100644 --- a/chrome/browser/chromeos/settings/owner_key_util.cc +++ b/chrome/browser/chromeos/settings/owner_key_util.cc @@ -58,7 +58,7 @@ bool OwnerKeyUtilImpl::ImportPublicKey(std::vector<uint8>* output) { } // Get the key data off of disk - int data_read = file_util::ReadFile( + int data_read = base::ReadFile( key_file_, reinterpret_cast<char*>(vector_as_array(output)), safe_file_size); diff --git a/chrome/browser/component_updater/component_unpacker.cc b/chrome/browser/component_updater/component_unpacker.cc index 789049a..ba9f658 100644 --- a/chrome/browser/component_updater/component_unpacker.cc +++ b/chrome/browser/component_updater/component_unpacker.cc @@ -122,7 +122,7 @@ ComponentUnpacker::ComponentUnpacker(const std::vector<uint8>& pk_hash, } // First, validate the CRX header and signature. As of today // this is SHA1 with RSA 1024. - ScopedStdioHandle file(file_util::OpenFile(path, "rb")); + ScopedStdioHandle file(base::OpenFile(path, "rb")); if (!file.get()) { error_ = kInvalidFile; return; diff --git a/chrome/browser/extensions/extension_creator.cc b/chrome/browser/extensions/extension_creator.cc index be9ac61..c31a399 100644 --- a/chrome/browser/extensions/extension_creator.cc +++ b/chrome/browser/extensions/extension_creator.cc @@ -213,7 +213,7 @@ bool ExtensionCreator::SignZip(const base::FilePath& zip_path, std::vector<uint8>* signature) { scoped_ptr<crypto::SignatureCreator> signature_creator( crypto::SignatureCreator::Create(private_key)); - ScopedStdioHandle zip_handle(file_util::OpenFile(zip_path, "rb")); + ScopedStdioHandle zip_handle(base::OpenFile(zip_path, "rb")); size_t buffer_size = 1 << 16; scoped_ptr<uint8[]> buffer(new uint8[buffer_size]); int bytes_read = -1; @@ -241,7 +241,7 @@ bool ExtensionCreator::WriteCRX(const base::FilePath& zip_path, const base::FilePath& crx_path) { if (base::PathExists(crx_path)) base::DeleteFile(crx_path, false); - ScopedStdioHandle crx_handle(file_util::OpenFile(crx_path, "wb")); + ScopedStdioHandle crx_handle(base::OpenFile(crx_path, "wb")); if (!crx_handle.get()) { error_message_ = l10n_util::GetStringUTF8(IDS_EXTENSION_SHARING_VIOLATION); return false; @@ -273,7 +273,7 @@ bool ExtensionCreator::WriteCRX(const base::FilePath& zip_path, size_t buffer_size = 1 << 16; scoped_ptr<uint8[]> buffer(new uint8[buffer_size]); size_t bytes_read = 0; - ScopedStdioHandle zip_handle(file_util::OpenFile(zip_path, "rb")); + ScopedStdioHandle zip_handle(base::OpenFile(zip_path, "rb")); while ((bytes_read = fread(buffer.get(), 1, buffer_size, zip_handle.get())) > 0) { if (fwrite(buffer.get(), sizeof(char), bytes_read, crx_handle.get()) != diff --git a/chrome/browser/extensions/external_registry_loader_win.cc b/chrome/browser/extensions/external_registry_loader_win.cc index 599b0cd..2edf5fa 100644 --- a/chrome/browser/extensions/external_registry_loader_win.cc +++ b/chrome/browser/extensions/external_registry_loader_win.cc @@ -33,7 +33,7 @@ const wchar_t kRegistryExtensionPath[] = L"path"; const wchar_t kRegistryExtensionVersion[] = L"version"; bool CanOpenFileForReading(const base::FilePath& path) { - ScopedStdioHandle file_handle(file_util::OpenFile(path, "rb")); + ScopedStdioHandle file_handle(base::OpenFile(path, "rb")); return file_handle.get() != NULL; } diff --git a/chrome/browser/extensions/sandboxed_unpacker.cc b/chrome/browser/extensions/sandboxed_unpacker.cc index 48c9230..34716af 100644 --- a/chrome/browser/extensions/sandboxed_unpacker.cc +++ b/chrome/browser/extensions/sandboxed_unpacker.cc @@ -415,7 +415,7 @@ void SandboxedUnpacker::OnUnpackExtensionFailed(const string16& error) { } bool SandboxedUnpacker::ValidateSignature() { - ScopedStdioHandle file(file_util::OpenFile(crx_path_, "rb")); + ScopedStdioHandle file(base::OpenFile(crx_path_, "rb")); if (!file.get()) { // Could not open crx file for reading. diff --git a/chrome/browser/importer/firefox_profile_lock_unittest.cc b/chrome/browser/importer/firefox_profile_lock_unittest.cc index c93d987..24a3259 100644 --- a/chrome/browser/importer/firefox_profile_lock_unittest.cc +++ b/chrome/browser/importer/firefox_profile_lock_unittest.cc @@ -70,9 +70,9 @@ TEST_F(FirefoxProfileLockTest, ProfileLockOrphaned) { test_path.Append(FirefoxProfileLock::kLockFileName); // Create the orphaned lock file. - FILE* lock_file = file_util::OpenFile(lock_file_path, "w"); + FILE* lock_file = base::OpenFile(lock_file_path, "w"); ASSERT_TRUE(lock_file); - file_util::CloseFile(lock_file); + base::CloseFile(lock_file); EXPECT_TRUE(base::PathExists(lock_file_path)); scoped_ptr<FirefoxProfileLock> lock; diff --git a/chrome/browser/net/net_log_temp_file.cc b/chrome/browser/net/net_log_temp_file.cc index f68528b..f117ae7 100644 --- a/chrome/browser/net/net_log_temp_file.cc +++ b/chrome/browser/net/net_log_temp_file.cc @@ -96,7 +96,7 @@ void NetLogTempFile::StartNetLog() { // Try to make sure we can create the file. // TODO(rtenneti): Find a better for doing the following. Surface some error // to the user if we couldn't create the file. - FILE* file = file_util::OpenFile(log_path_, "w"); + FILE* file = base::OpenFile(log_path_, "w"); if (file == NULL) return; diff --git a/chrome/browser/parsers/metadata_parser_manager.cc b/chrome/browser/parsers/metadata_parser_manager.cc index 1b10f98..b60a0dd 100644 --- a/chrome/browser/parsers/metadata_parser_manager.cc +++ b/chrome/browser/parsers/metadata_parser_manager.cc @@ -39,7 +39,7 @@ MetadataParser* MetadataParserManager::GetParserForFile( char buffer[kAmountToRead]; int amount_read = 0; DLOG(ERROR) << path.value(); - amount_read = file_util::ReadFile(path, buffer, sizeof(buffer)); + amount_read = base::ReadFile(path, buffer, sizeof(buffer)); if (amount_read <= 0) { DLOG(ERROR) << "Unable to read file"; return NULL; diff --git a/chrome/browser/safe_browsing/prefix_set.cc b/chrome/browser/safe_browsing/prefix_set.cc index e3100c7..4a1ff73 100644 --- a/chrome/browser/safe_browsing/prefix_set.cc +++ b/chrome/browser/safe_browsing/prefix_set.cc @@ -160,7 +160,7 @@ PrefixSet* PrefixSet::LoadFile(const base::FilePath& filter_name) { if (size_64 < static_cast<int64>(sizeof(FileHeader) + sizeof(MD5Digest))) return NULL; - file_util::ScopedFILE file(file_util::OpenFile(filter_name, "rb")); + file_util::ScopedFILE file(base::OpenFile(filter_name, "rb")); if (!file.get()) return NULL; @@ -243,7 +243,7 @@ bool PrefixSet::WriteFile(const base::FilePath& filter_name) const { return false; } - file_util::ScopedFILE file(file_util::OpenFile(filter_name, "wb")); + file_util::ScopedFILE file(base::OpenFile(filter_name, "wb")); if (!file.get()) return false; diff --git a/chrome/browser/safe_browsing/prefix_set_unittest.cc b/chrome/browser/safe_browsing/prefix_set_unittest.cc index 10865e9..ee3c3fb 100644 --- a/chrome/browser/safe_browsing/prefix_set_unittest.cc +++ b/chrome/browser/safe_browsing/prefix_set_unittest.cc @@ -151,7 +151,7 @@ class PrefixSetTest : public PlatformTest { int64 size_64; ASSERT_TRUE(base::GetFileSize(filename, &size_64)); - file_util::ScopedFILE file(file_util::OpenFile(filename, "r+b")); + file_util::ScopedFILE file(base::OpenFile(filename, "r+b")); IncrementIntAt(file.get(), offset, inc); CleanChecksum(file.get()); file.reset(); @@ -373,7 +373,7 @@ TEST_F(PrefixSetTest, CorruptionHelpers) { ASSERT_TRUE(GetPrefixSetFile(&filename)); // This will modify data in |index_|, which will fail the digest check. - file_util::ScopedFILE file(file_util::OpenFile(filename, "r+b")); + file_util::ScopedFILE file(base::OpenFile(filename, "r+b")); IncrementIntAt(file.get(), kPayloadOffset, 1); file.reset(); scoped_ptr<safe_browsing::PrefixSet> @@ -382,7 +382,7 @@ TEST_F(PrefixSetTest, CorruptionHelpers) { // Fix up the checksum and it will read successfully (though the // data will be wrong). - file.reset(file_util::OpenFile(filename, "r+b")); + file.reset(base::OpenFile(filename, "r+b")); CleanChecksum(file.get()); file.reset(); prefix_set.reset(safe_browsing::PrefixSet::LoadFile(filename)); @@ -443,7 +443,7 @@ TEST_F(PrefixSetTest, CorruptionPayload) { base::FilePath filename; ASSERT_TRUE(GetPrefixSetFile(&filename)); - file_util::ScopedFILE file(file_util::OpenFile(filename, "r+b")); + file_util::ScopedFILE file(base::OpenFile(filename, "r+b")); ASSERT_NO_FATAL_FAILURE(IncrementIntAt(file.get(), 666, 1)); file.reset(); scoped_ptr<safe_browsing::PrefixSet> @@ -458,7 +458,7 @@ TEST_F(PrefixSetTest, CorruptionDigest) { int64 size_64; ASSERT_TRUE(base::GetFileSize(filename, &size_64)); - file_util::ScopedFILE file(file_util::OpenFile(filename, "r+b")); + file_util::ScopedFILE file(base::OpenFile(filename, "r+b")); long digest_offset = static_cast<long>(size_64 - sizeof(base::MD5Digest)); ASSERT_NO_FATAL_FAILURE(IncrementIntAt(file.get(), digest_offset, 1)); file.reset(); @@ -473,7 +473,7 @@ TEST_F(PrefixSetTest, CorruptionExcess) { ASSERT_TRUE(GetPrefixSetFile(&filename)); // Add some junk to the trunk. - file_util::ScopedFILE file(file_util::OpenFile(filename, "ab")); + file_util::ScopedFILE file(base::OpenFile(filename, "ab")); const char buf[] = "im in ur base, killing ur d00dz."; ASSERT_EQ(strlen(buf), fwrite(buf, 1, strlen(buf), file.get())); file.reset(); diff --git a/chrome/browser/safe_browsing/safe_browsing_database_unittest.cc b/chrome/browser/safe_browsing/safe_browsing_database_unittest.cc index 9810858..daa0b11 100644 --- a/chrome/browser/safe_browsing/safe_browsing_database_unittest.cc +++ b/chrome/browser/safe_browsing/safe_browsing_database_unittest.cc @@ -1152,7 +1152,7 @@ TEST_F(SafeBrowsingDatabaseTest, DISABLED_FileCorruptionHandling) { // Corrupt the file by corrupting the checksum, which is not checked // until the entire table is read in |UpdateFinished()|. - FILE* fp = file_util::OpenFile(database_filename_, "r+"); + FILE* fp = base::OpenFile(database_filename_, "r+"); ASSERT_TRUE(fp); ASSERT_NE(-1, fseek(fp, -8, SEEK_END)); for (size_t i = 0; i < 8; ++i) { diff --git a/chrome/browser/safe_browsing/safe_browsing_store_file.cc b/chrome/browser/safe_browsing/safe_browsing_store_file.cc index 3500819..a1be058 100644 --- a/chrome/browser/safe_browsing/safe_browsing_store_file.cc +++ b/chrome/browser/safe_browsing/safe_browsing_store_file.cc @@ -292,7 +292,7 @@ bool SafeBrowsingStoreFile::WriteAddPrefix(int32 chunk_id, SBPrefix prefix) { bool SafeBrowsingStoreFile::GetAddPrefixes(SBAddPrefixes* add_prefixes) { add_prefixes->clear(); - file_util::ScopedFILE file(file_util::OpenFile(filename_, "rb")); + file_util::ScopedFILE file(base::OpenFile(filename_, "rb")); if (file.get() == NULL) return false; FileHeader header; @@ -314,7 +314,7 @@ bool SafeBrowsingStoreFile::GetAddFullHashes( std::vector<SBAddFullHash>* add_full_hashes) { add_full_hashes->clear(); - file_util::ScopedFILE file(file_util::OpenFile(filename_, "rb")); + file_util::ScopedFILE file(base::OpenFile(filename_, "rb")); if (file.get() == NULL) return false; FileHeader header; @@ -397,11 +397,11 @@ bool SafeBrowsingStoreFile::BeginUpdate() { corruption_seen_ = false; const base::FilePath new_filename = TemporaryFileForFilename(filename_); - file_util::ScopedFILE new_file(file_util::OpenFile(new_filename, "wb+")); + file_util::ScopedFILE new_file(base::OpenFile(new_filename, "wb+")); if (new_file.get() == NULL) return false; - file_util::ScopedFILE file(file_util::OpenFile(filename_, "rb")); + file_util::ScopedFILE file(base::OpenFile(filename_, "rb")); empty_ = (file.get() == NULL); if (empty_) { // If the file exists but cannot be opened, try to delete it (not @@ -644,7 +644,7 @@ bool SafeBrowsingStoreFile::DoUpdate( return false; // Trim any excess left over from the temporary chunk data. - if (!file_util::TruncateFile(new_file_.get())) + if (!base::TruncateFile(new_file_.get())) return false; // Close the file handle and swizzle the file into place. diff --git a/chrome/browser/safe_browsing/safe_browsing_store_file_unittest.cc b/chrome/browser/safe_browsing/safe_browsing_store_file_unittest.cc index ac8002f..28add4a 100644 --- a/chrome/browser/safe_browsing/safe_browsing_store_file_unittest.cc +++ b/chrome/browser/safe_browsing/safe_browsing_store_file_unittest.cc @@ -90,7 +90,7 @@ TEST_F(SafeBrowsingStoreFileTest, DetectsCorruption) { EXPECT_FALSE(corruption_detected_); // Corrupt the store. - file_util::ScopedFILE file(file_util::OpenFile(filename_, "rb+")); + file_util::ScopedFILE file(base::OpenFile(filename_, "rb+")); const long kOffset = 60; EXPECT_EQ(fseek(file.get(), kOffset, SEEK_SET), 0); const int32 kZero = 0; @@ -114,7 +114,7 @@ TEST_F(SafeBrowsingStoreFileTest, DetectsCorruption) { // Make it look like there is a lot of add-chunks-seen data. const long kAddChunkCountOffset = 2 * sizeof(int32); const int32 kLargeCount = 1000 * 1000 * 1000; - file.reset(file_util::OpenFile(filename_, "rb+")); + file.reset(base::OpenFile(filename_, "rb+")); EXPECT_EQ(fseek(file.get(), kAddChunkCountOffset, SEEK_SET), 0); EXPECT_EQ(fwrite(&kLargeCount, sizeof(kLargeCount), 1, file.get()), 1U); file.reset(); @@ -156,7 +156,7 @@ TEST_F(SafeBrowsingStoreFileTest, CheckValidityPayload) { const size_t kOffset = 37; { - file_util::ScopedFILE file(file_util::OpenFile(filename_, "rb+")); + file_util::ScopedFILE file(base::OpenFile(filename_, "rb+")); EXPECT_EQ(0, fseek(file.get(), kOffset, SEEK_SET)); EXPECT_GE(fputs("hello", file.get()), 0); } @@ -176,7 +176,7 @@ TEST_F(SafeBrowsingStoreFileTest, CheckValidityChecksum) { const int kOffset = -static_cast<int>(sizeof(base::MD5Digest)); { - file_util::ScopedFILE file(file_util::OpenFile(filename_, "rb+")); + file_util::ScopedFILE file(base::OpenFile(filename_, "rb+")); EXPECT_EQ(0, fseek(file.get(), kOffset, SEEK_END)); EXPECT_GE(fputs("hello", file.get()), 0); } diff --git a/chrome/browser/storage_monitor/image_capture_device_manager_unittest.mm b/chrome/browser/storage_monitor/image_capture_device_manager_unittest.mm index 5b2e317..42f0a42 100644 --- a/chrome/browser/storage_monitor/image_capture_device_manager_unittest.mm +++ b/chrome/browser/storage_monitor/image_capture_device_manager_unittest.mm @@ -391,8 +391,8 @@ TEST_F(ImageCaptureDeviceManagerTest, DownloadFile) { EXPECT_EQ(kTestFileName, listener_.downloads()[1]); ASSERT_EQ(base::PLATFORM_FILE_OK, listener_.last_error()); char file_contents[5]; - ASSERT_EQ(4, file_util::ReadFile(temp_file, file_contents, - strlen(kTestFileContents))); + ASSERT_EQ(4, base::ReadFile(temp_file, file_contents, + strlen(kTestFileContents))); EXPECT_EQ(kTestFileContents, std::string(file_contents, strlen(kTestFileContents))); @@ -425,8 +425,8 @@ TEST_F(ImageCaptureDeviceManagerTest, TestSubdirectories) { base::RunLoop().RunUntilIdle(); char file_contents[5]; - ASSERT_EQ(4, file_util::ReadFile(temp_file, file_contents, - strlen(kTestFileContents))); + ASSERT_EQ(4, base::ReadFile(temp_file, file_contents, + strlen(kTestFileContents))); EXPECT_EQ(kTestFileContents, std::string(file_contents, strlen(kTestFileContents))); diff --git a/chrome/browser/ui/pdf/pdf_browsertest.cc b/chrome/browser/ui/pdf/pdf_browsertest.cc index 105feac..6373095 100644 --- a/chrome/browser/ui/pdf/pdf_browsertest.cc +++ b/chrome/browser/ui/pdf/pdf_browsertest.cc @@ -133,7 +133,7 @@ class PDFBrowserTest : public InProcessBrowserTest, 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)); + ASSERT_EQ(size, base::ReadFile(reference, data.get(), size)); int w, h; std::vector<unsigned char> decoded; diff --git a/chrome/browser/ui/views/select_file_dialog_extension_browsertest.cc b/chrome/browser/ui/views/select_file_dialog_extension_browsertest.cc index 8b5c742..3df3b31 100644 --- a/chrome/browser/ui/views/select_file_dialog_extension_browsertest.cc +++ b/chrome/browser/ui/views/select_file_dialog_extension_browsertest.cc @@ -272,9 +272,9 @@ IN_PROC_BROWSER_TEST_F(SelectFileDialogExtensionBrowserTest, downloads_dir_.AppendASCII("file_manager_test.html"); // Create an empty file to give us something to select. - FILE* fp = file_util::OpenFile(test_file, "w"); + FILE* fp = base::OpenFile(test_file, "w"); ASSERT_TRUE(fp != NULL); - ASSERT_TRUE(file_util::CloseFile(fp)); + ASSERT_TRUE(base::CloseFile(fp)); gfx::NativeWindow owning_window = browser()->window()->GetNativeWindow(); diff --git a/chrome/browser/ui/webui/net_internals/net_internals_ui_browsertest.cc b/chrome/browser/ui/webui/net_internals/net_internals_ui_browsertest.cc index 68345cb..5ce3876 100644 --- a/chrome/browser/ui/webui/net_internals/net_internals_ui_browsertest.cc +++ b/chrome/browser/ui/webui/net_internals/net_internals_ui_browsertest.cc @@ -342,7 +342,7 @@ void NetInternalsTest::MessageHandler::GetNetLogLoggerLog( base::FilePath temp_file; ASSERT_TRUE(base::CreateTemporaryFileInDir(temp_directory.path(), &temp_file)); - FILE* temp_file_handle = file_util::OpenFile(temp_file, "w"); + FILE* temp_file_handle = base::OpenFile(temp_file, "w"); ASSERT_TRUE(temp_file_handle); scoped_ptr<base::Value> constants(NetInternalsUI::GetConstants()); diff --git a/chrome/browser/web_applications/web_app_win.cc b/chrome/browser/web_applications/web_app_win.cc index a4d465b1..a4bf6d8 100644 --- a/chrome/browser/web_applications/web_app_win.cc +++ b/chrome/browser/web_applications/web_app_win.cc @@ -81,7 +81,7 @@ bool ShouldUpdateIcon(const base::FilePath& icon_file, return true; base::MD5Digest persisted_image_checksum; - if (sizeof(persisted_image_checksum) != file_util::ReadFile(checksum_file, + if (sizeof(persisted_image_checksum) != base::ReadFile(checksum_file, reinterpret_cast<char*>(&persisted_image_checksum), sizeof(persisted_image_checksum))) return true; diff --git a/chrome/tools/convert_dict/aff_reader.cc b/chrome/tools/convert_dict/aff_reader.cc index b6ad12c..6ef94a8 100644 --- a/chrome/tools/convert_dict/aff_reader.cc +++ b/chrome/tools/convert_dict/aff_reader.cc @@ -60,7 +60,7 @@ void Panic(const char* fmt, ...) { AffReader::AffReader(const base::FilePath& path) : has_indexed_affixes_(false) { - file_ = file_util::OpenFile(path, "r"); + file_ = base::OpenFile(path, "r"); // Default to Latin1 in case the file doesn't specify it. encoding_ = "ISO8859-1"; @@ -68,7 +68,7 @@ AffReader::AffReader(const base::FilePath& path) AffReader::~AffReader() { if (file_) - file_util::CloseFile(file_); + base::CloseFile(file_); } bool AffReader::Read() { diff --git a/chrome/tools/convert_dict/convert_dict.cc b/chrome/tools/convert_dict/convert_dict.cc index 02cafe3..3c2c6da 100644 --- a/chrome/tools/convert_dict/convert_dict.cc +++ b/chrome/tools/convert_dict/convert_dict.cc @@ -136,14 +136,14 @@ int main(int argc, char* argv[]) { base::FilePath out_path = file_base.ReplaceExtension(FILE_PATH_LITERAL(".bdic")); printf("Writing %" PRFilePath " ...\n", out_path.value().c_str()); - FILE* out_file = file_util::OpenFile(out_path, "wb"); + FILE* out_file = base::OpenFile(out_path, "wb"); if (!out_file) { printf("ERROR writing file\n"); return 1; } size_t written = fwrite(&serialized[0], 1, serialized.size(), out_file); CHECK(written == serialized.size()); - file_util::CloseFile(out_file); + base::CloseFile(out_file); return 0; } diff --git a/chrome/tools/convert_dict/dic_reader.cc b/chrome/tools/convert_dict/dic_reader.cc index adf13a1..e4bffa8 100644 --- a/chrome/tools/convert_dict/dic_reader.cc +++ b/chrome/tools/convert_dict/dic_reader.cc @@ -129,11 +129,11 @@ bool PopulateWordSet(WordSet* word_set, FILE* file, AffReader* aff_reader, } // namespace DicReader::DicReader(const base::FilePath& path) { - file_ = file_util::OpenFile(path, "r"); + file_ = base::OpenFile(path, "r"); base::FilePath additional_path = path.ReplaceExtension(FILE_PATH_LITERAL("dic_delta")); - additional_words_file_ = file_util::OpenFile(additional_path, "r"); + additional_words_file_ = base::OpenFile(additional_path, "r"); if (additional_words_file_) printf("Reading %" PRFilePath " ...\n", additional_path.value().c_str()); @@ -143,9 +143,9 @@ DicReader::DicReader(const base::FilePath& path) { DicReader::~DicReader() { if (file_) - file_util::CloseFile(file_); + base::CloseFile(file_); if (additional_words_file_) - file_util::CloseFile(additional_words_file_); + base::CloseFile(additional_words_file_); } bool DicReader::Read(AffReader* aff_reader) { diff --git a/cloud_print/virtual_driver/win/port_monitor/port_monitor.cc b/cloud_print/virtual_driver/win/port_monitor/port_monitor.cc index 6171296..a905be1 100644 --- a/cloud_print/virtual_driver/win/port_monitor/port_monitor.cc +++ b/cloud_print/virtual_driver/win/port_monitor/port_monitor.cc @@ -62,7 +62,7 @@ struct PortData { printer_handle = NULL; } if (file) { - file_util::CloseFile(file); + base::CloseFile(file); file = NULL; } } @@ -433,7 +433,7 @@ BOOL WINAPI Monitor2StartDocPort(HANDLE port_handle, LOG(ERROR) << "Can't create temporary file in " << app_data_dir.value(); return FALSE; } - port_data->file = file_util::OpenFile(file_path, "wb+"); + port_data->file = base::OpenFile(file_path, "wb+"); if (port_data->file == NULL) { LOG(ERROR) << "Error opening file " << file_path.value() << "."; return FALSE; @@ -478,7 +478,7 @@ BOOL WINAPI Monitor2EndDocPort(HANDLE port_handle) { } if (port_data->file != NULL) { - file_util::CloseFile(port_data->file); + base::CloseFile(port_data->file); port_data->file = NULL; bool delete_file = true; int64 file_size = 0; diff --git a/components/visitedlink/browser/visitedlink_master.cc b/components/visitedlink/browser/visitedlink_master.cc index 7cf6891..f4e3e2a 100644 --- a/components/visitedlink/browser/visitedlink_master.cc +++ b/components/visitedlink/browser/visitedlink_master.cc @@ -31,8 +31,6 @@ using content::BrowserThread; using file_util::ScopedFILE; -using file_util::OpenFile; -using file_util::TruncateFile; namespace visitedlink { @@ -68,7 +66,7 @@ void GenerateSalt(uint8 salt[LINK_SALT_LENGTH]) { // Opens file on a background thread to not block UI thread. void AsyncOpen(FILE** file, const base::FilePath& filename) { - *file = OpenFile(filename, "wb+"); + *file = base::OpenFile(filename, "wb+"); DLOG_IF(ERROR, !(*file)) << "Failed to open file " << filename.value(); } @@ -105,7 +103,7 @@ void AsyncWrite(FILE** file, int32 offset, const std::string& data) { // by the time of scheduling the task for execution. void AsyncTruncate(FILE** file) { if (*file) - base::IgnoreResult(TruncateFile(*file)); + base::IgnoreResult(base::TruncateFile(*file)); } // Closes the file on a background thread and releases memory used for storage @@ -542,7 +540,7 @@ bool VisitedLinkMaster::InitFromFile() { base::FilePath filename; GetDatabaseFileName(&filename); - ScopedFILE file_closer(OpenFile(filename, "rb+")); + ScopedFILE file_closer(base::OpenFile(filename, "rb+")); if (!file_closer.get()) return false; diff --git a/content/browser/browser_shutdown_profile_dumper.cc b/content/browser/browser_shutdown_profile_dumper.cc index ebec936..3e74e06 100644 --- a/content/browser/browser_shutdown_profile_dumper.cc +++ b/content/browser/browser_shutdown_profile_dumper.cc @@ -37,7 +37,7 @@ void BrowserShutdownProfileDumper::WriteTracesToDisc( base::debug::TraceLog::GetInstance()->GetBufferPercentFull() << " full."; DCHECK(!dump_file_); - dump_file_ = file_util::OpenFile(file_name, "w+"); + dump_file_ = base::OpenFile(file_name, "w+"); if (!IsFileValid()) { LOG(ERROR) << "Failed to open performance trace file: " << file_name.value(); @@ -131,7 +131,7 @@ void BrowserShutdownProfileDumper::WriteChars(const char* chars, size_t size) { void BrowserShutdownProfileDumper::CloseFile() { if (!dump_file_) return; - file_util::CloseFile(dump_file_); + base::CloseFile(dump_file_); dump_file_ = NULL; } diff --git a/content/browser/fileapi/file_system_operation_impl_unittest.cc b/content/browser/fileapi/file_system_operation_impl_unittest.cc index 236cc8e..445657d 100644 --- a/content/browser/fileapi/file_system_operation_impl_unittest.cc +++ b/content/browser/fileapi/file_system_operation_impl_unittest.cc @@ -689,8 +689,8 @@ TEST_F(FileSystemOperationImplTest, TestCopyInForeignFileSuccess) { // Compare contents of src and copied file. char buffer[100]; - EXPECT_EQ(data_size, file_util::ReadFile(PlatformPath("dest/file"), - buffer, data_size)); + EXPECT_EQ(data_size, base::ReadFile(PlatformPath("dest/file"), + buffer, data_size)); for (int i = 0; i < data_size; ++i) EXPECT_EQ(test_data[i], buffer[i]); } @@ -1009,7 +1009,7 @@ TEST_F(FileSystemOperationImplTest, TestTruncate) { // data. EXPECT_EQ(length, GetFileSize("file")); char data[100]; - EXPECT_EQ(length, file_util::ReadFile(platform_path, data, length)); + EXPECT_EQ(length, base::ReadFile(platform_path, data, length)); for (int i = 0; i < length; ++i) { if (i < static_cast<int>(sizeof(test_data))) EXPECT_EQ(test_data[i], data[i]); @@ -1028,7 +1028,7 @@ TEST_F(FileSystemOperationImplTest, TestTruncate) { // Check that its length is now 3 and that it contains only bits of test data. EXPECT_EQ(length, GetFileSize("file")); - EXPECT_EQ(length, file_util::ReadFile(platform_path, data, length)); + EXPECT_EQ(length, base::ReadFile(platform_path, data, length)); for (int i = 0; i < length; ++i) EXPECT_EQ(test_data[i], data[i]); diff --git a/content/browser/renderer_host/media/video_capture_host_unittest.cc b/content/browser/renderer_host/media/video_capture_host_unittest.cc index a4e79e8..1c169a4 100644 --- a/content/browser/renderer_host/media/video_capture_host_unittest.cc +++ b/content/browser/renderer_host/media/video_capture_host_unittest.cc @@ -60,7 +60,7 @@ class DumpVideo { void StartDump(int width, int height) { base::FilePath file_name = base::FilePath(base::StringPrintf( FILE_PATH_LITERAL("dump_w%d_h%d.yuv"), width, height)); - file_.reset(file_util::OpenFile(file_name, "wb")); + file_.reset(base::OpenFile(file_name, "wb")); expected_size_ = media::VideoFrame::AllocationSize( media::VideoFrame::I420, gfx::Size(width, height)); } diff --git a/content/browser/tracing/tracing_controller_impl.cc b/content/browser/tracing/tracing_controller_impl.cc index ba9f2e0..bc7cee2 100644 --- a/content/browser/tracing/tracing_controller_impl.cc +++ b/content/browser/tracing/tracing_controller_impl.cc @@ -68,7 +68,7 @@ TracingControllerImpl::ResultFile::ResultFile(const base::FilePath& path) void TracingControllerImpl::ResultFile::OpenTask() { if (path_.empty()) base::CreateTemporaryFile(&path_); - file_ = file_util::OpenFile(path_, "w"); + file_ = base::OpenFile(path_, "w"); if (!file_) { LOG(ERROR) << "Failed to open " << path_.value(); return; @@ -104,7 +104,7 @@ void TracingControllerImpl::ResultFile::CloseTask( const char* trailout = "]}"; size_t written = fwrite(trailout, strlen(trailout), 1, file_); DCHECK(written == 1); - file_util::CloseFile(file_); + base::CloseFile(file_); file_ = NULL; BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback); diff --git a/content/child/npapi/plugin_stream_posix.cc b/content/child/npapi/plugin_stream_posix.cc index b84a6d9..8c74d83 100644 --- a/content/child/npapi/plugin_stream_posix.cc +++ b/content/child/npapi/plugin_stream_posix.cc @@ -34,7 +34,7 @@ bool PluginStream::OpenTempFile() { DCHECK_EQ(static_cast<FILE*>(NULL), temp_file_); if (base::CreateTemporaryFile(&temp_file_path_)) - temp_file_ = file_util::OpenFile(temp_file_path_, "a"); + temp_file_ = base::OpenFile(temp_file_path_, "a"); if (!temp_file_) { base::DeleteFile(temp_file_path_, false); @@ -48,7 +48,7 @@ void PluginStream::CloseTempFile() { if (!TempFileIsValid()) return; - file_util::CloseFile(temp_file_); + base::CloseFile(temp_file_); ResetTempFileHandle(); } diff --git a/content/common/gpu/client/gl_helper_benchmark.cc b/content/common/gpu/client/gl_helper_benchmark.cc index 43ce6b6..f9385fd 100644 --- a/content/common/gpu/client/gl_helper_benchmark.cc +++ b/content/common/gpu/client/gl_helper_benchmark.cc @@ -102,11 +102,11 @@ class GLHelperTest : public testing::Test { std::vector<gfx::PNGCodec::Comment>(), &compressed)); ASSERT_TRUE(compressed.size()); - FILE* f = file_util::OpenFile(filename, "wb"); + FILE* f = base::OpenFile(filename, "wb"); ASSERT_TRUE(f); ASSERT_EQ(fwrite(&*compressed.begin(), 1, compressed.size(), f), compressed.size()); - file_util::CloseFile(f); + base::CloseFile(f); } scoped_ptr<webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl> diff --git a/content/common/mac/font_loader.mm b/content/common/mac/font_loader.mm index d919680..66b143f 100644 --- a/content/common/mac/font_loader.mm +++ b/content/common/mac/font_loader.mm @@ -140,9 +140,9 @@ void FontLoader::LoadFont(const FontDescriptor& font, return; } - int32 amt_read = file_util::ReadFile(font_path, - reinterpret_cast<char*>(result->font_data.memory()), - font_file_size_32); + int32 amt_read = base::ReadFile(font_path, + reinterpret_cast<char*>(result->font_data.memory()), + font_file_size_32); if (amt_read != font_file_size_32) { DLOG(ERROR) << "Failed to read font data for " << font_path.value(); return; diff --git a/content/common/page_state_serialization_unittest.cc b/content/common/page_state_serialization_unittest.cc index c0c98d3..c23a2fb 100644 --- a/content/common/page_state_serialization_unittest.cc +++ b/content/common/page_state_serialization_unittest.cc @@ -379,7 +379,7 @@ TEST_F(PageStateSerializationTest, DumpExpectedPageStateForBackwardsCompat) { PathService::Get(base::DIR_TEMP, &path); path = path.AppendASCII("expected.dat"); - FILE* fp = file_util::OpenFile(path, "wb"); + FILE* fp = base::OpenFile(path, "wb"); ASSERT_TRUE(fp); const size_t kRowSize = 76; diff --git a/content/common/plugin_list_posix.cc b/content/common/plugin_list_posix.cc index afe35d2..acd7830 100644 --- a/content/common/plugin_list_posix.cc +++ b/content/common/plugin_list_posix.cc @@ -180,7 +180,7 @@ bool ELFMatchesCurrentArchitecture(const base::FilePath& filename) { const size_t kELFBufferSize = 5; char buffer[kELFBufferSize]; - if (!file_util::ReadFile(filename, buffer, kELFBufferSize)) + if (!base::ReadFile(filename, buffer, kELFBufferSize)) return false; if (buffer[0] != ELFMAG0 || diff --git a/content/gpu/gpu_watchdog_thread.cc b/content/gpu/gpu_watchdog_thread.cc index b644aec..940d07e 100644 --- a/content/gpu/gpu_watchdog_thread.cc +++ b/content/gpu/gpu_watchdog_thread.cc @@ -57,7 +57,7 @@ GpuWatchdogThread::GpuWatchdogThread(int timeout) #endif #if defined(OS_CHROMEOS) - tty_file_ = file_util::OpenFile(base::FilePath(kTtyFilePath), "r"); + tty_file_ = base::OpenFile(base::FilePath(kTtyFilePath), "r"); #endif watched_message_loop_->AddTaskObserver(&task_observer_); } diff --git a/content/renderer/media/media_stream_audio_processor_unittest.cc b/content/renderer/media/media_stream_audio_processor_unittest.cc index 79311c8..1a6409c 100644 --- a/content/renderer/media/media_stream_audio_processor_unittest.cc +++ b/content/renderer/media/media_stream_audio_processor_unittest.cc @@ -46,7 +46,7 @@ void ReadDataFromSpeechFile(char* data, int length) { DCHECK(base::PathExists(file)); int64 data_file_size64 = 0; DCHECK(base::GetFileSize(file, &data_file_size64)); - EXPECT_EQ(length, file_util::ReadFile(file, data, length)); + EXPECT_EQ(length, base::ReadFile(file, data, length)); DCHECK(data_file_size64 > length); } diff --git a/content/renderer/media/webrtc_audio_device_unittest.cc b/content/renderer/media/webrtc_audio_device_unittest.cc index 5e111a5..73f0885 100644 --- a/content/renderer/media/webrtc_audio_device_unittest.cc +++ b/content/renderer/media/webrtc_audio_device_unittest.cc @@ -296,7 +296,7 @@ void ReadDataFromSpeechFile(char* data, int length) { DCHECK(base::PathExists(data_file)); int64 data_file_size64 = 0; DCHECK(base::GetFileSize(data_file, &data_file_size64)); - EXPECT_EQ(length, file_util::ReadFile(data_file, data, length)); + EXPECT_EQ(length, base::ReadFile(data_file, data, length)); DCHECK(data_file_size64 > length); } diff --git a/content/test/plugin/plugin_geturl_test.cc b/content/test/plugin/plugin_geturl_test.cc index 8bc62e0..c9b344d 100644 --- a/content/test/plugin/plugin_geturl_test.cc +++ b/content/test/plugin/plugin_geturl_test.cc @@ -212,7 +212,7 @@ NPError PluginGetURLTest::NewStream(NPMIMEType type, NPStream* stream, base::FilePath path = base::FilePath(filename); #endif - test_file_ = file_util::OpenFile(path, "r"); + test_file_ = base::OpenFile(path, "r"); if (!test_file_) { SetError("Could not open source file"); } @@ -356,7 +356,7 @@ NPError PluginGetURLTest::DestroyStream(NPStream *stream, NPError reason) { size_t bytes = fread(read_buffer, 1, sizeof(read_buffer), test_file_); if (bytes != 0) SetError("Data and source mismatch on length"); - file_util::CloseFile(test_file_); + base::CloseFile(test_file_); } break; default: diff --git a/content/test/weburl_loader_mock_factory.cc b/content/test/weburl_loader_mock_factory.cc index 38a9d50..f4aa677 100644 --- a/content/test/weburl_loader_mock_factory.cc +++ b/content/test/weburl_loader_mock_factory.cc @@ -182,7 +182,7 @@ bool WebURLLoaderMockFactory::ReadFile(const base::FilePath& file_path, int size = static_cast<int>(file_size); scoped_ptr<char[]> buffer(new char[size]); data->reset(); - int read_count = file_util::ReadFile(file_path, buffer.get(), size); + int read_count = base::ReadFile(file_path, buffer.get(), size); if (read_count == -1) return false; DCHECK(read_count == size); diff --git a/gpu/tools/compositor_model_bench/compositor_model_bench.cc b/gpu/tools/compositor_model_bench/compositor_model_bench.cc index 6c39981..3d788444 100644 --- a/gpu/tools/compositor_model_bench/compositor_model_bench.cc +++ b/gpu/tools/compositor_model_bench/compositor_model_bench.cc @@ -38,9 +38,7 @@ using base::TimeTicks; -using file_util::CloseFile; using base::DirectoryExists; -using file_util::OpenFile; using base::PathExists; using std::queue; using std::string; @@ -275,7 +273,7 @@ class Simulator { void DumpOutput() { LOG(INFO) << "Successfully ran " << sims_completed_.size() << " tests"; - FILE* f = OpenFile(output_path_, "w"); + FILE* f = base::OpenFile(output_path_, "w"); if (!f) { LOG(ERROR) << "Failed to open output file " << @@ -301,7 +299,7 @@ class Simulator { } fputs("\t]\n}", f); - CloseFile(f); + base::CloseFile(f); } bool UpdateTestStatus() { diff --git a/media/audio/android/audio_android_unittest.cc b/media/audio/android/audio_android_unittest.cc index 00d1f90..300e154 100644 --- a/media/audio/android/audio_android_unittest.cc +++ b/media/audio/android/audio_android_unittest.cc @@ -218,7 +218,7 @@ class FileAudioSink : public AudioInputStream::AudioInputCallback { base::FilePath file_path; EXPECT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &file_path)); file_path = file_path.AppendASCII(file_name.c_str()); - binary_file_ = file_util::OpenFile(file_path, "wb"); + binary_file_ = base::OpenFile(file_path, "wb"); DLOG_IF(ERROR, !binary_file_) << "Failed to open binary PCM data file."; VLOG(0) << "Writing to file: " << file_path.value().c_str(); } @@ -239,7 +239,7 @@ class FileAudioSink : public AudioInputStream::AudioInputCallback { buffer_->Seek(chunk_size); bytes_written += chunk_size; } - file_util::CloseFile(binary_file_); + base::CloseFile(binary_file_); } // AudioInputStream::AudioInputCallback implementation. diff --git a/media/audio/audio_low_latency_input_output_unittest.cc b/media/audio/audio_low_latency_input_output_unittest.cc index 55ff1ed..c0cfa69 100644 --- a/media/audio/audio_low_latency_input_output_unittest.cc +++ b/media/audio/audio_low_latency_input_output_unittest.cc @@ -162,7 +162,7 @@ class FullDuplexAudioSinkSource EXPECT_TRUE(PathService::Get(base::DIR_EXE, &file_name)); file_name = file_name.AppendASCII(kDelayValuesFileName); - FILE* text_file = file_util::OpenFile(file_name, "wt"); + FILE* text_file = base::OpenFile(file_name, "wt"); DLOG_IF(ERROR, !text_file) << "Failed to open log file."; VLOG(0) << ">> Output file " << file_name.value() << " has been created."; @@ -180,7 +180,7 @@ class FullDuplexAudioSinkSource ++elements_written; } - file_util::CloseFile(text_file); + base::CloseFile(text_file); } // AudioInputStream::AudioInputCallback. diff --git a/media/audio/win/audio_low_latency_input_win_unittest.cc b/media/audio/win/audio_low_latency_input_win_unittest.cc index b34c237..54bd3f7 100644 --- a/media/audio/win/audio_low_latency_input_win_unittest.cc +++ b/media/audio/win/audio_low_latency_input_win_unittest.cc @@ -100,7 +100,7 @@ class WriteToFileAudioSink : public AudioInputStream::AudioInputCallback { base::FilePath file_path; EXPECT_TRUE(PathService::Get(base::DIR_EXE, &file_path)); file_path = file_path.AppendASCII(file_name); - binary_file_ = file_util::OpenFile(file_path, "wb"); + binary_file_ = base::OpenFile(file_path, "wb"); DLOG_IF(ERROR, !binary_file_) << "Failed to open binary PCM data file."; VLOG(0) << ">> Output file: " << file_path.value() << " has been created."; } @@ -120,7 +120,7 @@ class WriteToFileAudioSink : public AudioInputStream::AudioInputCallback { buffer_.Seek(chunk_size); bytes_written += chunk_size; } - file_util::CloseFile(binary_file_); + base::CloseFile(binary_file_); } // AudioInputStream::AudioInputCallback implementation. diff --git a/media/audio/win/audio_low_latency_output_win_unittest.cc b/media/audio/win/audio_low_latency_output_win_unittest.cc index 26d71f2..5fda4b1 100644 --- a/media/audio/win/audio_low_latency_output_win_unittest.cc +++ b/media/audio/win/audio_low_latency_output_win_unittest.cc @@ -97,7 +97,7 @@ class ReadFromFileAudioSource : public AudioOutputStream::AudioSourceCallback { file_name = file_name.AppendASCII(kDeltaTimeMsFileName); EXPECT_TRUE(!text_file_); - text_file_ = file_util::OpenFile(file_name, "wt"); + text_file_ = base::OpenFile(file_name, "wt"); DLOG_IF(ERROR, !text_file_) << "Failed to open log file."; // Write the array which contains delta times to a text file. @@ -107,7 +107,7 @@ class ReadFromFileAudioSource : public AudioOutputStream::AudioSourceCallback { ++elements_written; } - file_util::CloseFile(text_file_); + base::CloseFile(text_file_); } // AudioOutputStream::AudioSourceCallback implementation. diff --git a/media/audio/win/audio_unified_win.cc b/media/audio/win/audio_unified_win.cc index 848678d..901c8b8 100644 --- a/media/audio/win/audio_unified_win.cc +++ b/media/audio/win/audio_unified_win.cc @@ -161,7 +161,7 @@ WASAPIUnifiedStream::~WASAPIUnifiedStream() { base::FilePath data_file_name; PathService::Get(base::DIR_EXE, &data_file_name); data_file_name = data_file_name.AppendASCII(kUnifiedAudioDebugFileName); - data_file_ = file_util::OpenFile(data_file_name, "wt"); + data_file_ = base::OpenFile(data_file_name, "wt"); DVLOG(1) << ">> Output file " << data_file_name.value() << " is created."; size_t n = 0; @@ -175,16 +175,16 @@ WASAPIUnifiedStream::~WASAPIUnifiedStream() { fifo_rate_comps_[n]); ++n; } - file_util::CloseFile(data_file_); + base::CloseFile(data_file_); base::FilePath param_file_name; PathService::Get(base::DIR_EXE, ¶m_file_name); param_file_name = param_file_name.AppendASCII(kUnifiedAudioParamsFileName); - param_file_ = file_util::OpenFile(param_file_name, "wt"); + param_file_ = base::OpenFile(param_file_name, "wt"); DVLOG(1) << ">> Output file " << param_file_name.value() << " is created."; fprintf(param_file_, "%d %d\n", input_params_[0], input_params_[1]); fprintf(param_file_, "%d %d\n", output_params_[0], output_params_[1]); - file_util::CloseFile(param_file_); + base::CloseFile(param_file_); #endif } diff --git a/media/audio/win/audio_unified_win_unittest.cc b/media/audio/win/audio_unified_win_unittest.cc index 6c36665..15573ae 100644 --- a/media/audio/win/audio_unified_win_unittest.cc +++ b/media/audio/win/audio_unified_win_unittest.cc @@ -74,7 +74,7 @@ class UnifiedSourceCallback : public AudioOutputStream::AudioSourceCallback { file_name = file_name.AppendASCII(kDeltaTimeMsFileName); EXPECT_TRUE(!text_file_); - text_file_ = file_util::OpenFile(file_name, "wt"); + text_file_ = base::OpenFile(file_name, "wt"); DLOG_IF(ERROR, !text_file_) << "Failed to open log file."; VLOG(0) << ">> Output file " << file_name.value() << " has been created."; @@ -84,7 +84,7 @@ class UnifiedSourceCallback : public AudioOutputStream::AudioSourceCallback { fprintf(text_file_, "%d\n", delta_times_[elements_written]); ++elements_written; } - file_util::CloseFile(text_file_); + base::CloseFile(text_file_); } virtual int OnMoreData(AudioBus* dest, diff --git a/media/base/container_names_unittest.cc b/media/base/container_names_unittest.cc index 0cd2c3c..c7d40d4 100644 --- a/media/base/container_names_unittest.cc +++ b/media/base/container_names_unittest.cc @@ -111,7 +111,7 @@ void TestFile(MediaContainerName expected, const base::FilePath& filename) { int64 actual_size; if (base::GetFileSize(filename, &actual_size) && actual_size < read_size) read_size = actual_size; - int read = file_util::ReadFile(filename, buffer, read_size); + int read = base::ReadFile(filename, buffer, read_size); // Now verify the type. EXPECT_EQ(expected, diff --git a/media/base/test_data_util.cc b/media/base/test_data_util.cc index b60bf77..386617e 100644 --- a/media/base/test_data_util.cc +++ b/media/base/test_data_util.cc @@ -37,7 +37,7 @@ scoped_refptr<DecoderBuffer> ReadTestDataFile(const std::string& name) { scoped_refptr<DecoderBuffer> buffer(new DecoderBuffer(file_size)); CHECK_EQ(file_size, - file_util::ReadFile( + base::ReadFile( file_path, reinterpret_cast<char*>(buffer->writable_data()), file_size)) << "Failed to read '" << name << "'"; diff --git a/media/base/yuv_convert_unittest.cc b/media/base/yuv_convert_unittest.cc index f1504ba..7c964f3 100644 --- a/media/base/yuv_convert_unittest.cc +++ b/media/base/yuv_convert_unittest.cc @@ -55,7 +55,7 @@ static void ReadData(const base::FilePath::CharType* filename, CHECK_EQ(actual_size, expected_size); // Verify bytes read are correct. - int bytes_read = file_util::ReadFile( + int bytes_read = base::ReadFile( path, reinterpret_cast<char*>(data->get()), expected_size); CHECK_EQ(bytes_read, expected_size); } @@ -371,9 +371,9 @@ TEST(YUVConvertTest, RGB32ToYUV) { .Append(FILE_PATH_LITERAL("data")) .Append(FILE_PATH_LITERAL("bali_640x360_P420.yuv")); EXPECT_EQ(static_cast<int>(kYUV12Size), - file_util::ReadFile(yuv_url, - reinterpret_cast<char*>(yuv_bytes.get()), - static_cast<int>(kYUV12Size))); + base::ReadFile(yuv_url, + reinterpret_cast<char*>(yuv_bytes.get()), + static_cast<int>(kYUV12Size))); // Convert a frame of YUV to 32 bit ARGB. media::ConvertYUVToRGB32(yuv_bytes.get(), @@ -451,9 +451,9 @@ TEST(YUVConvertTest, DownScaleYUVToRGB32WithRect) { const size_t size_of_yuv = kSourceYSize * 12 / 8; // 12 bpp. scoped_ptr<uint8[]> yuv_bytes(new uint8[size_of_yuv]); EXPECT_EQ(static_cast<int>(size_of_yuv), - file_util::ReadFile(yuv_url, - reinterpret_cast<char*>(yuv_bytes.get()), - static_cast<int>(size_of_yuv))); + base::ReadFile(yuv_url, + reinterpret_cast<char*>(yuv_bytes.get()), + static_cast<int>(size_of_yuv))); // Scale the full frame of YUV to 32 bit ARGB. // The API currently only supports down-scaling, so we don't test up-scaling. diff --git a/media/webm/chromeos/webm_encoder.cc b/media/webm/chromeos/webm_encoder.cc index da1f176..059f9c6f 100644 --- a/media/webm/chromeos/webm_encoder.cc +++ b/media/webm/chromeos/webm_encoder.cc @@ -157,7 +157,7 @@ bool WebmEncoder::EncodeFromSprite(const SkBitmap& sprite, } bool WebmEncoder::WriteWebmHeader() { - output_ = file_util::OpenFile(output_path_, "wb"); + output_ = base::OpenFile(output_path_, "wb"); if (!output_) return false; @@ -251,7 +251,7 @@ bool WebmEncoder::WriteWebmFooter() { EndSubElement(); // Cluster EndSubElement(); // Segment DCHECK(ebml_sub_elements_.empty()); - return file_util::CloseFile(output_) && !has_errors_; + return base::CloseFile(output_) && !has_errors_; } void WebmEncoder::StartSubElement(unsigned long class_id) { diff --git a/net/android/keystore_unittest.cc b/net/android/keystore_unittest.cc index 98944e2..58e3da7 100644 --- a/net/android/keystore_unittest.cc +++ b/net/android/keystore_unittest.cc @@ -117,8 +117,7 @@ EVP_PKEY* ImportPrivateKeyFile(const char* filename) { // Load file in memory. base::FilePath certs_dir = GetTestCertsDirectory(); base::FilePath file_path = certs_dir.AppendASCII(filename); - ScopedStdioHandle handle( - file_util::OpenFile(file_path, "rb")); + ScopedStdioHandle handle(base::OpenFile(file_path, "rb")); if (!handle.get()) { LOG(ERROR) << "Could not open private key file: " << filename; return NULL; @@ -167,7 +166,7 @@ EVP_PKEY* ImportPublicKeyFile(const char* filename) { // Load file as PEM data. base::FilePath certs_dir = GetTestCertsDirectory(); base::FilePath file_path = certs_dir.AppendASCII(filename); - ScopedStdioHandle handle(file_util::OpenFile(file_path, "rb")); + ScopedStdioHandle handle(base::OpenFile(file_path, "rb")); if (!handle.get()) { LOG(ERROR) << "Could not open public key file: " << filename; return NULL; diff --git a/net/base/file_stream_unittest.cc b/net/base/file_stream_unittest.cc index 6f35985..b055c78 100644 --- a/net/base/file_stream_unittest.cc +++ b/net/base/file_stream_unittest.cc @@ -200,7 +200,7 @@ TEST_F(FileStreamTest, UseFileHandle) { // Read into buffer and compare to make sure the handle worked fine. ASSERT_EQ(kTestDataSize, - file_util::ReadFile(temp_file_path(), buffer, kTestDataSize)); + base::ReadFile(temp_file_path(), buffer, kTestDataSize)); ASSERT_EQ(0, memcmp(kTestData, buffer, kTestDataSize)); } diff --git a/net/base/net_log_logger_unittest.cc b/net/base/net_log_logger_unittest.cc index 3dd6915..05c16c7 100644 --- a/net/base/net_log_logger_unittest.cc +++ b/net/base/net_log_logger_unittest.cc @@ -28,7 +28,7 @@ class NetLogLoggerTest : public testing::Test { TEST_F(NetLogLoggerTest, GeneratesValidJSONForNoEvents) { { // Create and destroy a logger. - FILE* file = file_util::OpenFile(log_path_, "w"); + FILE* file = base::OpenFile(log_path_, "w"); ASSERT_TRUE(file); scoped_ptr<base::Value> constants(NetLogLogger::GetConstants()); NetLogLogger logger(file, *constants); @@ -50,7 +50,7 @@ TEST_F(NetLogLoggerTest, GeneratesValidJSONForNoEvents) { TEST_F(NetLogLoggerTest, GeneratesValidJSONWithOneEvent) { { - FILE* file = file_util::OpenFile(log_path_, "w"); + FILE* file = base::OpenFile(log_path_, "w"); ASSERT_TRUE(file); scoped_ptr<base::Value> constants(NetLogLogger::GetConstants()); NetLogLogger logger(file, *constants); @@ -82,7 +82,7 @@ TEST_F(NetLogLoggerTest, GeneratesValidJSONWithOneEvent) { TEST_F(NetLogLoggerTest, GeneratesValidJSONWithMultipleEvents) { { - FILE* file = file_util::OpenFile(log_path_, "w"); + FILE* file = base::OpenFile(log_path_, "w"); ASSERT_TRUE(file); scoped_ptr<base::Value> constants(NetLogLogger::GetConstants()); NetLogLogger logger(file, *constants); diff --git a/net/disk_cache/backend_unittest.cc b/net/disk_cache/backend_unittest.cc index c7b37e4..b25001f 100644 --- a/net/disk_cache/backend_unittest.cc +++ b/net/disk_cache/backend_unittest.cc @@ -489,7 +489,7 @@ TEST_F(DiskCacheBackendTest, ExternalFiles) { // And verify that the first file is still there. scoped_refptr<net::IOBuffer> buffer2(new net::IOBuffer(kSize)); - ASSERT_EQ(kSize, file_util::ReadFile(filename, buffer2->data(), kSize)); + ASSERT_EQ(kSize, base::ReadFile(filename, buffer2->data(), kSize)); EXPECT_EQ(0, memcmp(buffer1->data(), buffer2->data(), kSize)); } diff --git a/net/disk_cache/cache_util_unittest.cc b/net/disk_cache/cache_util_unittest.cc index b86290f..3a05196 100644 --- a/net/disk_cache/cache_util_unittest.cc +++ b/net/disk_cache/cache_util_unittest.cc @@ -21,16 +21,16 @@ class CacheUtilTest : public PlatformTest { dir1_ = base::FilePath(cache_dir_.Append(FILE_PATH_LITERAL("dir01"))); file3_ = base::FilePath(dir1_.Append(FILE_PATH_LITERAL("file03"))); ASSERT_TRUE(base::CreateDirectory(cache_dir_)); - FILE *fp = file_util::OpenFile(file1_, "w"); + FILE *fp = base::OpenFile(file1_, "w"); ASSERT_TRUE(fp != NULL); - file_util::CloseFile(fp); - fp = file_util::OpenFile(file2_, "w"); + base::CloseFile(fp); + fp = base::OpenFile(file2_, "w"); ASSERT_TRUE(fp != NULL); - file_util::CloseFile(fp); + base::CloseFile(fp); ASSERT_TRUE(base::CreateDirectory(dir1_)); - fp = file_util::OpenFile(file3_, "w"); + fp = base::OpenFile(file3_, "w"); ASSERT_TRUE(fp != NULL); - file_util::CloseFile(fp); + base::CloseFile(fp); dest_dir_ = tmp_dir_.path().Append(FILE_PATH_LITERAL("old_Cache_001")); dest_file1_ = base::FilePath(dest_dir_.Append(FILE_PATH_LITERAL("file01"))); dest_file2_ = diff --git a/net/proxy/proxy_config_service_linux.cc b/net/proxy/proxy_config_service_linux.cc index c39dd87..d01e5e6 100644 --- a/net/proxy/proxy_config_service_linux.cc +++ b/net/proxy/proxy_config_service_linux.cc @@ -1171,7 +1171,7 @@ class SettingGetterImplKDE : public ProxyConfigServiceLinux::SettingGetter, // each relevant name-value pair to the appropriate value table. void UpdateCachedSettings() { base::FilePath kioslaverc = kde_config_dir_.Append("kioslaverc"); - file_util::ScopedFILE input(file_util::OpenFile(kioslaverc, "r")); + file_util::ScopedFILE input(base::OpenFile(kioslaverc, "r")); if (!input.get()) return; ResetCachedSettings(); diff --git a/net/tools/dump_cache/cache_dumper.cc b/net/tools/dump_cache/cache_dumper.cc index ad9a79c..7d29a5c 100644 --- a/net/tools/dump_cache/cache_dumper.cc +++ b/net/tools/dump_cache/cache_dumper.cc @@ -108,7 +108,7 @@ int DiskDumper::CreateEntry(const std::string& key, wprintf(L"CreateFileW (%s) failed: %d\n", file.c_str(), GetLastError()); return (entry_ != INVALID_HANDLE_VALUE) ? net::OK : net::ERR_FAILED; #else - entry_ = file_util::OpenFile(entry_path_, "w+"); + entry_ = base::OpenFile(entry_path_, "w+"); return (entry_ != NULL) ? net::OK : net::ERR_FAILED; #endif } @@ -218,6 +218,6 @@ void DiskDumper::CloseEntry(disk_cache::Entry* entry, base::Time last_used, #ifdef WIN32_LARGE_FILENAME_SUPPORT CloseHandle(entry_); #else - file_util::CloseFile(entry_); + base::CloseFile(entry_); #endif } diff --git a/net/url_request/url_request_unittest.cc b/net/url_request/url_request_unittest.cc index 79e7967..116808c 100644 --- a/net/url_request/url_request_unittest.cc +++ b/net/url_request/url_request_unittest.cc @@ -4726,7 +4726,7 @@ TEST_F(URLRequestTestHTTP, PostFileTest) { ASSERT_EQ(true, base::GetFileSize(path, &size)); scoped_ptr<char[]> buf(new char[size]); - ASSERT_EQ(size, file_util::ReadFile(path, buf.get(), size)); + ASSERT_EQ(size, base::ReadFile(path, buf.get(), size)); ASSERT_EQ(1, d.response_started_count()) << "request failed: " << r.status().status() diff --git a/skia/ext/vector_canvas_unittest.cc b/skia/ext/vector_canvas_unittest.cc index b8fbfba..b7e9105 100644 --- a/skia/ext/vector_canvas_unittest.cc +++ b/skia/ext/vector_canvas_unittest.cc @@ -135,11 +135,11 @@ class Image { std::vector<gfx::PNGCodec::Comment>(), &compressed)); ASSERT_TRUE(compressed.size()); - FILE* f = file_util::OpenFile(filename, "wb"); + FILE* f = base::OpenFile(filename, "wb"); ASSERT_TRUE(f); ASSERT_EQ(fwrite(&*compressed.begin(), 1, compressed.size(), f), compressed.size()); - file_util::CloseFile(f); + base::CloseFile(f); } // Returns the percentage of the image that is different from the other, diff --git a/sql/connection_unittest.cc b/sql/connection_unittest.cc index c6811b4..5aa7a9b 100644 --- a/sql/connection_unittest.cc +++ b/sql/connection_unittest.cc @@ -423,10 +423,10 @@ TEST_F(SQLConnectionTest, RazeEmptyDB) { db().Close(); { - file_util::ScopedFILE file(file_util::OpenFile(db_path(), "rb+")); + file_util::ScopedFILE file(base::OpenFile(db_path(), "rb+")); ASSERT_TRUE(file.get() != NULL); ASSERT_EQ(0, fseek(file.get(), 0, SEEK_SET)); - ASSERT_TRUE(file_util::TruncateFile(file.get())); + ASSERT_TRUE(base::TruncateFile(file.get())); } ASSERT_TRUE(db().Open(db_path())); @@ -441,7 +441,7 @@ TEST_F(SQLConnectionTest, RazeNOTADB) { ASSERT_FALSE(base::PathExists(db_path())); { - file_util::ScopedFILE file(file_util::OpenFile(db_path(), "wb")); + file_util::ScopedFILE file(base::OpenFile(db_path(), "wb")); ASSERT_TRUE(file.get() != NULL); const char* kJunk = "This is the hour of our discontent."; @@ -474,7 +474,7 @@ TEST_F(SQLConnectionTest, RazeNOTADB2) { db().Close(); { - file_util::ScopedFILE file(file_util::OpenFile(db_path(), "rb+")); + file_util::ScopedFILE file(base::OpenFile(db_path(), "rb+")); ASSERT_TRUE(file.get() != NULL); ASSERT_EQ(0, fseek(file.get(), 0, SEEK_SET)); diff --git a/sql/test/test_helpers.cc b/sql/test/test_helpers.cc index 8d13d01..8d56140 100644 --- a/sql/test/test_helpers.cc +++ b/sql/test/test_helpers.cc @@ -75,7 +75,7 @@ bool CorruptSizeInHeader(const base::FilePath& db_path) { unsigned char header[kHeaderSize]; - file_util::ScopedFILE file(file_util::OpenFile(db_path, "rb+")); + file_util::ScopedFILE file(base::OpenFile(db_path, "rb+")); if (!file.get()) return false; diff --git a/tools/imagediff/image_diff.cc b/tools/imagediff/image_diff.cc index 27acf76..604f27e 100644 --- a/tools/imagediff/image_diff.cc +++ b/tools/imagediff/image_diff.cc @@ -96,7 +96,7 @@ class Image { // Creates the image from the given filename on disk, and returns true on // success. bool CreateFromFilename(const base::FilePath& path) { - FILE* f = file_util::OpenFile(path, "rb"); + FILE* f = base::OpenFile(path, "rb"); if (!f) return false; @@ -108,7 +108,7 @@ class Image { compressed.insert(compressed.end(), buf, buf + num_read); } - file_util::CloseFile(f); + base::CloseFile(f); if (!image_diff_png::DecodePNG(&compressed[0], compressed.size(), &data_, &w_, &h_)) { diff --git a/ui/base/resource/data_pack.cc b/ui/base/resource/data_pack.cc index 54694d9..8f8f182 100644 --- a/ui/base/resource/data_pack.cc +++ b/ui/base/resource/data_pack.cc @@ -216,13 +216,13 @@ ui::ScaleFactor DataPack::GetScaleFactor() const { bool DataPack::WritePack(const base::FilePath& path, const std::map<uint16, base::StringPiece>& resources, TextEncodingType textEncodingType) { - FILE* file = file_util::OpenFile(path, "wb"); + FILE* file = base::OpenFile(path, "wb"); if (!file) return false; if (fwrite(&kFileFormatVersion, sizeof(kFileFormatVersion), 1, file) != 1) { LOG(ERROR) << "Failed to write file version"; - file_util::CloseFile(file); + base::CloseFile(file); return false; } @@ -231,7 +231,7 @@ bool DataPack::WritePack(const base::FilePath& path, uint32 entry_count = resources.size(); if (fwrite(&entry_count, sizeof(entry_count), 1, file) != 1) { LOG(ERROR) << "Failed to write entry count"; - file_util::CloseFile(file); + base::CloseFile(file); return false; } @@ -239,14 +239,14 @@ bool DataPack::WritePack(const base::FilePath& path, textEncodingType != BINARY) { LOG(ERROR) << "Invalid text encoding type, got " << textEncodingType << ", expected between " << BINARY << " and " << UTF16; - file_util::CloseFile(file); + base::CloseFile(file); return false; } uint8 write_buffer = textEncodingType; if (fwrite(&write_buffer, sizeof(uint8), 1, file) != 1) { LOG(ERROR) << "Failed to write file text resources encoding"; - file_util::CloseFile(file); + base::CloseFile(file); return false; } @@ -260,13 +260,13 @@ bool DataPack::WritePack(const base::FilePath& path, uint16 resource_id = it->first; if (fwrite(&resource_id, sizeof(resource_id), 1, file) != 1) { LOG(ERROR) << "Failed to write id for " << resource_id; - file_util::CloseFile(file); + base::CloseFile(file); return false; } if (fwrite(&data_offset, sizeof(data_offset), 1, file) != 1) { LOG(ERROR) << "Failed to write offset for " << resource_id; - file_util::CloseFile(file); + base::CloseFile(file); return false; } @@ -278,13 +278,13 @@ bool DataPack::WritePack(const base::FilePath& path, uint16 resource_id = 0; if (fwrite(&resource_id, sizeof(resource_id), 1, file) != 1) { LOG(ERROR) << "Failed to write extra resource id."; - file_util::CloseFile(file); + base::CloseFile(file); return false; } if (fwrite(&data_offset, sizeof(data_offset), 1, file) != 1) { LOG(ERROR) << "Failed to write extra offset."; - file_util::CloseFile(file); + base::CloseFile(file); return false; } @@ -293,12 +293,12 @@ bool DataPack::WritePack(const base::FilePath& path, it != resources.end(); ++it) { if (fwrite(it->second.data(), it->second.length(), 1, file) != 1) { LOG(ERROR) << "Failed to write data for " << it->first; - file_util::CloseFile(file); + base::CloseFile(file); return false; } } - file_util::CloseFile(file); + base::CloseFile(file); return true; } |