Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(447)

Side by Side Diff: base/file_path.cc

Issue 6609008: Change other usages of .size() to .empty() when applicable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Peter nits Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/command_line_unittest.cc ('k') | base/process_util_posix.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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.empty() ||
253 return false; 253 parent_components.size() >= child_components.size())
254 if (parent_components.empty())
255 return false; 254 return false;
256 255
257 std::vector<StringType>::const_iterator parent_comp = 256 std::vector<StringType>::const_iterator parent_comp =
258 parent_components.begin(); 257 parent_components.begin();
259 std::vector<StringType>::const_iterator child_comp = 258 std::vector<StringType>::const_iterator child_comp =
260 child_components.begin(); 259 child_components.begin();
261 260
262 #if defined(FILE_PATH_USES_DRIVE_LETTERS) 261 #if defined(FILE_PATH_USES_DRIVE_LETTERS)
263 // Windows can access case sensitive filesystems, so component 262 // Windows can access case sensitive filesystems, so component
264 // comparisions must be case sensitive, but drive letters are 263 // comparisions must be case sensitive, but drive letters are
(...skipping 942 matching lines...) Expand 10 before | Expand all | Expand 10 after
1207 1206
1208 #if defined(FILE_PATH_USES_WIN_SEPARATORS) 1207 #if defined(FILE_PATH_USES_WIN_SEPARATORS)
1209 FilePath FilePath::NormalizeWindowsPathSeparators() const { 1208 FilePath FilePath::NormalizeWindowsPathSeparators() const {
1210 StringType copy = path_; 1209 StringType copy = path_;
1211 for (size_t i = 1; i < arraysize(kSeparators); ++i) { 1210 for (size_t i = 1; i < arraysize(kSeparators); ++i) {
1212 std::replace(copy.begin(), copy.end(), kSeparators[i], kSeparators[0]); 1211 std::replace(copy.begin(), copy.end(), kSeparators[i], kSeparators[0]);
1213 } 1212 }
1214 return FilePath(copy); 1213 return FilePath(copy);
1215 } 1214 }
1216 #endif 1215 #endif
OLDNEW
« no previous file with comments | « base/command_line_unittest.cc ('k') | base/process_util_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698