Skip to content

Commit

Permalink
support opening read-only WAD files
Browse files Browse the repository at this point in the history
fixes #24
  • Loading branch information
devinacker committed Apr 22, 2017
1 parent 261c14c commit 582da97
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion wadio.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,12 @@ def open(self, filename):
raise IOError("The handle is already open")
# Open an existing WAD
if os.path.exists(filename):
self.basefile = open(filename, 'r+b')
try:
self.basefile = open(filename, 'r+b')
except IOError:
# assume file is read-only
self.basefile = open(filename, 'rb')

filesize = os.stat(self.basefile.name)[6]
self.header = h = Header(bytes=self.basefile.read(Header._fmtsize))
if (not h.type in ("PWAD", "IWAD")) or filesize < 12:
Expand Down

0 comments on commit 582da97

Please sign in to comment.