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

Unified Diff: base/files/file_path.cc

Issue 17509002: Add FilePath::{As,From}UTF16Unsafe (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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 | « base/files/file_path.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/files/file_path.cc
diff --git a/base/files/file_path.cc b/base/files/file_path.cc
index 743cbb50537b3b3a609c8e1cd12bea8c65c32dbd..ef0cde6fd8fd76bd53bd98eec091ae5c9bbc08f3 100644
--- a/base/files/file_path.cc
+++ b/base/files/file_path.cc
@@ -577,6 +577,14 @@ std::string FilePath::AsUTF8Unsafe() const {
#endif
}
+string16 FilePath::AsUTF16Unsafe() const {
+#if defined(OS_MACOSX) || defined(OS_CHROMEOS)
+ return UTF8ToUTF16(value());
+#else
+ return WideToUTF16(SysNativeMBToWide(value()));
+#endif
+}
+
// The *Hack functions are temporary while we fix the remainder of the code.
// Remember to remove the #includes at the top when you remove these.
@@ -594,6 +602,15 @@ FilePath FilePath::FromUTF8Unsafe(const std::string& utf8) {
#endif
}
+// static
+FilePath FilePath::FromUTF16Unsafe(const string16& utf16) {
+#if defined(OS_MACOSX) || defined(OS_CHROMEOS)
+ return FilePath(UTF16ToUTF8(utf16));
+#else
+ return FilePath(SysWideToNativeMB(UTF16ToWide(utf16)));
+#endif
+}
+
#elif defined(OS_WIN)
string16 FilePath::LossyDisplayName() const {
return path_;
@@ -609,6 +626,10 @@ std::string FilePath::AsUTF8Unsafe() const {
return WideToUTF8(value());
}
+string16 FilePath::AsUTF16Unsafe() const {
+ return value();
+}
+
// static
FilePath FilePath::FromWStringHack(const std::wstring& wstring) {
return FilePath(wstring);
@@ -618,6 +639,11 @@ FilePath FilePath::FromWStringHack(const std::wstring& wstring) {
FilePath FilePath::FromUTF8Unsafe(const std::string& utf8) {
return FilePath(UTF8ToWide(utf8));
}
+
+// static
+FilePath FilePath::FromUTF16Unsafe(const string16& utf16) {
+ return FilePath(utf16);
+}
#endif
void FilePath::WriteToPickle(Pickle* pickle) const {
« no previous file with comments | « base/files/file_path.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698