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

Unified Diff: base/file_util_win.cc

Issue 1582022: Unpack extensions inside chrome's directory. (Closed)
Patch Set: Final rebase. Created 10 years, 8 months 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_unittest.cc ('k') | base/scoped_temp_dir.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/file_util_win.cc
diff --git a/base/file_util_win.cc b/base/file_util_win.cc
index d1cdc6cee4bf68ac9b00671a46ce0f3766ba7b7c..445f82e17e28f9eddd404716eb0e3e3dd6f5f5e8 100644
--- a/base/file_util_win.cc
+++ b/base/file_util_win.cc
@@ -500,12 +500,9 @@ bool CreateTemporaryFileInDir(const FilePath& dir,
return true;
}
-bool CreateNewTempDirectory(const FilePath::StringType& prefix,
- FilePath* new_temp_path) {
- FilePath system_temp_dir;
- if (!GetTempDir(&system_temp_dir))
- return false;
-
+bool CreateTemporaryDirInDir(const FilePath& base_dir,
+ const FilePath::StringType& prefix,
+ FilePath* new_dir) {
FilePath path_to_create;
srand(static_cast<uint32>(time(NULL)));
@@ -513,12 +510,13 @@ bool CreateNewTempDirectory(const FilePath::StringType& prefix,
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 = system_temp_dir;
+ path_to_create = base_dir;
+
std::wstring new_dir_name;
new_dir_name.assign(prefix);
new_dir_name.append(IntToWString(rand() % kint16max));
- path_to_create = path_to_create.Append(new_dir_name);
+ path_to_create = path_to_create.Append(new_dir_name);
if (::CreateDirectory(path_to_create.value().c_str(), NULL))
break;
count++;
@@ -528,10 +526,19 @@ bool CreateNewTempDirectory(const FilePath::StringType& prefix,
return false;
}
- *new_temp_path = path_to_create;
+ *new_dir = path_to_create;
return true;
}
+bool CreateNewTempDirectory(const FilePath::StringType& prefix,
+ FilePath* new_temp_path) {
+ FilePath system_temp_dir;
+ if (!GetTempDir(&system_temp_dir))
+ return false;
+
+ return CreateTemporaryDirInDir(system_temp_dir, prefix, new_temp_path);
+}
+
bool CreateDirectory(const FilePath& full_path) {
// If the path exists, we've succeeded if it's a directory, failed otherwise.
const wchar_t* full_path_str = full_path.value().c_str();
« no previous file with comments | « base/file_util_unittest.cc ('k') | base/scoped_temp_dir.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698