]> granicus.if.org Git - python/commitdiff
Mac-specific mod to enable aliases on import paths.
authorGuido van Rossum <guido@python.org>
Mon, 14 Sep 1998 13:40:53 +0000 (13:40 +0000)
committerGuido van Rossum <guido@python.org>
Mon, 14 Sep 1998 13:40:53 +0000 (13:40 +0000)
(Jack Jansen and/or Just van Rossum)

Python/import.c
Python/importdl.c

index 7099d1b92b4a195d111c304342a3355c413342fb..5c8d9399794d59c241eba7e76f69452fa3333046 100644 (file)
@@ -1055,27 +1055,44 @@ check_case(char *buf, int len, int namelen, char *name)
 
 #ifdef macintosh
 #include <TextUtils.h>
+#ifdef USE_GUSI
+#include "TFileSpec.h"         /* for Path2FSSpec() */
+#endif
 static int
 check_case(char *buf, int len, int namelen, char *name)
 {
        FSSpec fss;
        OSErr err;
-       unsigned char mybuf[MAXPATHLEN+1];
-       
-       strcpy((char *)mybuf, buf);
-       c2pstr((char *)mybuf);
-       err = FSMakeFSSpec(0, 0, mybuf, &fss);
+#ifndef USE_GUSI
+       err = FSMakeFSSpec(0, 0, Pstring(buf), &fss);
+#else
+       /* GUSI's Path2FSSpec() resolves all possible aliases nicely on
+          the way, which is fine for all directories, but here we need
+          the original name of the alias file (say, Dlg.ppc.slb, not
+          toolboxmodules.ppc.slb). */
+       char *colon;
+       err = Path2FSSpec(buf, &fss);
+       if (err == noErr) {
+               colon = strrchr(buf, ':'); /* find filename */
+               if (colon != NULL)
+                       err = FSMakeFSSpec(fss.vRefNum, fss.parID,
+                                          Pstring(colon+1), &fss);
+               else
+                       err = FSMakeFSSpec(fss.vRefNum, fss.parID,
+                                          fss.name, &fss);
+       }
+#endif
        if (err) {
                PyErr_Format(PyExc_NameError,
-                 "Can't find file for module %.100s\n(filename %.300s)",
-                 name, buf);
+                    "Can't find file for module %.100s\n(filename %.300s)",
+                    name, buf);
                return 0;
        }
        p2cstr(fss.name);
        if ( strncmp(name, (char *)fss.name, namelen) != 0 ) {
                PyErr_Format(PyExc_NameError,
-                 "Case mismatch for module name %.100s\n(filename %.300s)",
-                 name, fss.name);
+                    "Case mismatch for module name %.100s\n(filename %.300s)",
+                    name, fss.name);
                return 0;
        }
        return 1;
index ef015ad2ecd48ee8e30bc74073667c81444cde4a..774b7b37a768523720dbc7e2e6147e4351196af9 100644 (file)
@@ -249,6 +249,9 @@ typedef void (*dl_funcptr)();
 #define CFragConnectionID ConnectionID
 #define kLoadCFrag 0x01
 #endif
+#ifdef USE_GUSI
+#include "TFileSpec.h"         /* for Path2FSSpec() */
+#endif
 #include <Files.h>
 #include "macdefs.h"
 #include "macglue.h"
@@ -372,15 +375,21 @@ _PyImport_LoadDynamicModule(name, pathname, fp)
                Ptr mainAddr;
                Str255 errMessage;
                OSErr err;
+#ifndef USE_GUSI
                Boolean isfolder, didsomething;
+#endif
                char buf[512];
                Str63 fragname;
                Ptr symAddr;
                CFragSymbolClass class;
                
                /* First resolve any aliases to find the real file */
+#ifdef USE_GUSI
+               err = Path2FSSpec(pathname, &libspec);
+#else
                (void)FSMakeFSSpec(0, 0, Pstring(pathname), &libspec);
                err = ResolveAliasFile(&libspec, 1, &isfolder, &didsomething);
+#endif
                if ( err ) {
                        sprintf(buf, "%.255s: %.200s",
                                pathname, PyMac_StrError(err));