Skip to content

Commit

Permalink
Make the order of methods in the cc files match the headers in base/.
Browse files Browse the repository at this point in the history
BUG=68682
TEST=compiles

Review URL: http://codereview.chromium.org/6189001

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70771 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
erg@google.com committed Jan 7, 2011
1 parent 3abebda commit 9989c9b
Show file tree
Hide file tree
Showing 8 changed files with 395 additions and 412 deletions.
194 changes: 98 additions & 96 deletions base/file_path.cc
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,23 @@ FilePath& FilePath::operator=(const FilePath& that) {
return *this;
}

bool FilePath::operator==(const FilePath& that) const {
#if defined(FILE_PATH_USES_DRIVE_LETTERS)
return EqualDriveLetterCaseInsensitive(this->path_, that.path_);
#else // defined(FILE_PATH_USES_DRIVE_LETTERS)
return path_ == that.path_;
#endif // defined(FILE_PATH_USES_DRIVE_LETTERS)
}

bool FilePath::operator!=(const FilePath& that) const {
#if defined(FILE_PATH_USES_DRIVE_LETTERS)
return !EqualDriveLetterCaseInsensitive(this->path_, that.path_);
#else // defined(FILE_PATH_USES_DRIVE_LETTERS)
return path_ != that.path_;
#endif // defined(FILE_PATH_USES_DRIVE_LETTERS)
}

// static
bool FilePath::IsSeparator(CharType character) {
for (size_t i = 0; i < arraysize(kSeparators) - 1; ++i) {
if (character == kSeparators[i]) {
Expand Down Expand Up @@ -219,22 +236,6 @@ void FilePath::GetComponents(std::vector<StringType>* components) const {
*components = std::vector<StringType>(ret_val.rbegin(), ret_val.rend());
}

bool FilePath::operator==(const FilePath& that) const {
#if defined(FILE_PATH_USES_DRIVE_LETTERS)
return EqualDriveLetterCaseInsensitive(this->path_, that.path_);
#else // defined(FILE_PATH_USES_DRIVE_LETTERS)
return path_ == that.path_;
#endif // defined(FILE_PATH_USES_DRIVE_LETTERS)
}

bool FilePath::operator!=(const FilePath& that) const {
#if defined(FILE_PATH_USES_DRIVE_LETTERS)
return !EqualDriveLetterCaseInsensitive(this->path_, that.path_);
#else // defined(FILE_PATH_USES_DRIVE_LETTERS)
return path_ != that.path_;
#endif // defined(FILE_PATH_USES_DRIVE_LETTERS)
}

bool FilePath::IsParent(const FilePath& child) const {
return AppendRelativePath(child, NULL);
}
Expand Down Expand Up @@ -489,6 +490,87 @@ bool FilePath::IsAbsolute() const {
return IsPathAbsolute(path_);
}

FilePath FilePath::StripTrailingSeparators() const {
FilePath new_path(path_);
new_path.StripTrailingSeparatorsInternal();

return new_path;
}

bool FilePath::ReferencesParent() const {
std::vector<StringType> components;
GetComponents(&components);

std::vector<StringType>::const_iterator it = components.begin();
for (; it != components.end(); ++it) {
const StringType& component = *it;
if (component == kParentDirectory)
return true;
}
return false;
}

#if defined(OS_POSIX)

// See file_path.h for a discussion of the encoding of paths on POSIX
// platforms. These *Hack() functions are not quite correct, but they're
// only temporary while we fix the remainder of the code.
// Remember to remove the #includes at the top when you remove these.

// static
FilePath FilePath::FromWStringHack(const std::wstring& wstring) {
return FilePath(base::SysWideToNativeMB(wstring));
}
std::wstring FilePath::ToWStringHack() const {
return base::SysNativeMBToWide(path_);
}
#elif defined(OS_WIN)
// static
FilePath FilePath::FromWStringHack(const std::wstring& wstring) {
return FilePath(wstring);
}
std::wstring FilePath::ToWStringHack() const {
return path_;
}
#endif

// static.
void FilePath::WriteStringTypeToPickle(Pickle* pickle,
const StringType& path) {
#if defined(WCHAR_T_IS_UTF16)
pickle->WriteWString(path);
#elif defined(WCHAR_T_IS_UTF32)
pickle->WriteString(path);
#else
NOTIMPLEMENTED() << "Impossible encoding situation!";
#endif
}

// static.
bool FilePath::ReadStringTypeFromPickle(Pickle* pickle, void** iter,
StringType* path) {
#if defined(WCHAR_T_IS_UTF16)
if (!pickle->ReadWString(iter, path))
return false;
#elif defined(WCHAR_T_IS_UTF32)
if (!pickle->ReadString(iter, path))
return false;
#else
NOTIMPLEMENTED() << "Impossible encoding situation!";
return false;
#endif

return true;
}

void FilePath::WriteToPickle(Pickle* pickle) {
WriteStringTypeToPickle(pickle, value());
}

bool FilePath::ReadFromPickle(Pickle* pickle, void** iter) {
return ReadStringTypeFromPickle(pickle, iter, &path_);
}

#if defined(OS_WIN)
// Windows specific implementation of file string comparisons

Expand Down Expand Up @@ -1078,73 +1160,6 @@ int FilePath::CompareIgnoreCase(const StringType& string1,

#endif // OS versions of CompareIgnoreCase()

#if defined(OS_POSIX)

// See file_path.h for a discussion of the encoding of paths on POSIX
// platforms. These *Hack() functions are not quite correct, but they're
// only temporary while we fix the remainder of the code.
// Remember to remove the #includes at the top when you remove these.

// static
FilePath FilePath::FromWStringHack(const std::wstring& wstring) {
return FilePath(base::SysWideToNativeMB(wstring));
}
std::wstring FilePath::ToWStringHack() const {
return base::SysNativeMBToWide(path_);
}
#elif defined(OS_WIN)
// static
FilePath FilePath::FromWStringHack(const std::wstring& wstring) {
return FilePath(wstring);
}
std::wstring FilePath::ToWStringHack() const {
return path_;
}
#endif

FilePath FilePath::StripTrailingSeparators() const {
FilePath new_path(path_);
new_path.StripTrailingSeparatorsInternal();

return new_path;
}

// static.
void FilePath::WriteStringTypeToPickle(Pickle* pickle,
const StringType& path) {
#if defined(WCHAR_T_IS_UTF16)
pickle->WriteWString(path);
#elif defined(WCHAR_T_IS_UTF32)
pickle->WriteString(path);
#else
NOTIMPLEMENTED() << "Impossible encoding situation!";
#endif
}

// static.
bool FilePath::ReadStringTypeFromPickle(Pickle* pickle, void** iter,
StringType* path) {
#if defined(WCHAR_T_IS_UTF16)
if (!pickle->ReadWString(iter, path))
return false;
#elif defined(WCHAR_T_IS_UTF32)
if (!pickle->ReadString(iter, path))
return false;
#else
NOTIMPLEMENTED() << "Impossible encoding situation!";
return false;
#endif

return true;
}

void FilePath::WriteToPickle(Pickle* pickle) {
WriteStringTypeToPickle(pickle, value());
}

bool FilePath::ReadFromPickle(Pickle* pickle, void** iter) {
return ReadStringTypeFromPickle(pickle, iter, &path_);
}

void FilePath::StripTrailingSeparatorsInternal() {
// If there is no drive letter, start will be 1, which will prevent stripping
Expand All @@ -1168,19 +1183,6 @@ void FilePath::StripTrailingSeparatorsInternal() {
}
}

bool FilePath::ReferencesParent() const {
std::vector<StringType> components;
GetComponents(&components);

std::vector<StringType>::const_iterator it = components.begin();
for (; it != components.end(); ++it) {
const StringType& component = *it;
if (component == kParentDirectory)
return true;
}
return false;
}

#if defined(FILE_PATH_USES_WIN_SEPARATORS)
FilePath FilePath::NormalizeWindowsPathSeparators() const {
StringType copy = path_;
Expand Down
Loading

0 comments on commit 9989c9b

Please sign in to comment.