summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-23 12:52:11 +0000
committerevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-23 12:52:11 +0000
commita18f79afc7cf1d3369d07a2e59b4ee100d9ff9fa (patch)
treedaa803fd1d74abf5c25bb7ab04d905fbff3882cc
parentd505a6d89230804cb9eeecc641b383bb2d4d5ce0 (diff)
downloadchromium_src-a18f79afc7cf1d3369d07a2e59b4ee100d9ff9fa.zip
chromium_src-a18f79afc7cf1d3369d07a2e59b4ee100d9ff9fa.tar.gz
chromium_src-a18f79afc7cf1d3369d07a2e59b4ee100d9ff9fa.tar.bz2
Deprecate GetDirectoryFromPath on non-Windows.
Due to a bunch of changes I made last week, we now only need this in Windows-specific codepaths. BUG=24672 Review URL: http://codereview.chromium.org/654009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39715 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/file_util.h11
-rw-r--r--base/file_util_deprecated.h15
-rw-r--r--base/file_util_posix.cc12
-rw-r--r--base/file_util_unittest.cc3
4 files changed, 18 insertions, 23 deletions
diff --git a/base/file_util.h b/base/file_util.h
index ad36a7e..fbde3e7 100644
--- a/base/file_util.h
+++ b/base/file_util.h
@@ -49,17 +49,6 @@ bool EndsWithSeparator(const FilePath& path);
// exists. Returns true if |path| is an existing directory, false otherwise.
bool EnsureEndsWithSeparator(FilePath* path);
-// Returns the directory component of a path, without the trailing
-// path separator, or an empty string on error. The function does not
-// check for the existence of the path, so if it is passed a directory
-// without the trailing \, it will interpret the last component of the
-// path as a file and chomp it. This does not support relative paths.
-// Examples:
-// path == "C:\pics\jojo.jpg", returns "C:\pics"
-// path == "C:\Windows\system32\", returns "C:\Windows\system32"
-// path == "C:\Windows\system32", returns "C:\Windows"
-std::wstring GetDirectoryFromPath(const std::wstring& path);
-
// Appends new_ending to path, adding a separator between the two if necessary.
void AppendToPath(std::wstring* path, const std::wstring& new_ending);
diff --git a/base/file_util_deprecated.h b/base/file_util_deprecated.h
index fd28ed2..05fd514 100644
--- a/base/file_util_deprecated.h
+++ b/base/file_util_deprecated.h
@@ -54,6 +54,21 @@ int ReadFile(const std::wstring& filename, char* data, int size);
int WriteFile(const std::wstring& filename, const char* data, int size);
bool GetCurrentDirectory(std::wstring* path);
+// Successfully deprecated on non-Windows, but Win-specific callers remain.
+#if defined(OS_WIN)
+// Returns the directory component of a path, without the trailing
+// path separator, or an empty string on error. The function does not
+// check for the existence of the path, so if it is passed a directory
+// without the trailing \, it will interpret the last component of the
+// path as a file and chomp it. This does not support relative paths.
+// Examples:
+// path == "C:\pics\jojo.jpg", returns "C:\pics"
+// path == "C:\Windows\system32\", returns "C:\Windows\system32"
+// path == "C:\Windows\system32", returns "C:\Windows"
+// Deprecated. Use FilePath's DirName() instead.
+std::wstring GetDirectoryFromPath(const std::wstring& path);
+#endif
+
}
#endif // BASE_FILE_UTIL_DEPRECATED_H_
diff --git a/base/file_util_posix.cc b/base/file_util_posix.cc
index 590b94d..c6069e6 100644
--- a/base/file_util_posix.cc
+++ b/base/file_util_posix.cc
@@ -60,18 +60,6 @@ static const char* kTempFileName = "com.google.chrome.XXXXXX";
static const char* kTempFileName = "org.chromium.XXXXXX";
#endif
-std::wstring GetDirectoryFromPath(const std::wstring& path) {
- if (EndsWithSeparator(path)) {
- return FilePath::FromWStringHack(path)
- .StripTrailingSeparators()
- .ToWStringHack();
- } else {
- char full_path[PATH_MAX];
- base::strlcpy(full_path, WideToUTF8(path).c_str(), arraysize(full_path));
- return UTF8ToWide(dirname(full_path));
- }
-}
-
bool AbsolutePath(FilePath* path) {
char full_path[PATH_MAX];
if (realpath(path->value().c_str(), full_path) == NULL)
diff --git a/base/file_util_unittest.cc b/base/file_util_unittest.cc
index 31bb46f..ae6560d 100644
--- a/base/file_util_unittest.cc
+++ b/base/file_util_unittest.cc
@@ -311,6 +311,8 @@ static const struct dir_case {
#endif
};
+#if defined(OS_WIN)
+// This function is deprecated, and only exists on Windows anymore.
TEST_F(FileUtilTest, GetDirectoryFromPath) {
for (unsigned int i = 0; i < arraysize(dir_cases); ++i) {
const dir_case& dir = dir_cases[i];
@@ -319,6 +321,7 @@ TEST_F(FileUtilTest, GetDirectoryFromPath) {
EXPECT_EQ(dir.directory, parent);
}
}
+#endif
TEST_F(FileUtilTest, CountFilesCreatedAfter) {
// Create old file (that we don't want to count)