Skip to content

Commit 5053b70

Browse files
committed
If the file has no resource fork first check to see whether it's a
datafork-based resource file before trying to decode it as AppleSingle.
1 parent 695b33b commit 5053b70

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

Mac/Lib/macresource.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,20 @@ def open_pathname(pathname):
7777
refno = Res.FSpOpenResFile(pathname, 1)
7878
except Res.Error, arg:
7979
if arg[0] in (-37, -39):
80-
# No resource fork. We may be on OSX, try to decode
81-
# the applesingle file.
82-
pathname = _decode(pathname)
83-
if pathname:
80+
# No resource fork. We may be on OSX, and this may be either
81+
# a data-fork based resource file or a AppleSingle file
82+
# from the CVS repository.
83+
try:
8484
refno = Res.FSOpenResourceFile(pathname, u'', 1)
85+
except Res.Error, arg:
86+
if arg[0] != -199:
87+
# -199 is "bad resource map"
88+
raise
8589
else:
86-
raise
90+
return refno
91+
# Finally try decoding an AppleSingle file
92+
pathname = _decode(pathname)
93+
refno = Res.FSOpenResourceFile(pathname, u'', 1)
8794
return refno
8895

8996
def _decode(pathname):

0 commit comments

Comments
 (0)