Improve illegal character removal

Now removes the NTFS-forbidden characters on all platforms, as some may still cause issues depending on your OS and FS. These characters are also now removed during the actual download process, so they'll still appear in the WAD name box, but will be stripped out before the file is created.
This commit is contained in:
2025-05-20 13:54:27 -04:00
parent 9b4addc8a5
commit 07579d7361
3 changed files with 8 additions and 4 deletions

View File

@@ -134,6 +134,10 @@ def run_nus_download_wii(out_folder: pathlib.Path, tid: str, version: str, pack_
title = ios_patcher.dump()
# Append "-PATCHED" to the end of the WAD file name to make it clear that it was modified.
wad_file_name = wad_file_name[:-4] + "-PATCHED" + wad_file_name[-4:]
# Certain special characters are prone to breaking things, so strip them from the file name before actually
# opening the file for writing. On some platforms (like macOS), invalid characters get replaced automatically,
# but on Windows the file will just fail to be written out at all.
wad_file_name = wad_file_name.translate({ord(c): None for c in '/\\:*"?<>|'})
# Have libWiiPy dump the WAD, and write that data out.
version_dir.joinpath(wad_file_name).write_bytes(title.dump_wad())
progress_callback.emit("Download complete!")