diff options
author | Max Kellermann <max@musicpd.org> | 2018-07-18 16:30:46 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2018-07-18 16:51:29 +0200 |
commit | 32290d5eb848a22e7b16b29e4be7651c002ca14f (patch) | |
tree | 81d24355051c4951af994601288d668bceb42d2d /src/fs | |
parent | f87265a4d52f140d6f156868b2e92efd1951c07e (diff) |
fs/Path: add method ToUTF8Throw()
Diffstat (limited to 'src/fs')
-rw-r--r-- | src/fs/AllocatedPath.hxx | 4 | ||||
-rw-r--r-- | src/fs/Path.cxx | 8 | ||||
-rw-r--r-- | src/fs/Path.hxx | 5 |
3 files changed, 16 insertions, 1 deletions
diff --git a/src/fs/AllocatedPath.hxx b/src/fs/AllocatedPath.hxx index d9af53bfd..5df893928 100644 --- a/src/fs/AllocatedPath.hxx +++ b/src/fs/AllocatedPath.hxx @@ -253,6 +253,10 @@ public: return ((Path)*this).ToUTF8(); } + std::string ToUTF8Throw() const { + return ((Path)*this).ToUTF8Throw(); + } + /** * Gets directory name of this path. * Returns a "nulled" instance on error. diff --git a/src/fs/Path.cxx b/src/fs/Path.cxx index 640c74dbe..2d6ec897d 100644 --- a/src/fs/Path.cxx +++ b/src/fs/Path.cxx @@ -25,12 +25,18 @@ std::string Path::ToUTF8() const noexcept { try { - return ::PathToUTF8(c_str()); + return ToUTF8Throw(); } catch (...) { return std::string(); } } +std::string +Path::ToUTF8Throw() const +{ + return ::PathToUTF8(c_str()); +} + Path::const_pointer_type Path::GetSuffix() const noexcept { diff --git a/src/fs/Path.hxx b/src/fs/Path.hxx index d43527254..eac017389 100644 --- a/src/fs/Path.hxx +++ b/src/fs/Path.hxx @@ -135,6 +135,11 @@ public: std::string ToUTF8() const noexcept; /** + * Like ToUTF8(), but throws on error. + */ + std::string ToUTF8Throw() const; + + /** * Determine the "base" file name. * The return value points inside this object. */ |