summaryrefslogtreecommitdiffstats
path: root/base/file_path.h
diff options
context:
space:
mode:
authorrolandsteiner@chromium.org <rolandsteiner@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-27 05:24:41 +0000
committerrolandsteiner@chromium.org <rolandsteiner@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-27 05:24:41 +0000
commitea9058d410a6df42e3ed72e0414fcf4b3607c3cb (patch)
treec7e0c39cab780a9bba614a4e28b9fd96db66b0ea /base/file_path.h
parentdfc95697b09185a561b2a30080ead8298b9c8668 (diff)
downloadchromium_src-ea9058d410a6df42e3ed72e0414fcf4b3607c3cb.zip
chromium_src-ea9058d410a6df42e3ed72e0414fcf4b3607c3cb.tar.gz
chromium_src-ea9058d410a6df42e3ed72e0414fcf4b3607c3cb.tar.bz2
Commit patch set from http://codereview.chromium.org/149796
(see discussion and history there) BUG=10876 TEST=FilePathTest.MatchesExtension.CompareIgnoreCase git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30168 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/file_path.h')
-rw-r--r--base/file_path.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/base/file_path.h b/base/file_path.h
index 5c8f183..7900922 100644
--- a/base/file_path.h
+++ b/base/file_path.h
@@ -294,6 +294,41 @@ class FilePath {
// TODO(port): remove these functions.
static FilePath FromWStringHack(const std::wstring& wstring);
+ // Compare two strings in the same way the file system does.
+ // Note that these always ignore case, even on file systems that are case-
+ // sensitive. If case-sensitive comparison is ever needed, add corresponding
+ // methods here.
+ // The methods are written as a static method so that they can also be used
+ // on parts of a file path, e.g., just the extension.
+ // CompareIgnoreCase() returns -1, 0 or 1 for less-than, equal-to and
+ // greater-than respectively.
+ static int CompareIgnoreCase(const StringType& string1,
+ const StringType& string2);
+ static bool CompareEqualIgnoreCase(const StringType& string1,
+ const StringType& string2) {
+ return CompareIgnoreCase(string1, string2) == 0;
+ }
+ static bool CompareLessIgnoreCase(const StringType& string1,
+ const StringType& string2) {
+ return CompareIgnoreCase(string1, string2) < 0;
+ }
+
+#if defined(OS_MACOSX)
+ // Returns the string in the special canonical decomposed form as defined for
+ // HFS, which is close to, but not quite, decomposition form D. See
+ // http://developer.apple.com/mac/library/technotes/tn/tn1150.html#UnicodeSubtleties
+ // for further comments.
+ // Returns the epmty string if the conversion failed.
+ static StringType GetHFSDecomposedForm(const FilePath::StringType& string);
+
+ // Special UTF-8 version of FastUnicodeCompare. Cf:
+ // http://developer.apple.com/mac/library/technotes/tn/tn1150.html#StringComparisonAlgorithm
+ // IMPORTANT: The input strings must be in the special HFS decomposed form!
+ // (cf. above GetHFSDecomposedForm method)
+ static int HFSFastUnicodeCompare(const StringType& string1,
+ const StringType& string2);
+#endif
+
// Older Chromium code assumes that paths are always wstrings.
// This function produces a wstring from a FilePath, and is useful to smooth
// porting that old code to the FilePath API.