summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--base/file_path.cc9
-rw-r--r--base/file_path.h4
2 files changed, 13 insertions, 0 deletions
diff --git a/base/file_path.cc b/base/file_path.cc
index 45f6e327..7cfe952 100644
--- a/base/file_path.cc
+++ b/base/file_path.cc
@@ -63,6 +63,15 @@ bool IsPathAbsolute(const FilePath::StringType& path) {
} // namespace
+const std::string FilePath::UTF8Value() const {
+#if defined(OS_POSIX)
+ // TODO(erikkay): I'm not sure how to make this code always correct for Linux.
+ return path_;
+#elif defined(OS_WIN)
+ return WideToUTF8(path_);
+#endif
+}
+
bool FilePath::IsSeparator(CharType character) {
for (size_t i = 0; i < arraysize(kSeparators) - 1; ++i) {
if (character == kSeparators[i]) {
diff --git a/base/file_path.h b/base/file_path.h
index cadf2cf..6d57c97 100644
--- a/base/file_path.h
+++ b/base/file_path.h
@@ -132,6 +132,10 @@ class FilePath {
const StringType& value() const { return path_; }
+ // Returns value() encoded as a UTF8 std::string. Be careful to not use this
+ // in places that use filesystem APIs as it won't be portable.
+ const std::string UTF8Value() const;
+
// Returns true if |character| is in kSeparators.
static bool IsSeparator(CharType character);