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 <algorithm> | 5 #include <algorithm> |
6 | 6 |
7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
8 | 8 |
9 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
10 #include <windows.h> | 10 #include <windows.h> |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
242 return AppendRelativePath(child, NULL); | 242 return AppendRelativePath(child, NULL); |
243 } | 243 } |
244 | 244 |
245 bool FilePath::AppendRelativePath(const FilePath& child, | 245 bool FilePath::AppendRelativePath(const FilePath& child, |
246 FilePath* path) const { | 246 FilePath* path) const { |
247 std::vector<StringType> parent_components; | 247 std::vector<StringType> parent_components; |
248 std::vector<StringType> child_components; | 248 std::vector<StringType> child_components; |
249 GetComponents(&parent_components); | 249 GetComponents(&parent_components); |
250 child.GetComponents(&child_components); | 250 child.GetComponents(&child_components); |
251 | 251 |
252 if (parent_components.size() >= child_components.size()) | 252 if (parent_components.size() >= child_components.size()) |
Peter Kasting
2011/03/02 00:02:42
Nit: Seems like these could be combined
| |
253 return false; | 253 return false; |
254 if (parent_components.size() == 0) | 254 if (parent_components.empty()) |
255 return false; | 255 return false; |
256 | 256 |
257 std::vector<StringType>::const_iterator parent_comp = | 257 std::vector<StringType>::const_iterator parent_comp = |
258 parent_components.begin(); | 258 parent_components.begin(); |
259 std::vector<StringType>::const_iterator child_comp = | 259 std::vector<StringType>::const_iterator child_comp = |
260 child_components.begin(); | 260 child_components.begin(); |
261 | 261 |
262 #if defined(FILE_PATH_USES_DRIVE_LETTERS) | 262 #if defined(FILE_PATH_USES_DRIVE_LETTERS) |
263 // Windows can access case sensitive filesystems, so component | 263 // Windows can access case sensitive filesystems, so component |
264 // comparisions must be case sensitive, but drive letters are | 264 // comparisions must be case sensitive, but drive letters are |
(...skipping 930 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1195 | 1195 |
1196 #if defined(FILE_PATH_USES_WIN_SEPARATORS) | 1196 #if defined(FILE_PATH_USES_WIN_SEPARATORS) |
1197 FilePath FilePath::NormalizeWindowsPathSeparators() const { | 1197 FilePath FilePath::NormalizeWindowsPathSeparators() const { |
1198 StringType copy = path_; | 1198 StringType copy = path_; |
1199 for (size_t i = 1; i < arraysize(kSeparators); ++i) { | 1199 for (size_t i = 1; i < arraysize(kSeparators); ++i) { |
1200 std::replace(copy.begin(), copy.end(), kSeparators[i], kSeparators[0]); | 1200 std::replace(copy.begin(), copy.end(), kSeparators[i], kSeparators[0]); |
1201 } | 1201 } |
1202 return FilePath(copy); | 1202 return FilePath(copy); |
1203 } | 1203 } |
1204 #endif | 1204 #endif |
OLD | NEW |