Skip to content

Commit 4b8d31b

Browse files
committed
Fix savedata (un)mounting
1 parent fe29ec8 commit 4b8d31b

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

_nx.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import nx
2+
3+
14
def account_initialize():
25
"""Initializes the account service."""
36
pass
@@ -17,7 +20,7 @@ def fs_mount_savedata(name: str, title_id: int, user_id: int):
1720
user_id: int
1821
The user ID of the user whose savedata filesystem to mount.
1922
"""
20-
pass
23+
nx.filesystem.SAVEDATA_BASE_PATH = '../save/'
2124

2225

2326
def fsdev_unmount_device(mountpoint: str):

nx/filesystem.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,9 @@ def unmount(self):
7676

7777
def __enter__(self):
7878
self.mount()
79+
return self
7980

80-
def __exit__(self):
81+
def __exit__(self, exc_type, exc_val, exc_tb):
8182
self.commit()
8283
self.unmount()
8384

@@ -111,7 +112,7 @@ def unmount(self):
111112
"""Unmounts the mounted RomFS."""
112113
_nx.fsdev_unmount_device('romfs')
113114

114-
def __exit__(self):
115+
def __exit__(self, exc_type, exc_val, exc_tb):
115116
self.unmount()
116117

117118

@@ -150,6 +151,7 @@ def mount(self):
150151

151152
def commit(self):
152153
"""Commits the savedata filesystem."""
154+
print(_nx.__dict__)
153155
_nx.fsdev_commit_device('save')
154156

155157
def unmount(self):

test.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,12 @@
88

99

1010
def main():
11-
nx.filesystem.SAVEDATA_BASE_PATH = '../save/'
12-
nx.filesystem.ROMFS_BASE_PATH = '../romfs/'
13-
1411
botw = nx.titles[BOTW_TITLE_ID] # get botw Title object
1512

1613
try:
1714
with botw.savedata as savedata: # mount BotW savedata partition
18-
with savedata.open(SAVEGAME_PATH) as savegame_file: # open save game file
19-
with open(OUTPUT_PATH, 'w') as destination_file: # open destination file on SD card
15+
with savedata.open(SAVEGAME_PATH, 'rb') as savegame_file: # open save game file
16+
with open(OUTPUT_PATH, 'wb') as destination_file: # open destination file on SD card
2017
shutil.copyfileobj(savegame_file, destination_file) # copy file from savedata to SD card
2118
except FileNotFoundError:
2219
print("No such file:", SAVEGAME_PATH)

0 commit comments

Comments
 (0)