mirror of
https://github.com/robmcmullen/atrcopy.git
synced 2024-11-29 11:51:14 +00:00
Disk image filenames should be str, not encoded bytes
This commit is contained in:
parent
8747e7e26b
commit
7e3159b175
@ -130,11 +130,10 @@ class DiskImageBase(object):
|
|||||||
return Directory
|
return Directory
|
||||||
|
|
||||||
def set_filename(self, filename):
|
def set_filename(self, filename):
|
||||||
if type(filename) is not bytes: filename = filename.encode("utf-8")
|
if '.' in filename:
|
||||||
if b'.' in filename:
|
self.filename, self.ext = filename.rsplit('.', 1)
|
||||||
self.filename, self.ext = filename.rsplit(b'.', 1)
|
|
||||||
else:
|
else:
|
||||||
self.filename, self.ext = filename, b''
|
self.filename, self.ext = filename, ''
|
||||||
|
|
||||||
def dir(self):
|
def dir(self):
|
||||||
lines = []
|
lines = []
|
||||||
@ -180,10 +179,9 @@ class DiskImageBase(object):
|
|||||||
if not filename:
|
if not filename:
|
||||||
filename = self.filename
|
filename = self.filename
|
||||||
if self.ext:
|
if self.ext:
|
||||||
filename += b'.' + self.ext
|
filename += '.' + self.ext
|
||||||
if not filename:
|
if not filename:
|
||||||
raise RuntimeError("No filename specified for save!")
|
raise RuntimeError("No filename specified for save!")
|
||||||
if type(filename) is not bytes: filename = filename.encode("utf-8")
|
|
||||||
data = self.bytes[:]
|
data = self.bytes[:]
|
||||||
with open(filename, "wb") as fh:
|
with open(filename, "wb") as fh:
|
||||||
data.tofile(fh)
|
data.tofile(fh)
|
||||||
|
Loading…
Reference in New Issue
Block a user