| 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. | |
| 69 return path_; | |
| 70 #elif defined(OS_WIN) | |
| 71 return WideToUTF8(path_); | |
| 72 #endif | |
| 73 } | |
| 74 | |
| 75 bool FilePath::IsSeparator(CharType character) { | 66 bool FilePath::IsSeparator(CharType character) { |
| 76 for (size_t i = 0; i < arraysize(kSeparators) - 1; ++i) { | 67 for (size_t i = 0; i < arraysize(kSeparators) - 1; ++i) { |
| 77 if (character == kSeparators[i]) { | 68 if (character == kSeparators[i]) { |
| 78 return true; | 69 return true; |
| 79 } | 70 } |
| 80 } | 71 } |
| 81 | 72 |
| 82 return false; | 73 return false; |
| 83 } | 74 } |
| 84 | 75 |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 --pos) { | 249 --pos) { |
| 259 // If the string only has two separators and they're at the beginning, | 250 // If the string only has two separators and they're at the beginning, |
| 260 // don't strip them, unless the string began with more than two separators. | 251 // don't strip them, unless the string began with more than two separators. |
| 261 if (pos != start + 1 || last_stripped == start + 2 || | 252 if (pos != start + 1 || last_stripped == start + 2 || |
| 262 !IsSeparator(path_[start - 1])) { | 253 !IsSeparator(path_[start - 1])) { |
| 263 path_.resize(pos - 1); | 254 path_.resize(pos - 1); |
| 264 last_stripped = pos; | 255 last_stripped = pos; |
| 265 } | 256 } |
| 266 } | 257 } |
| 267 } | 258 } |
| OLD | NEW |