OLD | NEW |
---|---|
1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2008 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 #include "base/file_util.h" | 6 #include "base/file_util.h" |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 | 8 |
9 // These includes are just for the *Hack functions, and should be removed | 9 // These includes are just for the *Hack functions, and should be removed |
10 // when those functions are removed. | 10 // when those functions are removed. |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
56 return path.length() > 1 && | 56 return path.length() > 1 && |
57 FilePath::IsSeparator(path[0]) && FilePath::IsSeparator(path[1]); | 57 FilePath::IsSeparator(path[0]) && FilePath::IsSeparator(path[1]); |
58 #else // FILE_PATH_USES_DRIVE_LETTERS | 58 #else // FILE_PATH_USES_DRIVE_LETTERS |
59 // Look for a separator in the first position. | 59 // Look for a separator in the first position. |
60 return path.length() > 0 && FilePath::IsSeparator(path[0]); | 60 return path.length() > 0 && FilePath::IsSeparator(path[0]); |
61 #endif // FILE_PATH_USES_DRIVE_LETTERS | 61 #endif // FILE_PATH_USES_DRIVE_LETTERS |
62 } | 62 } |
63 | 63 |
64 } // namespace | 64 } // namespace |
65 | 65 |
66 const std::string FilePath::UTF8Value() const { | |
67 #if defined(OS_POSIX) | |
68 // TODO(erikkay): I'm not sure how to make this code always correct for Linux. | |
darin (slow to review)
2008/12/23 20:23:55
this is precisely why this kind of function is pro
Avi (use Gerrit)
2008/12/23 22:58:49
There are cases where we need to have the path in
Erik does not do reviews
2008/12/23 23:02:04
Unfortunately, as Darin educated me here, this met
| |
69 return path_; | |
70 #elif defined(OS_WIN) | |
71 return WideToUTF8(path_); | |
72 #endif | |
73 } | |
74 | |
66 bool FilePath::IsSeparator(CharType character) { | 75 bool FilePath::IsSeparator(CharType character) { |
67 for (size_t i = 0; i < arraysize(kSeparators) - 1; ++i) { | 76 for (size_t i = 0; i < arraysize(kSeparators) - 1; ++i) { |
68 if (character == kSeparators[i]) { | 77 if (character == kSeparators[i]) { |
69 return true; | 78 return true; |
70 } | 79 } |
71 } | 80 } |
72 | 81 |
73 return false; | 82 return false; |
74 } | 83 } |
75 | 84 |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
249 --pos) { | 258 --pos) { |
250 // If the string only has two separators and they're at the beginning, | 259 // If the string only has two separators and they're at the beginning, |
251 // don't strip them, unless the string began with more than two separators. | 260 // don't strip them, unless the string began with more than two separators. |
252 if (pos != start + 1 || last_stripped == start + 2 || | 261 if (pos != start + 1 || last_stripped == start + 2 || |
253 !IsSeparator(path_[start - 1])) { | 262 !IsSeparator(path_[start - 1])) { |
254 path_.resize(pos - 1); | 263 path_.resize(pos - 1); |
255 last_stripped = pos; | 264 last_stripped = pos; |
256 } | 265 } |
257 } | 266 } |
258 } | 267 } |
OLD | NEW |