diff options
author | evanm@google.com <evanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-30 23:54:04 +0000 |
---|---|---|
committer | evanm@google.com <evanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-30 23:54:04 +0000 |
commit | 640517fdd23e08ed95cf129d27457db817ee6124 (patch) | |
tree | 2674bc857b9d1b566e05bcfa1dd5c8cfd1897dbf /base/file_path.cc | |
parent | f92ed219c9aeeed79993d1d32f34e5d5c9888dbe (diff) | |
download | chromium_src-640517fdd23e08ed95cf129d27457db817ee6124.zip chromium_src-640517fdd23e08ed95cf129d27457db817ee6124.tar.gz chromium_src-640517fdd23e08ed95cf129d27457db817ee6124.tar.bz2 |
Begin the first small step towards using FilePath everywhere:
- Add some transition APIs.
- Start migrating some code to transition APIs.
Review URL: http://codereview.chromium.org/8825
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4254 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/file_path.cc')
-rw-r--r-- | base/file_path.cc | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/base/file_path.cc b/base/file_path.cc index b20eb6b..4cafd1f 100644 --- a/base/file_path.cc +++ b/base/file_path.cc @@ -4,6 +4,11 @@ #include "base/file_path.h" +// These includes are just for the *Hack functions, and should be removed +// when those functions are removed. +#include "base/string_piece.h" +#include "base/sys_string_conversions.h" + #if defined(FILE_PATH_USES_WIN_SEPARATORS) const FilePath::CharType FilePath::kSeparators[] = FILE_PATH_LITERAL("\\/"); #else // FILE_PATH_USES_WIN_SEPARATORS @@ -152,6 +157,29 @@ bool FilePath::IsAbsolute() const { #endif // FILE_PATH_USES_DRIVE_LETTERS } +#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 + void FilePath::StripTrailingSeparators() { // 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 |