From 1ee6a78cb727561e75a5d60135bb0cd7956f70b0 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 12 Sep 2013 10:02:11 +0200 Subject: Path: add FromUTF8() overload that returns an Error --- src/fs/Path.cxx | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/fs/Path.cxx') diff --git a/src/fs/Path.cxx b/src/fs/Path.cxx index c063025c8..f04823661 100644 --- a/src/fs/Path.cxx +++ b/src/fs/Path.cxx @@ -21,6 +21,7 @@ #include "fs/Path.hxx" #include "ConfigGlobal.hxx" #include "system/FatalError.hxx" +#include "util/Error.hxx" #include "util/Domain.hxx" #include "gcc.h" @@ -89,6 +90,18 @@ Path Path::FromUTF8(const char *path_utf8) return Path(Donate(), p); } +Path +Path::FromUTF8(const char *path_utf8, Error &error) +{ + Path path = FromUTF8(path_utf8); + if (path.IsNull()) + error.Format(path_domain, + "Failed to convert to file system charset: %s", + path_utf8); + + return path; +} + gcc_pure static bool IsSupportedCharset(const char *charset) -- cgit v1.2.3