mirror of
https://github.com/Virtual-World-RE/NeoGF.git
synced 2024-11-15 13:55:35 +01:00
Update afstool.py
This commit is contained in:
parent
00678250cb
commit
3e4009b9c7
12
afstool.py
12
afstool.py
|
@ -126,7 +126,7 @@ class Afs:
|
||||||
def __loadsys_from_afs(self, afs_file, afs_len:int):
|
def __loadsys_from_afs(self, afs_file, afs_len:int):
|
||||||
self.__tableofcontent = afs_file.read(Afs.HEADER_LEN)
|
self.__tableofcontent = afs_file.read(Afs.HEADER_LEN)
|
||||||
if self.__get_magic() not in [Afs.MAGIC_00, Afs.MAGIC_20]:
|
if self.__get_magic() not in [Afs.MAGIC_00, Afs.MAGIC_20]:
|
||||||
raise Exception("Invalid AFS magic number.")
|
raise Exception("Error - Invalid AFS magic number.")
|
||||||
self.__file_count = self.__get_file_count()
|
self.__file_count = self.__get_file_count()
|
||||||
self.__tableofcontent += afs_file.read(self.__file_count*8)
|
self.__tableofcontent += afs_file.read(self.__file_count*8)
|
||||||
tableofcontent_len = len(self.__tableofcontent)
|
tableofcontent_len = len(self.__tableofcontent)
|
||||||
|
@ -201,11 +201,11 @@ class Afs:
|
||||||
logging.info("There is no filename directory. Creating new names and dates for files.")
|
logging.info("There is no filename directory. Creating new names and dates for files.")
|
||||||
else:
|
else:
|
||||||
logging.debug(f"filenamedirectory_offset:0x{self.__filenamedirectory_offset:x}, filenamedirectory_len:0x{self.__filenamedirectory_len:x}.")
|
logging.debug(f"filenamedirectory_offset:0x{self.__filenamedirectory_offset:x}, filenamedirectory_len:0x{self.__filenamedirectory_len:x}.")
|
||||||
logging.info("Writting sys/filenamedirectory.bin")
|
logging.info(f"Writting {Path('sys/filenamedirectory.bin')}")
|
||||||
(sys_path / "filenamedirectory.bin").write_bytes(self.__filenamedirectory)
|
(sys_path / "filenamedirectory.bin").write_bytes(self.__filenamedirectory)
|
||||||
resolver = FilenameResolver(sys_path)
|
resolver = FilenameResolver(sys_path)
|
||||||
|
|
||||||
logging.info("Writting sys/tableofcontent.bin")
|
logging.info(f"Writting {Path('sys/tableofcontent.bin')}")
|
||||||
(sys_path / "tableofcontent.bin").write_bytes(self.__tableofcontent)
|
(sys_path / "tableofcontent.bin").write_bytes(self.__tableofcontent)
|
||||||
|
|
||||||
logging.info(f"Extracting {self.__file_count} files.")
|
logging.info(f"Extracting {self.__file_count} files.")
|
||||||
|
@ -267,11 +267,11 @@ class Afs:
|
||||||
if self.__filenamedirectory:
|
if self.__filenamedirectory:
|
||||||
afs_file.seek(self.__filenamedirectory_offset)
|
afs_file.seek(self.__filenamedirectory_offset)
|
||||||
afs_file.write(self.__pad(self.__filenamedirectory))
|
afs_file.write(self.__pad(self.__filenamedirectory))
|
||||||
logging.debug(f"Packing {sys_path}/tableofcontent.bin at the beginning of the AFS.")
|
logging.debug(f"Packing {sys_path / 'tableofcontent.bin'} at the beginning of the AFS.")
|
||||||
afs_file.seek(0)
|
afs_file.seek(0)
|
||||||
afs_file.write(self.__tableofcontent)
|
afs_file.write(self.__tableofcontent)
|
||||||
def rebuild(self, folder_path:Path):
|
def rebuild(self, folder_path:Path):
|
||||||
raise Exception("Not implemented yet")
|
raise Exception("Error - Not implemented yet")
|
||||||
def stats(self, path:Path):
|
def stats(self, path:Path):
|
||||||
if path.is_file():
|
if path.is_file():
|
||||||
with path.open("rb") as afs_file:
|
with path.open("rb") as afs_file:
|
||||||
|
@ -396,7 +396,7 @@ def get_argparser():
|
||||||
group.add_argument('-p', '--pack', action='store_true', help="-p source_folder (dest_file.afs): Pack source_folder in new file source_folder.afs or dest_file.afs if specified.")
|
group.add_argument('-p', '--pack', action='store_true', help="-p source_folder (dest_file.afs): Pack source_folder in new file source_folder.afs or dest_file.afs if specified.")
|
||||||
group.add_argument('-u', '--unpack', action='store_true', help="-u source_afs.afs (dest_folder): Unpack the AFS in new folder source_afs or dest_folder if specified.")
|
group.add_argument('-u', '--unpack', action='store_true', help="-u source_afs.afs (dest_folder): Unpack the AFS in new folder source_afs or dest_folder if specified.")
|
||||||
group.add_argument('-s', '--stats', action='store_true', help="-s source_afs.afs or source_folder: Get stats about AFS, files, memory, lengths and offsets.")
|
group.add_argument('-s', '--stats', action='store_true', help="-s source_afs.afs or source_folder: Get stats about AFS, files, memory, lengths and offsets.")
|
||||||
group.add_argument('-r', '--rebuild', help="-r source_folder fndo_offset : Rebuild AFS tableofcontent (TOC) and filenamedirectory (FND) using filenamedirectory_offset_offset=fndo_offset (the offset in the TOC).")
|
group.add_argument('-r', '--rebuild', help="-r source_folder: Rebuild AFS tableofcontent (TOC) and filenamedirectory (FD) using rebuild.conf file.")
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user