diff options
Diffstat (limited to 'chromium/base/file_util.cc')
-rw-r--r-- | chromium/base/file_util.cc | 54 |
1 files changed, 21 insertions, 33 deletions
diff --git a/chromium/base/file_util.cc b/chromium/base/file_util.cc index e9806763855..1575a079d6b 100644 --- a/chromium/base/file_util.cc +++ b/chromium/base/file_util.cc @@ -23,8 +23,6 @@ namespace base { namespace { -const FilePath::CharType kExtensionSeparator = FILE_PATH_LITERAL('.'); - // The maximum number of 'uniquified' files we will try to create. // This is used when the filename we're trying to download is already in use, // so we create a new unique filename by appending " (nnn)" before the @@ -34,8 +32,6 @@ static const int kMaxUniqueFiles = 100; } // namespace -bool g_bug108724_debug = false; - int64 ComputeDirectorySize(const FilePath& root_path) { int64 running_size = 0; FileEnumerator file_iter(root_path, true, FileEnumerator::FILES); @@ -133,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; } @@ -144,22 +140,11 @@ bool ReadFileToString(const FilePath& path, std::string* contents) { if (contents) contents->append(buf, len); } - file_util::CloseFile(file); + CloseFile(file); return true; } -} // namespace base - -// ----------------------------------------------------------------------------- - -namespace file_util { - -using base::FileEnumerator; -using base::FilePath; -using base::kExtensionSeparator; -using base::kMaxUniqueFiles; - bool IsDirectoryEmpty(const FilePath& dir_path) { FileEnumerator files(dir_path, false, FileEnumerator::FILES | FileEnumerator::DIRECTORIES); @@ -176,12 +161,12 @@ FILE* CreateAndOpenTemporaryFile(FilePath* path) { return CreateAndOpenTemporaryFileInDir(directory, path); } -bool CreateDirectory(const base::FilePath& full_path) { +bool CreateDirectory(const FilePath& full_path) { return CreateDirectoryAndGetError(full_path, NULL); } bool GetFileSize(const FilePath& file_path, int64* file_size) { - base::PlatformFileInfo info; + PlatformFileInfo info; if (!GetFileInfo(file_path, &info)) return false; *file_size = info.size; @@ -189,32 +174,26 @@ bool GetFileSize(const FilePath& file_path, int64* file_size) { } bool TouchFile(const FilePath& path, - const base::Time& last_accessed, - const base::Time& last_modified) { - int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_WRITE_ATTRIBUTES; + const Time& last_accessed, + const Time& last_modified) { + int flags = PLATFORM_FILE_OPEN | PLATFORM_FILE_WRITE_ATTRIBUTES; #if defined(OS_WIN) // On Windows, FILE_FLAG_BACKUP_SEMANTICS is needed to open a directory. if (DirectoryExists(path)) - flags |= base::PLATFORM_FILE_BACKUP_SEMANTICS; + flags |= PLATFORM_FILE_BACKUP_SEMANTICS; #endif // OS_WIN - const base::PlatformFile file = - base::CreatePlatformFile(path, flags, NULL, NULL); - if (file != base::kInvalidPlatformFileValue) { - bool result = base::TouchPlatformFile(file, last_accessed, last_modified); - base::ClosePlatformFile(file); + const PlatformFile file = CreatePlatformFile(path, flags, NULL, NULL); + if (file != kInvalidPlatformFileValue) { + bool result = TouchPlatformFile(file, last_accessed, last_modified); + ClosePlatformFile(file); return result; } return false; } -bool SetLastModifiedTime(const FilePath& path, - const base::Time& last_modified) { - return TouchFile(path, last_modified, last_modified); -} - bool CloseFile(FILE* file) { if (file == NULL) return true; @@ -239,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) { |