mirror of
https://github.com/NinjaCheetah/libWiiPy.git
synced 2025-04-26 05:11:02 -04:00
Allow for extracting a U8 archive to an existing (empty) directory
This commit is contained in:
parent
1f731bbc81
commit
45638769a9
@ -172,9 +172,14 @@ def extract_u8(u8_data, output_folder) -> None:
|
|||||||
The path to a new folder to extract the archive to.
|
The path to a new folder to extract the archive to.
|
||||||
"""
|
"""
|
||||||
output_folder = pathlib.Path(output_folder)
|
output_folder = pathlib.Path(output_folder)
|
||||||
if pathlib.Path.is_dir(output_folder):
|
# Check if the path already exists, and if it does, ensure that it is both a directory and empty.
|
||||||
raise ValueError("Output folder already exists!")
|
if output_folder.exists():
|
||||||
os.mkdir(output_folder)
|
if output_folder.is_dir() and next(os.scandir(output_folder), None):
|
||||||
|
raise ValueError("Output folder is not empty!")
|
||||||
|
elif output_folder.is_file():
|
||||||
|
raise ValueError("A file already exists with the provided name!")
|
||||||
|
else:
|
||||||
|
os.mkdir(output_folder)
|
||||||
# Create a new U8Archive object and load the provided U8 file data into it.
|
# Create a new U8Archive object and load the provided U8 file data into it.
|
||||||
u8_archive = U8Archive()
|
u8_archive = U8Archive()
|
||||||
u8_archive.load(u8_data)
|
u8_archive.load(u8_data)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user