diff options
author | avi@google.com <avi@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-11 14:55:12 +0000 |
---|---|---|
committer | avi@google.com <avi@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-11 14:55:12 +0000 |
commit | 0b733220c5fbef986647fce040c1b5d5e48be2b6 (patch) | |
tree | 72caaec198bd07c1e468c2a4805b00067da78126 /base/file_path.cc | |
parent | 64596e5e583f0c64124da1a79e496d6e063c25fa (diff) | |
download | chromium_src-0b733220c5fbef986647fce040c1b5d5e48be2b6.zip chromium_src-0b733220c5fbef986647fce040c1b5d5e48be2b6.tar.gz chromium_src-0b733220c5fbef986647fce040c1b5d5e48be2b6.tar.bz2 |
Move file enumeration to filepaths.
Review URL: http://codereview.chromium.org/13315
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6784 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/file_path.cc')
-rw-r--r-- | base/file_path.cc | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/base/file_path.cc b/base/file_path.cc index 0856029..a938ca6 100644 --- a/base/file_path.cc +++ b/base/file_path.cc @@ -77,7 +77,7 @@ bool FilePath::IsSeparator(CharType character) { // adhere to their behavior. FilePath FilePath::DirName() const { FilePath new_path(path_); - new_path.StripTrailingSeparators(); + new_path.StripTrailingSeparatorsInternal(); // The drive letter, if any, always needs to remain in the output. If there // is no drive letter, as will always be the case on platforms which do not @@ -104,7 +104,7 @@ FilePath FilePath::DirName() const { new_path.path_.resize(last_separator); } - new_path.StripTrailingSeparators(); + new_path.StripTrailingSeparatorsInternal(); if (!new_path.path_.length()) new_path.path_ = kCurrentDirectory; @@ -113,7 +113,7 @@ FilePath FilePath::DirName() const { FilePath FilePath::BaseName() const { FilePath new_path(path_); - new_path.StripTrailingSeparators(); + new_path.StripTrailingSeparatorsInternal(); // The drive letter, if any, is always stripped. StringType::size_type letter = FindDriveLetter(new_path.path_); @@ -148,7 +148,7 @@ FilePath FilePath::Append(const FilePath::StringType& component) const { } FilePath new_path(path_); - new_path.StripTrailingSeparators(); + new_path.StripTrailingSeparatorsInternal(); // Don't append a separator if the path is empty (indicating the current // directory) or if the path component is empty (indicating nothing to @@ -201,7 +201,14 @@ std::wstring FilePath::ToWStringHack() const { } #endif -void FilePath::StripTrailingSeparators() { +FilePath FilePath::StripTrailingSeparators() const { + FilePath new_path(path_); + new_path.StripTrailingSeparatorsInternal(); + + return new_path; +} + +void FilePath::StripTrailingSeparatorsInternal() { // If there is no drive letter, start will be 1, which will prevent stripping // the leading separator if there is only one separator. If there is a drive // letter, start will be set appropriately to prevent stripping the first |