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

Unified Diff: base/file_path.h

Issue 6246036: FilePath: Remove most of ToWStringHack, adding a LossyDisplayName() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: bug link Created 9 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/file_path.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/file_path.h
diff --git a/base/file_path.h b/base/file_path.h
index 01cd4a555eee6a95e8b1df444fbd92a87e8a1c80..84bb35005f605bf8feab076c3ceb2f09abcd6d51 100644
--- a/base/file_path.h
+++ b/base/file_path.h
@@ -277,6 +277,12 @@ class FilePath {
// directory (i.e. has a path component that is ".."
bool ReferencesParent() const;
+ // Return a Unicode human-readable version of this path.
+ // Warning: you can *not*, in general, go from a display name back to a real
+ // path. Only use this when displaying paths to users, not just when you
+ // want to stuff a string16 into some other API.
+ string16 LossyDisplayName() const;
+
// Older Chromium code assumes that paths are always wstrings.
// These functions convert wstrings to/from FilePaths, and are
// useful to smooth porting that old code to the FilePath API.
@@ -290,6 +296,9 @@ class FilePath {
// OS-native string format.
// - Am I using well-known file names, like "config.ini"? Then use the
// ASCII functions (we require paths to always be supersets of ASCII).
+ // - Am I displaying a string to the user in some UI? Then use the
+ // LossyDisplayName() function, but keep in mind that you can't
+ // ever use the result of that again as a path.
static FilePath FromWStringHack(const std::wstring& wstring);
std::wstring ToWStringHack() const;
« no previous file with comments | « no previous file | base/file_path.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698