@@ -47,6 +47,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
4747#include <TextUtils.h>
4848#endif
4949#include <CodeFragments.h>
50+ #include <StringCompare.h>
5051
5152#ifdef USE_GUSI1
5253#include "TFileSpec.h" /* for Path2FSSpec() */
@@ -55,6 +56,13 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
5556typedef void (* dl_funcptr )();
5657#define FUNCNAME_PATTERN "init%.200s"
5758
59+ static int
60+ fssequal (FSSpec * fs1 , FSSpec * fs2 )
61+ {
62+ if ( fs1 -> vRefNum != fs2 -> vRefNum || fs1 -> parID != fs2 -> parID )
63+ return 0 ;
64+ return EqualString (fs1 -> name , fs2 -> name , false, true);
65+ }
5866/*
5967** findnamedresource - Common code for the various *ResourceModule functions.
6068** Check whether a file contains a resource of the correct name and type, and
@@ -93,8 +101,19 @@ findnamedresource(
93101 return 0 ;
94102 }
95103#endif /* INTERN_STRINGS */
96-
97- if ( strcmp (filename , PyMac_ApplicationPath ) == 0 ) {
104+ #ifdef USE_GUSI1
105+ if ( Path2FSSpec (filename , & fss ) != noErr ) {
106+ #else
107+ if ( FSMakeFSSpec (0 , 0 , Pstring (filename ), & fss ) != noErr ) {
108+ #endif
109+ #ifdef INTERN_STRINGS
110+ if ( obj && max_not_a_file < MAXPATHCOMPONENTS && obj -> ob_sinterned )
111+ not_a_file [max_not_a_file ++ ] = obj ;
112+ #endif /* INTERN_STRINGS */
113+ /* doesn't exist or is folder */
114+ return 0 ;
115+ }
116+ if ( fssequal (& fss , & PyMac_ApplicationFSSpec ) ) {
98117 /*
99118 ** Special case: the application itself. Use a shortcut to
100119 ** forestall opening and closing the application numerous times
@@ -104,19 +123,14 @@ findnamedresource(
104123 UseResFile (PyMac_AppRefNum );
105124 filerh = -1 ;
106125 } else {
107- #ifdef USE_GUSI1
108- if ( Path2FSSpec (filename , & fss ) != noErr ||
109- #else
110- if ( FSMakeFSSpec (0 , 0 , Pstring (filename ), & fss ) != noErr ||
111- #endif
112- FSpGetFInfo (& fss , & finfo ) != noErr ) {
113126#ifdef INTERN_STRINGS
127+ if ( FSpGetFInfo (& fss , & finfo ) != noErr ) {
114128 if ( obj && max_not_a_file < MAXPATHCOMPONENTS && obj -> ob_sinterned )
115129 not_a_file [max_not_a_file ++ ] = obj ;
116- #endif /* INTERN_STRINGS */
117- /* doesn't exist or is folder */
130+ /* doesn't exist or is folder */
118131 return 0 ;
119132 }
133+ #endif /* INTERN_STRINGS */
120134 oldrh = CurResFile ();
121135 filerh = FSpOpenResFile (& fss , fsRdPerm );
122136 if ( filerh == -1 )
@@ -293,7 +307,14 @@ char *filename;
293307 PyObject * m , * co ;
294308 long num , size ;
295309
296- if ( strcmp (filename , PyMac_ApplicationPath ) == 0 ) {
310+ #ifdef USE_GUSI1
311+ if ( (err = Path2FSSpec (filename , & fss )) != noErr ||
312+ FSpGetFInfo (& fss , & finfo ) != noErr )
313+ #else
314+ if ( (err = FSMakeFSSpec (0 , 0 , Pstring (filename ), & fss )) != noErr )
315+ #endif
316+ goto error ;
317+ if ( fssequal (& fss , & PyMac_ApplicationFSSpec ) ) {
297318 /*
298319 ** Special case: the application itself. Use a shortcut to
299320 ** forestall opening and closing the application numerous times
@@ -303,13 +324,6 @@ char *filename;
303324 UseResFile (PyMac_AppRefNum );
304325 filerh = -1 ;
305326 } else {
306- #ifdef USE_GUSI1
307- if ( (err = Path2FSSpec (filename , & fss )) != noErr ||
308- FSpGetFInfo (& fss , & finfo ) != noErr )
309- #else
310- if ( (err = FSMakeFSSpec (0 , 0 , Pstring (filename ), & fss )) != noErr )
311- #endif
312- goto error ;
313327 if ( (err = FSpGetFInfo (& fss , & finfo )) != noErr )
314328 goto error ;
315329 oldrh = CurResFile ();
0 commit comments