summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorerikkay@chromium.org <erikkay@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-18 16:07:55 +0000
committererikkay@chromium.org <erikkay@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-18 16:07:55 +0000
commit33edeab42b851a5617a77caa1d65a3782a01ee7b (patch)
treed1baa44ff796c9f0c4881e9819e7e5b359489b1d /base
parentf348b92e95dd67fef3a9a6109bc0465fb4078d6b (diff)
downloadchromium_src-33edeab42b851a5617a77caa1d65a3782a01ee7b.zip
chromium_src-33edeab42b851a5617a77caa1d65a3782a01ee7b.tar.gz
chromium_src-33edeab42b851a5617a77caa1d65a3782a01ee7b.tar.bz2
Renames the function CreateTemporaryFilename to CreateTemporaryFile and track down all callers, also removes the
deprecated function that uses std::wstring. BUG=3078 (http://crbug.com/3078) TEST=run base_unittests, installer_util_unittests, net_unittests, setup_unittests, and unit_tests. Review URL: http://codereview.chromium.org/164537 Patch from Thiago Farina. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23631 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/file_util.cc7
-rw-r--r--base/file_util.h13
-rw-r--r--base/file_util_posix.cc9
-rw-r--r--base/file_util_unittest.cc8
-rw-r--r--base/file_util_win.cc24
5 files changed, 24 insertions, 37 deletions
diff --git a/base/file_util.cc b/base/file_util.cc
index 505dfb4..d632b96 100644
--- a/base/file_util.cc
+++ b/base/file_util.cc
@@ -343,13 +343,6 @@ bool CreateNewTempDirectory(const std::wstring& prefix,
*new_temp_path = temp_path.ToWStringHack();
return true;
}
-bool CreateTemporaryFileName(std::wstring* temp_file) {
- FilePath temp_file_path;
- if (!CreateTemporaryFileName(&temp_file_path))
- return false;
- *temp_file = temp_file_path.ToWStringHack();
- return true;
-}
bool Delete(const std::wstring& path, bool recursive) {
return Delete(FilePath::FromWStringHack(path), recursive);
}
diff --git a/base/file_util.h b/base/file_util.h
index 71780f8..1c1a79f 100644
--- a/base/file_util.h
+++ b/base/file_util.h
@@ -283,12 +283,7 @@ bool GetShmemTempDir(FilePath* path);
// Creates a temporary file. The full path is placed in |path|, and the
// function returns true if was successful in creating the file. The file will
// be empty and all handles closed after this function returns.
-// TODO(erikkay): rename this function and track down all of the callers.
-// (Clarification of erik's comment: the intent is to rename the BlahFileName()
-// calls into BlahFile(), since they create temp files (not temp filenames).)
-bool CreateTemporaryFileName(FilePath* path);
-// Deprecated temporary compatibility function.
-bool CreateTemporaryFileName(std::wstring* temp_file);
+bool CreateTemporaryFile(FilePath* path);
// Create and open a temporary file. File is opened for read/write.
// The full path is placed in |path|, and the function returns true if
@@ -300,9 +295,9 @@ FILE* CreateAndOpenTemporaryShmemFile(FilePath* path);
// Similar to CreateAndOpenTemporaryFile, but the file is created in |dir|.
FILE* CreateAndOpenTemporaryFileInDir(const FilePath& dir, FilePath* path);
-// Same as CreateTemporaryFileName but the file is created in |dir|.
-bool CreateTemporaryFileNameInDir(const std::wstring& dir,
- std::wstring* temp_file);
+// Same as CreateTemporaryFile but the file is created in |dir|.
+bool CreateTemporaryFileInDir(const FilePath& dir,
+ FilePath* temp_file);
// Create a new directory under TempPath. If prefix is provided, the new
// directory name is in the format of prefixyyyy.
diff --git a/base/file_util_posix.cc b/base/file_util_posix.cc
index 5a02278..b02df8e 100644
--- a/base/file_util_posix.cc
+++ b/base/file_util_posix.cc
@@ -387,7 +387,7 @@ int CreateAndOpenFdForTemporaryFile(FilePath directory, FilePath* path) {
return mkstemp(buffer);
}
-bool CreateTemporaryFileName(FilePath* path) {
+bool CreateTemporaryFile(FilePath* path) {
FilePath directory;
if (!GetTempDir(&directory))
return false;
@@ -413,10 +413,9 @@ FILE* CreateAndOpenTemporaryFileInDir(const FilePath& dir, FilePath* path) {
return fdopen(fd, "a+");
}
-
-bool CreateTemporaryFileNameInDir(const std::wstring& dir,
- std::wstring* temp_file) {
- // Not implemented yet.
+// TODO(port): implement me.
+bool CreateTemporaryFileInDir(const FilePath& dir,
+ FilePath* temp_file) {
NOTREACHED();
return false;
}
diff --git a/base/file_util_unittest.cc b/base/file_util_unittest.cc
index 7dff868..b1f7822 100644
--- a/base/file_util_unittest.cc
+++ b/base/file_util_unittest.cc
@@ -777,10 +777,10 @@ TEST_F(FileUtilTest, CopyAndDeleteDirectoryTest) {
}
#endif
-TEST_F(FileUtilTest, CreateTemporaryFileNameTest) {
- std::wstring temp_files[3];
+TEST_F(FileUtilTest, CreateTemporaryFileTest) {
+ FilePath temp_files[3];
for (int i = 0; i < 3; i++) {
- ASSERT_TRUE(file_util::CreateTemporaryFileName(&(temp_files[i])));
+ ASSERT_TRUE(file_util::CreateTemporaryFile(&(temp_files[i])));
EXPECT_TRUE(file_util::PathExists(temp_files[i]));
EXPECT_FALSE(file_util::DirectoryExists(temp_files[i]));
}
@@ -790,7 +790,7 @@ TEST_F(FileUtilTest, CreateTemporaryFileNameTest) {
EXPECT_TRUE(file_util::Delete(temp_files[i], false));
}
-TEST_F(FileUtilTest, CreateAndOpenTemporaryFileNameTest) {
+TEST_F(FileUtilTest, CreateAndOpenTemporaryFileTest) {
FilePath names[3];
FILE *fps[3];
int i;
diff --git a/base/file_util_win.cc b/base/file_util_win.cc
index c83322e..cffe72e 100644
--- a/base/file_util_win.cc
+++ b/base/file_util_win.cc
@@ -445,14 +445,14 @@ bool GetShmemTempDir(FilePath* path) {
return GetTempDir(path);
}
-bool CreateTemporaryFileName(FilePath* path) {
- std::wstring temp_path, temp_file;
+bool CreateTemporaryFile(FilePath* path) {
+ FilePath temp_file;
- if (!GetTempDir(&temp_path))
+ if (!GetTempDir(path))
return false;
- if (CreateTemporaryFileNameInDir(temp_path, &temp_file)) {
- *path = FilePath(temp_file);
+ if (CreateTemporaryFileInDir(*path, &temp_file)) {
+ *path = temp_file;
return true;
}
@@ -468,29 +468,29 @@ FILE* CreateAndOpenTemporaryShmemFile(FilePath* path) {
// TODO(jrg): is there equivalent call to use on Windows instead of
// going 2-step?
FILE* CreateAndOpenTemporaryFileInDir(const FilePath& dir, FilePath* path) {
- std::wstring wstring_path;
- if (!CreateTemporaryFileNameInDir(dir.value(), &wstring_path)) {
+ if (!CreateTemporaryFileInDir(dir, path)) {
return NULL;
}
- *path = FilePath(wstring_path);
// Open file in binary mode, to avoid problems with fwrite. On Windows
// it replaces \n's with \r\n's, which may surprise you.
// Reference: http://msdn.microsoft.com/en-us/library/h9t88zwz(VS.71).aspx
return OpenFile(*path, "wb+");
}
-bool CreateTemporaryFileNameInDir(const std::wstring& dir,
- std::wstring* temp_file) {
+bool CreateTemporaryFileInDir(const FilePath& dir,
+ FilePath* temp_file) {
wchar_t temp_name[MAX_PATH + 1];
- if (!GetTempFileName(dir.c_str(), L"", 0, temp_name))
+ if (!GetTempFileName(dir.value().c_str(), L"", 0, temp_name))
return false; // fail!
DWORD path_len = GetLongPathName(temp_name, temp_name, MAX_PATH);
if (path_len > MAX_PATH + 1 || path_len == 0)
return false; // fail!
- temp_file->assign(temp_name, path_len);
+ std::wstring temp_file_str;
+ temp_file_str.assign(temp_name, path_len);
+ *temp_file = FilePath(temp_file_str);
return true;
}