fs/Path: add method ToUTF8Throw()

This commit is contained in:
Max Kellermann
2018-07-18 16:30:46 +02:00
parent f87265a4d5
commit 32290d5eb8
10 changed files with 43 additions and 29 deletions

View File

@@ -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.

View File

@@ -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
{

View File

@@ -134,6 +134,11 @@ public:
gcc_pure
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.