From 9256e748c85b725bcf1045782f839c08e8969975 Mon Sep 17 00:00:00 2001 From: John Regan Date: Tue, 26 Sep 2017 08:42:43 -0500 Subject: [PATCH] GME Plugin: only load m3u if it exists If you load an NSFE file (which has embedded track titles), then attempt to load an M3U file, it causes GME to lose all information found in the NSFE file. This adds a check that the M3U file exists before attempting to load. --- src/decoder/plugins/GmeDecoderPlugin.cxx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/decoder/plugins/GmeDecoderPlugin.cxx b/src/decoder/plugins/GmeDecoderPlugin.cxx index 3f9dbfee1..c8f7ae2d4 100644 --- a/src/decoder/plugins/GmeDecoderPlugin.cxx +++ b/src/decoder/plugins/GmeDecoderPlugin.cxx @@ -27,6 +27,7 @@ #include "tag/Builder.hxx" #include "fs/Path.hxx" #include "fs/AllocatedPath.hxx" +#include "fs/FileSystem.hxx" #include "util/ScopeExit.hxx" #include "util/FormatString.hxx" #include "util/UriUtil.hxx" @@ -126,7 +127,14 @@ LoadGmeAndM3u(GmeContainerPath container) { std::string m3u_path(path,suffix); m3u_path += "m3u"; - gme_load_m3u(emu,m3u_path.c_str()); + /* + * Some GME formats lose metadata if you attempt to + * load a non-existant M3U file, so check that one + * exists before loading. + */ + if(FileExists(Path::FromFS(m3u_path.c_str()))) { + gme_load_m3u(emu,m3u_path.c_str()); + } return emu; }