mirror of https://github.com/OpenTTD/OpenTTD
Fix: Better "temp" path for decoded MPSMIDI files when source filename has no path separators
parent
560b01f307
commit
bb086f9240
|
@ -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';
|
||||||
|
|
Loading…
Reference in New Issue