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.
This commit is contained in:
John Regan 2017-09-26 08:42:43 -05:00
parent af033c0d1d
commit 9256e748c8

View File

@ -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;
}