Fix: Better "temp" path for decoded MPSMIDI files when source filename has no path separators

This commit is contained in:
Niels Martin Hansen
2018-09-03 18:43:55 +02:00
parent 560b01f307
commit bb086f9240

View File

@@ -1020,16 +1020,18 @@ std::string MidiFile::GetSMFFile(const MusicSongInfo &song)
if (song.filetype != MTT_MPSMIDI) return std::string(); if (song.filetype != MTT_MPSMIDI) return std::string();
const char *lastpathsep = strrchr(song.filename, PATHSEPCHAR);
if (lastpathsep == NULL) {
lastpathsep = song.filename;
}
char basename[MAX_PATH]; char basename[MAX_PATH];
{ {
const char *fnstart = strrchr(song.filename, PATHSEPCHAR);
if (fnstart == NULL) {
fnstart = song.filename;
} else {
fnstart++;
}
/* Remove all '.' characters from filename */ /* Remove all '.' characters from filename */
char *wp = basename; char *wp = basename;
for (const char *rp = lastpathsep + 1; *rp != '\0'; rp++) { for (const char *rp = fnstart; *rp != '\0'; rp++) {
if (*rp != '.') *wp++ = *rp; if (*rp != '.') *wp++ = *rp;
} }
*wp++ = '\0'; *wp++ = '\0';