Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/file_path.h" | 5 #include "base/file_path.h" |
| 6 | 6 |
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 #elif defined(OS_MACOSX) | |
| 10 #include <CoreServices/CoreServices.h> | |
| 11 #endif | 9 #endif |
| 12 | 10 |
| 13 #include "base/logging.h" | 11 #include "base/logging.h" |
| 14 #include "base/pickle.h" | 12 #include "base/pickle.h" |
| 15 | 13 |
| 16 // These includes are just for the *Hack functions, and should be removed | 14 // These includes are just for the *Hack functions, and should be removed |
| 17 // when those functions are removed. | 15 // when those functions are removed. |
| 18 #include "base/string_piece.h" | 16 #include "base/string_piece.h" |
| 19 #include "base/string_util.h" | 17 #include "base/string_util.h" |
| 20 #include "base/sys_string_conversions.h" | 18 #include "base/sys_string_conversions.h" |
| 21 #include "base/utf_string_conversions.h" | 19 #include "base/utf_string_conversions.h" |
| 22 | 20 |
| 23 #if defined(OS_MACOSX) | 21 #if defined(OS_MACOSX) |
| 24 #include "base/mac/scoped_cftyperef.h" | 22 #include "base/mac/scoped_cftyperef.h" |
|
TVL
2010/11/15 17:02:00
fyi - this pulls in corefoundation
Mark Mentovai
2010/11/15 17:11:31
TVL wrote:
| |
| 25 #include "base/third_party/icu/icu_utf.h" | 23 #include "base/third_party/icu/icu_utf.h" |
| 26 #endif | 24 #endif |
| 27 | 25 |
| 28 #if defined(FILE_PATH_USES_WIN_SEPARATORS) | 26 #if defined(FILE_PATH_USES_WIN_SEPARATORS) |
| 29 const FilePath::CharType FilePath::kSeparators[] = FILE_PATH_LITERAL("\\/"); | 27 const FilePath::CharType FilePath::kSeparators[] = FILE_PATH_LITERAL("\\/"); |
| 30 #else // FILE_PATH_USES_WIN_SEPARATORS | 28 #else // FILE_PATH_USES_WIN_SEPARATORS |
| 31 const FilePath::CharType FilePath::kSeparators[] = FILE_PATH_LITERAL("/"); | 29 const FilePath::CharType FilePath::kSeparators[] = FILE_PATH_LITERAL("/"); |
| 32 #endif // FILE_PATH_USES_WIN_SEPARATORS | 30 #endif // FILE_PATH_USES_WIN_SEPARATORS |
| 33 | 31 |
| 34 const FilePath::CharType FilePath::kCurrentDirectory[] = FILE_PATH_LITERAL("."); | 32 const FilePath::CharType FilePath::kCurrentDirectory[] = FILE_PATH_LITERAL("."); |
| (...skipping 950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 985 if (codepoint1 == 0) { | 983 if (codepoint1 == 0) { |
| 986 DCHECK_EQ(index1, length1); | 984 DCHECK_EQ(index1, length1); |
| 987 DCHECK_EQ(index2, length2); | 985 DCHECK_EQ(index2, length2); |
| 988 return 0; | 986 return 0; |
| 989 } | 987 } |
| 990 } | 988 } |
| 991 } | 989 } |
| 992 | 990 |
| 993 StringType FilePath::GetHFSDecomposedForm(const StringType& string) { | 991 StringType FilePath::GetHFSDecomposedForm(const StringType& string) { |
| 994 base::mac::ScopedCFTypeRef<CFStringRef> cfstring( | 992 base::mac::ScopedCFTypeRef<CFStringRef> cfstring( |
| 995 CFStringCreateWithBytesNoCopy( | 993 CFStringCreateWithBytesNoCopy( |
|
Mark Mentovai
2010/11/15 16:47:15
Hello kitty.
| |
| 996 NULL, | 994 NULL, |
| 997 reinterpret_cast<const UInt8*>(string.c_str()), | 995 reinterpret_cast<const UInt8*>(string.c_str()), |
| 998 string.length(), | 996 string.length(), |
| 999 kCFStringEncodingUTF8, | 997 kCFStringEncodingUTF8, |
| 1000 false, | 998 false, |
| 1001 kCFAllocatorNull)); | 999 kCFAllocatorNull)); |
| 1002 // Query the maximum length needed to store the result. In most cases this | 1000 // Query the maximum length needed to store the result. In most cases this |
| 1003 // will overestimate the required space. The return value also already | 1001 // will overestimate the required space. The return value also already |
| 1004 // includes the space needed for a terminating 0. | 1002 // includes the space needed for a terminating 0. |
| 1005 CFIndex length = CFStringGetMaximumSizeOfFileSystemRepresentation(cfstring); | 1003 CFIndex length = CFStringGetMaximumSizeOfFileSystemRepresentation(cfstring); |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1183 | 1181 |
| 1184 #if defined(FILE_PATH_USES_WIN_SEPARATORS) | 1182 #if defined(FILE_PATH_USES_WIN_SEPARATORS) |
| 1185 FilePath FilePath::NormalizeWindowsPathSeparators() const { | 1183 FilePath FilePath::NormalizeWindowsPathSeparators() const { |
| 1186 StringType copy = path_; | 1184 StringType copy = path_; |
| 1187 for (size_t i = 1; i < arraysize(kSeparators); ++i) { | 1185 for (size_t i = 1; i < arraysize(kSeparators); ++i) { |
| 1188 std::replace(copy.begin(), copy.end(), kSeparators[i], kSeparators[0]); | 1186 std::replace(copy.begin(), copy.end(), kSeparators[i], kSeparators[0]); |
| 1189 } | 1187 } |
| 1190 return FilePath(copy); | 1188 return FilePath(copy); |
| 1191 } | 1189 } |
| 1192 #endif | 1190 #endif |
| OLD | NEW |