diff options
author | skerner@chromium.org <skerner@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-30 17:00:09 +0000 |
---|---|---|
committer | skerner@chromium.org <skerner@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-30 17:00:09 +0000 |
commit | b0b3abd98a59384a83349c83a5ef9b14851816da (patch) | |
tree | 790628087c773280456dffae7cfb0ea8f744649f /base/file_util_win.cc | |
parent | ec2717e405abc8f618133fe3c9f5051fff224e71 (diff) | |
download | chromium_src-b0b3abd98a59384a83349c83a5ef9b14851816da.zip chromium_src-b0b3abd98a59384a83349c83a5ef9b14851816da.tar.gz chromium_src-b0b3abd98a59384a83349c83a5ef9b14851816da.tar.bz2 |
Unpack extensions inside chrome's profile directory.
Other users of the temp directory will be altered in a subsequent CL.
BUG=13044
TEST=SandboxedExtensionUnpackerTest.*, ScopedTempDir.UniqueTempDirUnderPath, FileUtilTest.CreateNewTempDirInDirTest, manual testing on win, linux, mac.
Review URL: http://codereview.chromium.org/1582022
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@46078 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/file_util_win.cc')
-rw-r--r-- | base/file_util_win.cc | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/base/file_util_win.cc b/base/file_util_win.cc index d1cdc6c..445f82e 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(); |