summaryrefslogtreecommitdiff
path: root/src/music/midifile.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/music/midifile.cpp')
-rw-r--r--src/music/midifile.cpp33
1 files changed, 15 insertions, 18 deletions
diff --git a/src/music/midifile.cpp b/src/music/midifile.cpp
index 67cc7b192..b15a27911 100644
--- a/src/music/midifile.cpp
+++ b/src/music/midifile.cpp
@@ -1048,14 +1048,12 @@ bool MidiFile::WriteSMF(const char *filename)
std::string MidiFile::GetSMFFile(const MusicSongInfo &song)
{
if (song.filetype == MTT_STANDARDMIDI) {
- char filename[MAX_PATH];
- if (FioFindFullPath(filename, lastof(filename), Subdirectory::BASESET_DIR, song.filename)) {
- return std::string(filename);
- } else if (FioFindFullPath(filename, lastof(filename), Subdirectory::OLD_GM_DIR, song.filename)) {
- return std::string(filename);
- } else {
- return std::string();
- }
+ std::string filename = FioFindFullPath(Subdirectory::BASESET_DIR, song.filename);
+ if (!filename.empty()) return filename;
+ filename = FioFindFullPath(Subdirectory::OLD_GM_DIR, song.filename);
+ if (!filename.empty()) return filename;
+
+ return std::string();
}
if (song.filetype != MTT_MPSMIDI) return std::string();
@@ -1077,17 +1075,16 @@ std::string MidiFile::GetSMFFile(const MusicSongInfo &song)
*wp++ = '\0';
}
- char tempdirname[MAX_PATH];
- FioGetFullPath(tempdirname, lastof(tempdirname), Searchpath::SP_AUTODOWNLOAD_DIR, Subdirectory::BASESET_DIR, basename);
- if (!AppendPathSeparator(tempdirname, lastof(tempdirname))) return std::string();
- FioCreateDirectory(tempdirname);
+ std::string tempdirname = FioGetDirectory(Searchpath::SP_AUTODOWNLOAD_DIR, Subdirectory::BASESET_DIR);
+ tempdirname += basename;
+ AppendPathSeparator(tempdirname);
+ FioCreateDirectory(tempdirname.c_str());
- char output_filename[MAX_PATH];
- seprintf(output_filename, lastof(output_filename), "%s%d.mid", tempdirname, song.cat_index);
+ std::string output_filename = tempdirname + std::to_string(song.cat_index) + ".mid";
- if (FileExists(output_filename)) {
+ if (FileExists(output_filename.c_str())) {
/* If the file already exists, assume it's the correct decoded data */
- return std::string(output_filename);
+ return output_filename;
}
byte *data;
@@ -1102,8 +1099,8 @@ std::string MidiFile::GetSMFFile(const MusicSongInfo &song)
}
free(data);
- if (midifile.WriteSMF(output_filename)) {
- return std::string(output_filename);
+ if (midifile.WriteSMF(output_filename.c_str())) {
+ return output_filename;
} else {
return std::string();
}