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

Side by Side Diff: base/file_path.cc

Issue 172012: Add "bool FilePath::ReferencesParent()" which adds a clean & simple way for... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 4 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/file_path.h ('k') | base/file_path_unittest.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) 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/logging.h" 6 #include "base/logging.h"
7 7
8 // These includes are just for the *Hack functions, and should be removed 8 // These includes are just for the *Hack functions, and should be removed
9 // when those functions are removed. 9 // when those functions are removed.
10 #include "base/string_piece.h" 10 #include "base/string_piece.h"
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 --pos) { 445 --pos) {
446 // If the string only has two separators and they're at the beginning, 446 // If the string only has two separators and they're at the beginning,
447 // don't strip them, unless the string began with more than two separators. 447 // don't strip them, unless the string began with more than two separators.
448 if (pos != start + 1 || last_stripped == start + 2 || 448 if (pos != start + 1 || last_stripped == start + 2 ||
449 !IsSeparator(path_[start - 1])) { 449 !IsSeparator(path_[start - 1])) {
450 path_.resize(pos - 1); 450 path_.resize(pos - 1);
451 last_stripped = pos; 451 last_stripped = pos;
452 } 452 }
453 } 453 }
454 } 454 }
455
456 bool FilePath::ReferencesParent() const {
457 std::vector<FilePath::StringType> components;
458 GetComponents(&components);
459
460 std::vector<FilePath::StringType>::const_iterator it = components.begin();
461 for (; it != components.end(); ++it) {
462 const FilePath::StringType& component = *it;
463 if (component == kParentDirectory)
464 return true;
465 }
466 return false;
467 }
468
OLDNEW
« no previous file with comments | « base/file_path.h ('k') | base/file_path_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698