diff options
author | erikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-23 20:20:10 +0000 |
---|---|---|
committer | erikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-23 20:20:10 +0000 |
commit | 7e1fde6a79fbc323f22a132dba6777dcd3464218 (patch) | |
tree | f644dd3ef1d3107bffda58c4da2fa2c331aa5e2e /base/file_util_win.cc | |
parent | fe5956cb0e0529312c57603b41d4894c82c27b23 (diff) | |
download | chromium_src-7e1fde6a79fbc323f22a132dba6777dcd3464218.zip chromium_src-7e1fde6a79fbc323f22a132dba6777dcd3464218.tar.gz chromium_src-7e1fde6a79fbc323f22a132dba6777dcd3464218.tar.bz2 |
file_util minor cleanup:
* add POSIX version of IsPathWritable
* convert IsPathWritable to FilePath
* convert CreateNewTempDirectory to FilePath
* fix a bug where recursive delete errors weren't being handled in POSIX
Review URL: http://codereview.chromium.org/16241
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7430 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 8f372b1..c2dbf0a 100644 --- a/base/file_util_win.cc +++ b/base/file_util_win.cc @@ -168,9 +168,9 @@ bool PathExists(const FilePath& path) { return (GetFileAttributes(path.value().c_str()) != INVALID_FILE_ATTRIBUTES); } -bool PathIsWritable(const std::wstring& path) { +bool PathIsWritable(const FilePath& path) { HANDLE dir = - CreateFile(path.c_str(), FILE_ADD_FILE, + CreateFile(path.value().c_str(), FILE_ADD_FILE, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); @@ -421,26 +421,26 @@ bool CreateTemporaryFileNameInDir(const std::wstring& dir, return true; } -bool CreateNewTempDirectory(const std::wstring& prefix, - std::wstring* new_temp_path) { - std::wstring system_temp_dir; +bool CreateNewTempDirectory(const FilePath::StringType& prefix, + FilePath* new_temp_path) { + FilePath system_temp_dir; if (!GetTempDir(&system_temp_dir)) return false; - std::wstring path_to_create; + FilePath path_to_create; srand(static_cast<uint32>(time(NULL))); int count = 0; while (count < 50) { // Try create a new temporary directory with random generated name. If // the one exists, keep trying another path name until we reach some limit. - path_to_create.assign(system_temp_dir); + path_to_create = system_temp_dir; std::wstring new_dir_name; new_dir_name.assign(prefix); new_dir_name.append(IntToWString(rand() % kint16max)); - file_util::AppendToPath(&path_to_create, new_dir_name); + path_to_create = path_to_create.Append(new_dir_name); - if (::CreateDirectory(path_to_create.c_str(), NULL)) + if (::CreateDirectory(path_to_create.value().c_str(), NULL)) break; count++; } @@ -449,7 +449,7 @@ bool CreateNewTempDirectory(const std::wstring& prefix, return false; } - new_temp_path->assign(path_to_create); + *new_temp_path = path_to_create; return true; } |