diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-11 00:01:38 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-11 00:01:38 +0000 |
commit | 392264c76c724e3c31273ad1aa932a041cc12a7e (patch) | |
tree | fca9dca526bda74fa05a791b179e35e86e5c9755 /base/file_util_posix.cc | |
parent | 27961c57893201b2914f173cb517e33f37d0ae58 (diff) | |
download | chromium_src-392264c76c724e3c31273ad1aa932a041cc12a7e.zip chromium_src-392264c76c724e3c31273ad1aa932a041cc12a7e.tar.gz chromium_src-392264c76c724e3c31273ad1aa932a041cc12a7e.tar.bz2 |
Added CreateTemporaryFileName that takes a FilePath argument.
Review URL: http://codereview.chromium.org/9752
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5142 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/file_util_posix.cc')
-rw-r--r-- | base/file_util_posix.cc | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/base/file_util_posix.cc b/base/file_util_posix.cc index fd012b4..a0c6cb6 100644 --- a/base/file_util_posix.cc +++ b/base/file_util_posix.cc @@ -24,7 +24,7 @@ namespace file_util { -static const wchar_t* kTempFileName = L"com.google.chrome.XXXXXX"; +static const char* kTempFileName = "com.google.chrome.XXXXXX"; std::wstring GetDirectoryFromPath(const std::wstring& path) { if (EndsWithSeparator(path)) { @@ -249,19 +249,20 @@ bool GetFileCreationLocalTime(const std::string& filename, } #endif -bool CreateTemporaryFileName(std::wstring* temp_file) { - std::wstring tmpdir; - if (!GetTempDir(&tmpdir)) +bool CreateTemporaryFileName(FilePath* path) { + if (!GetTempDir(path)) return false; - AppendToPath(&tmpdir, kTempFileName); - std::string tmpdir_string = WideToUTF8(tmpdir); + + *path = path->Append(kTempFileName); + std::string tmpdir_string = path->value(); // this should be OK since mkstemp just replaces characters in place char* buffer = const_cast<char*>(tmpdir_string.c_str()); + int fd = mkstemp(buffer); if (fd < 0) return false; - *temp_file = UTF8ToWide(buffer); - close(fd); + + close(fd); return true; } @@ -274,11 +275,11 @@ bool CreateTemporaryFileNameInDir(const std::wstring& dir, bool CreateNewTempDirectory(const std::wstring& prefix, std::wstring* new_temp_path) { - std::wstring tmpdir; + FilePath tmpdir; if (!GetTempDir(&tmpdir)) return false; - AppendToPath(&tmpdir, kTempFileName); - std::string tmpdir_string = WideToUTF8(tmpdir); + tmpdir = tmpdir.Append(kTempFileName); + std::string tmpdir_string = tmpdir.value(); // this should be OK since mkdtemp just replaces characters in place char* buffer = const_cast<char*>(tmpdir_string.c_str()); char* dtemp = mkdtemp(buffer); |