From 07579d7361297a0c5d8427cfd227759f36c59748 Mon Sep 17 00:00:00 2001 From: NinjaCheetah <58050615+NinjaCheetah@users.noreply.github.com> Date: Tue, 20 May 2025 13:54:27 -0400 Subject: [PATCH] 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. --- NUSGet.py | 4 ---- modules/download_dsi.py | 4 ++++ modules/download_wii.py | 4 ++++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/NUSGet.py b/NUSGet.py index 783a4b6..888c8e0 100644 --- a/NUSGet.py +++ b/NUSGet.py @@ -279,10 +279,6 @@ class MainWindow(QMainWindow, Ui_MainWindow): if selected_title.category.find("System") != -1 or selected_title.category == "IOS": archive_name += "-Wii" archive_name += ".wad" - # On Windows, we need to strip characters that aren't allowed on NTFS. APFS and Linux filesystems aren't nearly - # as picky, but some titles contain characters that NTFS dislikes which will break downloads. - if os.name == "nt": - archive_name = archive_name.translate({ord(c): None for c in '/\\:*"?<>|'}) self.ui.archive_file_entry.setText(archive_name) danger_text = selected_title.danger # Add warning text to the log if the selected title has no ticket. diff --git a/modules/download_dsi.py b/modules/download_dsi.py index c0d8c98..91054de 100644 --- a/modules/download_dsi.py +++ b/modules/download_dsi.py @@ -104,6 +104,10 @@ def run_nus_download_dsi(out_folder: pathlib.Path, tid: str, version: str, pack_ tad_file_name += ".tad" else: tad_file_name = f"{tid}-v{title_version}.tad" + # 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. + tad_file_name = tad_file_name.translate({ord(c): None for c in '/\\:*"?<>|'}) # Have libTWLPy dump the TAD, and write that data out. version_dir.joinpath(tad_file_name).write_bytes(title.dump_tad()) progress_callback.emit("Download complete!") diff --git a/modules/download_wii.py b/modules/download_wii.py index 6064da3..cf94ed5 100644 --- a/modules/download_wii.py +++ b/modules/download_wii.py @@ -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!")