diff options
author | dkegel@google.com <dkegel@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-04 21:00:46 +0000 |
---|---|---|
committer | dkegel@google.com <dkegel@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-04 21:00:46 +0000 |
commit | eac0709a26a824381291cbf78440c969a846b1ab (patch) | |
tree | 98255561598331f85ab1e519c2fba40c16da67e6 /base | |
parent | 379979b98bbc0af3e1f3eebacda613c771b2d104 (diff) | |
download | chromium_src-eac0709a26a824381291cbf78440c969a846b1ab.zip chromium_src-eac0709a26a824381291cbf78440c969a846b1ab.tar.gz chromium_src-eac0709a26a824381291cbf78440c969a846b1ab.tar.bz2 |
Port more of url_request_unittest.cc.
Also do a little bit of the FilePath rewrite as it pertains to this test.
Review URL: http://codereview.chromium.org/9074
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4652 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/file_util.cc | 8 | ||||
-rw-r--r-- | base/file_util.h | 5 | ||||
-rw-r--r-- | base/file_util_posix.cc | 4 | ||||
-rw-r--r-- | base/file_util_win.cc | 4 |
4 files changed, 16 insertions, 5 deletions
diff --git a/base/file_util.cc b/base/file_util.cc index dd00d00..f4d0504 100644 --- a/base/file_util.cc +++ b/base/file_util.cc @@ -289,7 +289,7 @@ bool ReadFileToString(const std::wstring& path, std::string* contents) { return true; } -bool GetFileSize(const std::wstring& file_path, int64* file_size) { +bool GetFileSize(const FilePath& file_path, int64* file_size) { FileInfo info; if (!GetFileInfo(file_path, &info)) return false; @@ -350,6 +350,12 @@ bool GetCurrentDirectory(std::wstring* path_str) { *path_str = path.ToWStringHack(); return true; } +bool GetFileInfo(const std::wstring& file_path, FileInfo* results) { + return GetFileInfo(FilePath::FromWStringHack(file_path), results); +} +bool GetFileSize(const std::wstring& file_path, int64* file_size) { + return GetFileSize(FilePath::FromWStringHack(file_path), file_size); +} bool GetTempDir(std::wstring* path_str) { FilePath path; if (!GetTempDir(&path)) diff --git a/base/file_util.h b/base/file_util.h index 127afd0..2318ec7 100644 --- a/base/file_util.h +++ b/base/file_util.h @@ -267,6 +267,8 @@ bool CreateDirectory(const FilePath& full_path); bool CreateDirectory(const std::wstring& full_path); // Returns the file size. Returns true on success. +bool GetFileSize(const FilePath& file_path, int64* file_size); +// Deprecated temporary compatibility function. bool GetFileSize(const std::wstring& file_path, int64* file_size); // Used to hold information about a given file path. See GetFileInfo below. @@ -281,8 +283,11 @@ struct FileInfo { }; // Returns information about the given file path. +bool GetFileInfo(const FilePath& file_path, FileInfo* info); +// Deprecated temporary compatibility function. bool GetFileInfo(const std::wstring& file_path, FileInfo* info); + // Wrapper for fopen-like calls. Returns non-NULL FILE* on success. FILE* OpenFile(const FilePath& filename, const char* mode); // Deprecated temporary compatibility functions. diff --git a/base/file_util_posix.cc b/base/file_util_posix.cc index d48ae2a..fd012b4 100644 --- a/base/file_util_posix.cc +++ b/base/file_util_posix.cc @@ -311,9 +311,9 @@ bool CreateDirectory(const FilePath& full_path) { return true; } -bool GetFileInfo(const std::wstring& file_path, FileInfo* results) { +bool GetFileInfo(const FilePath& file_path, FileInfo* results) { struct stat64 file_info; - if (stat64(WideToUTF8(file_path).c_str(), &file_info) != 0) + if (stat64(file_path.value().c_str(), &file_info) != 0) return false; results->is_directory = S_ISDIR(file_info.st_mode); results->size = file_info.st_size; diff --git a/base/file_util_win.cc b/base/file_util_win.cc index 2a08f55..661d3f6 100644 --- a/base/file_util_win.cc +++ b/base/file_util_win.cc @@ -456,9 +456,9 @@ bool CreateDirectory(const FilePath& full_path) { return err == ERROR_SUCCESS; } -bool GetFileInfo(const std::wstring& file_path, FileInfo* results) { +bool GetFileInfo(const FilePath& file_path, FileInfo* results) { WIN32_FILE_ATTRIBUTE_DATA attr; - if (!GetFileAttributesEx(file_path.c_str(), GetFileExInfoStandard, &attr)) + if (!GetFileAttributesEx(file_path.ToWstringHack().c_str(), GetFileExInfoStandard, &attr)) return false; ULARGE_INTEGER size; |