Compare commits

...

4 Commits

  1. 3
      ninfs/main.py
  2. 26
      ninfs/mount/exefs.py
  3. 2
      requirements.txt
  4. 2
      setup.py

3
ninfs/main.py

@ -70,6 +70,7 @@ def mount(mount_type: str, return_doc: bool = False) -> int: @@ -70,6 +70,7 @@ def mount(mount_type: str, return_doc: bool = False) -> int:
parent_pid = int(environ['NINFS_GUI_PARENT_PID'])
if windll.kernel32.AttachConsole(parent_pid) == 0: # ATTACH_PARENT_PROCESS
print(f'Failed to do AttachConsole({parent_pid}):', get_last_error())
print("(Note: this most likely isn't the cause of any other issues you might have!)")
except KeyError:
pass
@ -78,12 +79,14 @@ def mount(mount_type: str, return_doc: bool = False) -> int: @@ -78,12 +79,14 @@ def mount(mount_type: str, return_doc: bool = False) -> int:
module = import_module('mount.' + mountinfo.aliases.get(mount_type, mount_type))
if return_doc:
# noinspection PyTypeChecker
return module.__doc__
prog = None
if __name__ != '__main__':
prog = 'mount_' + mountinfo.aliases.get(mount_type, mount_type)
try:
# noinspection PyUnresolvedReferences
return module.main(prog=prog)
except BootromNotFoundError as e:
print('Bootrom could not be found.',

26
ninfs/mount/exefs.py

@ -73,25 +73,19 @@ class ExeFSMount(LoggingMixIn, Operations): @@ -73,25 +73,19 @@ class ExeFSMount(LoggingMixIn, Operations):
self.files = {'/' + x.name.replace('.', '', 1) + '.bin': x.name for x in self.reader.entries.values()}
self.special_files = {}
if 'icon' in self.reader.entries:
try:
with self.reader.open('icon') as i:
smdh = SMDH.load(i)
except InvalidSMDHError:
print('ExeFS: Failed to load smdh')
else:
icon_small = BytesIO()
icon_large = BytesIO()
if self.reader.icon:
icon_small = BytesIO()
icon_large = BytesIO()
smdh.icon_small.save(icon_small, 'png')
smdh.icon_large.save(icon_large, 'png')
self.reader.icon.icon_small.save(icon_small, 'png')
self.reader.icon.icon_large.save(icon_large, 'png')
icon_small_size = icon_small.seek(0, 2)
icon_large_size = icon_large.seek(0, 2)
icon_small_size = icon_small.seek(0, 2)
icon_large_size = icon_large.seek(0, 2)
# these names are too long to be in the exefs, so special checks can be added for them
self.special_files['/icon_small.png'] = {'size': icon_small_size, 'io': icon_small}
self.special_files['/icon_large.png'] = {'size': icon_large_size, 'io': icon_large}
# these names are too long to be in the exefs, so special checks can be added for them
self.special_files['/icon_small.png'] = {'size': icon_small_size, 'io': icon_small}
self.special_files['/icon_large.png'] = {'size': icon_large_size, 'io': icon_large}
@_c.ensure_lower_path
def getattr(self, path, fh=None):

2
requirements.txt

@ -1,3 +1,3 @@ @@ -1,3 +1,3 @@
pyctr>=0.5.1,<0.6
haccrypto==0.1.1
haccrypto>=0.1
pycryptodomex>=3.9,<4

2
setup.py

@ -39,7 +39,7 @@ setup( @@ -39,7 +39,7 @@ setup(
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
],
install_requires=['pycryptodomex>=3.9,<4', 'pyctr>=0.5.1,<0.6', 'haccrypto==0.1.1'],
install_requires=['pycryptodomex>=3.9,<4', 'pyctr>=0.5.1,<0.6', 'haccrypto>=0.1'],
python_requires='>=3.6.1',
# fusepy should be added here once the main repo has a new release with Windows support.
entry_points={'gui_scripts': ['ninfsw = ninfs.main:gui'],

Loading…
Cancel
Save