Skip to content

Commit

Permalink
Fix log display of files with non-ascii characters.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarod42 committed Aug 6, 2023
1 parent c2cb636 commit 53fa98e
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -777,20 +777,20 @@ void copyImageFromFLC (const std::filesystem::path& fileName, const std::filesys

if (file == nullptr)
{
throw InstallException ("FLC-File '" + fileName.string() + "' not found" + TEXT_FILE_LF);
throw InstallException ("FLC-File '" + fileName.u8string() + "' not found" + TEXT_FILE_LF);
}

animation = FLI_Open (file, &error);
if (error != 0)
{
throw InstallException ("FLC-File '" + fileName.string() + "' may be corrupted" + TEXT_FILE_LF);
throw InstallException ("FLC-File '" + fileName.u8string() + "' may be corrupted" + TEXT_FILE_LF);
}

error = FLI_NextFrame (animation);
if (error != 0)
{
FLI_Close (animation);
throw InstallException ("FLC-File '" + fileName.string() + "' may be corrupted" + TEXT_FILE_LF);
throw InstallException ("FLC-File '" + fileName.u8string() + "' may be corrupted" + TEXT_FILE_LF);
}

savePCX (animation->surface, dst);
Expand Down
4 changes: 2 additions & 2 deletions src/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ SDL_RWops* openFile (const std::filesystem::path& path, const char* mode)
return file;
}

throw InstallException ("Couldn't open file '" + (dir / fileName).string() + "' or '" + lowerCaseFileName + "'" + TEXT_FILE_LF);
throw InstallException ("Couldn't open file '" + (dir / fileName).u8string() + "' or '" + lowerCaseFileName + "'" + TEXT_FILE_LF);
return nullptr;
}

Expand All @@ -92,7 +92,7 @@ void copyFile (const std::filesystem::path& source, const std::filesystem::path&
}
else
{
throw InstallException ("Couldn't copy file '" + source.string() + "' to '" + dest.string() + "'" + TEXT_FILE_LF);
throw InstallException ("Couldn't copy file '" + source.u8string() + "' to '" + dest.u8string() + "'" + TEXT_FILE_LF);
}
}
END_INSTALL_FILE (dest);
Expand Down
2 changes: 1 addition & 1 deletion src/pcx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ SDL_Surface* loadPCX (const std::filesystem::path& name)

if (file == nullptr)
{
throw InstallException (std::string ("Couldn't open file ") + name.string() + TEXT_FILE_LF);
throw InstallException (std::string ("Couldn't open file ") + name.u8string() + TEXT_FILE_LF);
}

//load data
Expand Down
1 change: 1 addition & 0 deletions src/resinstaller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4463,6 +4463,7 @@ int main (int argc, char* argv[])
sVoicePath = sMAXPath;
writeLog ("Language is not available");
}
writeLog ("Voice path: " + sVoicePath.u8string() + TEXT_FILE_LF);
}
// ask the user, which language to install
else
Expand Down
8 changes: 4 additions & 4 deletions src/resinstaller.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,18 @@ void trimSpaces (std::string& str, const std::locale& loc = std::locale());

void trimQuotes (std::string& str);

// makes all necessary actions after a successfull
// or unsuccessfull attempt to install a file
// makes all necessary actions after a successful
// or unsuccessful attempt to install a file
#define END_INSTALL_FILE(file) \
catch (const InstallException& e) \
{ \
writeLog ("Error while installing file '" + std::filesystem::path(file).string() + "'" + TEXT_FILE_LF + e.message); \
writeLog ("Error while installing file '" + std::filesystem::path (file).u8string() + "'" + TEXT_FILE_LF + e.message); \
iErrors++; \
wasError = true; \
} \
catch (const std::exception& e) \
{ \
writeLog ("Error while installing file '" + std::filesystem::path (file).string() + "'" + TEXT_FILE_LF + e.what() + TEXT_FILE_LF); \
writeLog ("Error while installing file '" + std::filesystem::path (file).u8string() + "'" + TEXT_FILE_LF + e.what() + TEXT_FILE_LF); \
iErrors++; \
wasError = true; \
} \
Expand Down
2 changes: 1 addition & 1 deletion src/wave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ int loadWAV (const std::filesystem::path& src, cWaveFile& waveFile)
if (SDL_LoadWAV_RW (file, 0, &waveFile.spec, &waveFile.buffer, &waveFile.length) == nullptr)
{
SDL_RWclose (file);
throw InstallException ("File '" + src.string() + "' may be corrupted" + TEXT_FILE_LF);
throw InstallException ("File '" + src.u8string() + "' may be corrupted" + TEXT_FILE_LF);
}
//load smpl chunk
readSmplChunk (file, waveFile);
Expand Down

0 comments on commit 53fa98e

Please sign in to comment.