mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-08-19 12:39:11 +00:00
Codechange: Use std::string in FIO search path handling.
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
Reference in New Issue
Block a user