aboutsummaryrefslogtreecommitdiff
path: root/src/fs
diff options
context:
space:
mode:
authorDenis Krjuchkov <denis@crazydev.net>2013-01-24 00:48:14 +0600
committerDenis Krjuchkov <denis@crazydev.net>2013-01-26 11:16:12 +0600
commit292d7c3fdfa1732a3b4ff7b9db3075a063311819 (patch)
tree56236a67714c15da9ac633600b0b9d135f8fd5df /src/fs
parent0273cd44b0b50d5d320ce88cc1472e0d8ee8e529 (diff)
Path: ToUTF() returns std::string
Diffstat (limited to 'src/fs')
-rw-r--r--src/fs/Path.cxx12
-rw-r--r--src/fs/Path.hxx13
2 files changed, 17 insertions, 8 deletions
diff --git a/src/fs/Path.cxx b/src/fs/Path.cxx
index 80b41cba..393cb303 100644
--- a/src/fs/Path.cxx
+++ b/src/fs/Path.cxx
@@ -38,6 +38,18 @@
static char *fs_charset;
+std::string Path::ToUTF8() const
+{
+ if (value == nullptr)
+ return std::string();
+ char *path_utf8 = fs_charset_to_utf8(value);
+ if (path_utf8 == nullptr)
+ return std::string();
+ std::string result = value;
+ g_free(path_utf8);
+ return value;
+}
+
char *
fs_charset_to_utf8(const char *path_fs)
{
diff --git a/src/fs/Path.hxx b/src/fs/Path.hxx
index 24f1d5e1..926b6eaf 100644
--- a/src/fs/Path.hxx
+++ b/src/fs/Path.hxx
@@ -26,6 +26,7 @@
#include <glib.h>
#include <algorithm>
+#include <string>
#include <assert.h>
#include <string.h>
@@ -250,15 +251,11 @@ public:
}
/**
- * Convert the path to UTF-8. The caller is responsible for
- * freeing the return value with g_free(). Returns nullptr on
- * error.
+ * Convert the path to UTF-8.
+ * Returns empty string on error or if this instance is "nulled"
+ * (#IsNull returns true).
*/
- char *ToUTF8() const {
- return value != nullptr
- ? fs_charset_to_utf8(value)
- : nullptr;
- }
+ std::string ToUTF8() const;
};
#endif