diff options
author | Max Kellermann <max@duempel.org> | 2014-08-07 18:54:06 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-08-07 19:38:25 +0200 |
commit | aa2e4d92e0005f4516eb591803120eff89f99109 (patch) | |
tree | beb83ec24f0cb5b527ec60bd56c2722681f1d3f5 /src/PlaylistFile.cxx | |
parent | 0ea66a1275da319e2443fa1536cec7ea7fc53b53 (diff) | |
download | mpd-aa2e4d92e0005f4516eb591803120eff89f99109.tar.gz mpd-aa2e4d92e0005f4516eb591803120eff89f99109.tar.xz mpd-aa2e4d92e0005f4516eb591803120eff89f99109.zip |
fs/io/BufferedReader: new class to replace class TextFile
The new class is pluggable, to prepare for gzipped database files.
For now, the TextFile class remains, and will be refactored away
later.
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; } |