]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
If the file has no resource fork first check to see whether it's a
authorJack Jansen <jack.jansen@cwi.nl>
Fri, 29 Mar 2002 14:29:35 +0000 (14:29 +0000)
committerJack Jansen <jack.jansen@cwi.nl>
Fri, 29 Mar 2002 14:29:35 +0000 (14:29 +0000)
datafork-based resource file before trying to decode it as AppleSingle.

Mac/Lib/macresource.py

index 4bd40bcca9d90715374407c5c91e8b12943b1458..4eaf0762af336fa1e4695e258defbd972f7f6661 100644 (file)
@@ -77,13 +77,20 @@ def open_pathname(pathname):
                refno = Res.FSpOpenResFile(pathname, 1)
        except Res.Error, arg:
                if arg[0] in (-37, -39):
-                       # No resource fork. We may be on OSX, try to decode
-                       # the applesingle file.
-                       pathname = _decode(pathname)
-                       if pathname:
+                       # No resource fork. We may be on OSX, and this may be either
+                       # a data-fork based resource file or a AppleSingle file
+                       # from the CVS repository.
+                       try:
                                refno = Res.FSOpenResourceFile(pathname, u'', 1)
+                       except Res.Error, arg:
+                               if arg[0] != -199:
+                                       # -199 is "bad resource map"
+                                       raise
                        else:
-                               raise
+                               return refno
+                       # Finally try decoding an AppleSingle file
+                       pathname = _decode(pathname)
+                       refno = Res.FSOpenResourceFile(pathname, u'', 1)
        return refno
        
 def _decode(pathname):