diff options
author | darin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-26 01:04:08 +0000 |
---|---|---|
committer | darin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-26 01:04:08 +0000 |
commit | f5e3da4d564980a048f375cf1a824a01df03382a (patch) | |
tree | 68a0562ee30146d65071d722744503d47255dec4 /base/file_util_win.cc | |
parent | ec9207d3a86ed6ccbefc56d95034897f48f52674 (diff) | |
download | chromium_src-f5e3da4d564980a048f375cf1a824a01df03382a.zip chromium_src-f5e3da4d564980a048f375cf1a824a01df03382a.tar.gz chromium_src-f5e3da4d564980a048f375cf1a824a01df03382a.tar.bz2 |
Add file_util::GetFileInfo as a means to provide more information about a file
path. This CL changes GetFileSize to be implemented in terms of GetFileInfo
since under the hood on all platforms the same system call is used.
R=mark
Review URL: http://codereview.chromium.org/4286
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2624 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/file_util_win.cc')
-rw-r--r-- | base/file_util_win.cc | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/base/file_util_win.cc b/base/file_util_win.cc index 168e26e..6a89b3f 100644 --- a/base/file_util_win.cc +++ b/base/file_util_win.cc @@ -432,18 +432,18 @@ bool CreateDirectory(const std::wstring& full_path) { return err == ERROR_SUCCESS; } -bool GetFileSize(const std::wstring& file_path, int64* file_size) { - ScopedHandle file_handle( - CreateFile(file_path.c_str(), GENERIC_READ, - FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, - OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)); - - LARGE_INTEGER win32_file_size = {0}; - if (!GetFileSizeEx(file_handle, &win32_file_size)) { +bool GetFileInfo(const std::wstring& file_path, FileInfo* results) { + WIN32_FILE_ATTRIBUTE_DATA attr; + if (!GetFileAttributesEx(file_path.c_str(), GetFileExInfoStandard, &attr)) return false; - } - *file_size = win32_file_size.QuadPart; + ULARGE_INTEGER size; + size.HighPart = attr.nFileSizeHigh; + size.LowPart = attr.nFileSizeLow; + results->size = size.QuadPart; + + results->is_directory = + (attr.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0; return true; } |