diff options
Diffstat (limited to '')
-rw-r--r-- | src/PlaylistFile.cxx | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/src/PlaylistFile.cxx b/src/PlaylistFile.cxx index 2fb28aadf..f0aa2d2d7 100644 --- a/src/PlaylistFile.cxx +++ b/src/PlaylistFile.cxx @@ -116,6 +116,29 @@ spl_map_to_fs(const char *name_utf8, Error &error) return path_fs; } +gcc_pure +static bool +IsNotFoundError(const Error &error) +{ +#ifdef WIN32 + return error.IsDomain(win32_domain) && + error.GetCode() == ERROR_FILE_NOT_FOUND; +#else + return error.IsDomain(errno_domain) && + error.GetCode() == ENOENT; +#endif +} + +static void +TranslatePlaylistError(Error &error) +{ + if (IsNotFoundError(error)) { + error.Clear(); + error.Set(playlist_domain, int(PlaylistResult::NO_SUCH_LIST), + "No such playlist"); + } +} + /** * Create an #Error for the current errno. */ @@ -228,9 +251,9 @@ LoadPlaylistFile(const char *utf8path, Error &error) if (path_fs.IsNull()) return contents; - TextFile file(path_fs); + TextFile file(path_fs, error); if (file.HasFailed()) { - playlist_errno(error); + TranslatePlaylistError(error); return contents; } |