Chromium Code Reviews| Index: base/file_path.h |
| diff --git a/base/file_path.h b/base/file_path.h |
| index 639683356eea970980cdc65cd1438b944289795b..514bf8842670bdecc1401c2e084eaec5d7306749 100644 |
| --- a/base/file_path.h |
| +++ b/base/file_path.h |
| @@ -17,6 +17,7 @@ |
| // |
| // * The encoding need not be specified on POSIX systems, although some |
| // POSIX-compliant systems do specify an encoding. Mac OS X uses UTF-8. |
| +// Chrome OS also uses UTF-8. |
| // Linux does not specify an encoding, but in practice, the locale's |
| // character set may be used. |
| // |
| @@ -294,6 +295,20 @@ class BASE_EXPORT FilePath { |
| // known-ASCII filename. |
| std::string MaybeAsASCII() const; |
| + // Return the path as UTF-8. |
| + // |
| + // This function is *unsafe* as we cannot tell what encoding is used in |
|
Mark Mentovai
2011/11/01 21:30:46
Please avoid using “we” in comments. Line 307 and
satorux1
2011/11/01 21:49:55
Done.
|
| + // file names on POSIX systems other than Mac and Chrome OS, although |
| + // UTF-8 is practically used everywhere these days. To mitigate the |
| + // encoding issue, this function internally calls SysNativeMBToWide() on |
| + // POSIX per assumption that the current locale's encoding is used in |
|
Mark Mentovai
2011/11/01 21:30:46
SysNativeMBToWide is unnecessary (and in some case
satorux1
2011/11/01 21:49:55
Done.
|
| + // file names, but this isn't a perfect solution. |
| + // |
| + // Once we are confident enough to stop caring about non-UTF-8 file |
| + // names, we'll get rid of the SysNativeMBToWide() hack and and remove |
| + // "Unsafe" from the function name. |
| + std::string AsUTF8Unsafe() const; |
| + |
| // Older Chromium code assumes that paths are always wstrings. |
| // This function converts wstrings to FilePaths, and is |
| // useful to smooth porting that old code to the FilePath API. |
| @@ -312,6 +327,15 @@ class BASE_EXPORT FilePath { |
| // ever use the result of that again as a path. |
| static FilePath FromWStringHack(const std::wstring& wstring); |
| + // Returns a FilePath object from a path name in UTF-8. This function |
| + // should only be used for cases where you are sure that the input |
| + // string is UTF-8. |
| + // |
| + // Like AsUTF8Unsafe(), this function is unsafe. This function |
| + // internally calls SysWideToNativeMB() on POSIX to mitigate the |
| + // encoding issue. See the comment at AsUTF8Unsafe() for details. |
| + static FilePath FromUTF8Unsafe(const std::string& utf8); |
| + |
| void WriteToPickle(Pickle* pickle); |
| bool ReadFromPickle(Pickle* pickle, void** iter); |