Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3849)

Unified Diff: base/file_util_win.cc

Issue 16241: file_util minor cleanup:... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/file_util_posix.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/file_util_win.cc
===================================================================
--- base/file_util_win.cc (revision 7416)
+++ base/file_util_win.cc (working copy)
@@ -168,9 +168,9 @@
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 @@
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 @@
return false;
}
- new_temp_path->assign(path_to_create);
+ *new_temp_path = path_to_create;
return true;
}
« no previous file with comments | « base/file_util_posix.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698