Skip to content

Commit

Permalink
Raise ReadOnlyDiskError when reading a file works, but deleting it do…
Browse files Browse the repository at this point in the history
…esn't
  • Loading branch information
hollowaytape committed May 11, 2017
1 parent 260f9b3 commit ca4133b
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions patcher.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from os import path, remove
from shutil import copyfile
from rominfo import DISK_FILES, IMAGES
from romtools.disk import Disk, FileNotFoundError, FileFormatNotSupportedError, HARD_DISK_FORMATS
from romtools.disk import Disk, FileNotFoundError, FileFormatNotSupportedError, ReadOnlyDiskError, HARD_DISK_FORMATS
from romtools.patch import Patch, PatchChecksumError

def patch(sysDisk, opDisk=None, diskA=None, diskB=None, path_in_disk=None, backup_folder='./backup', speedhack=False):
Expand Down Expand Up @@ -117,10 +117,13 @@ def patch(sysDisk, opDisk=None, diskA=None, diskB=None, path_in_disk=None, backu

copyfile(extracted_file_path + '_edited', extracted_file_path)

if fallback_necessary:
RustyDiskOriginal.insert(extracted_file_path, 'RUSTY')
else:
RustyDiskOriginal.insert(extracted_file_path, path_in_disk, fallback_path='RUSTY')
try:
if fallback_necessary:
RustyDiskOriginal.insert(extracted_file_path, path_in_disk='RUSTY', fallback_path='.')
else:
RustyDiskOriginal.insert(extracted_file_path, path_in_disk, fallback_path='RUSTY')
except ReadOnlyDiskError:
return "Can't write to disk %s. Make sure it's not read-only." % disks[disk_index]
remove(extracted_file_path)
remove(extracted_file_path + '_edited')

Expand Down

0 comments on commit ca4133b

Please sign in to comment.