]> granicus.if.org Git - python/commitdiff
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
authorJack Jansen <jack.jansen@cwi.nl>
Sat, 19 May 2001 12:55:57 +0000 (12:55 +0000)
committerJack Jansen <jack.jansen@cwi.nl>
Sat, 19 May 2001 12:55:57 +0000 (12:55 +0000)
have been there in the first place.

Mac/Python/macgetargv.c
Mac/Python/macglue.c

index bef197ca5ba9870fec6e48f353fe26276ca7bf7d..bc5bbd56fe7b418bf5a737b9d2131097401a1535 100644 (file)
@@ -108,46 +108,6 @@ get_folder_parent (FSSpec * fss, FSSpec * parent)
         return 0;
 }
 
-/* Given an FSSpec return a full, colon-separated pathname */
-
-OSErr
-PyMac_GetFullPath (FSSpec *fss, char *buf)
-{
-       short err;
-       FSSpec fss_parent, fss_current;
-       char tmpbuf[1024];
-       int plen;
-
-       fss_current = *fss;
-       plen = fss_current.name[0];
-       memcpy(buf, &fss_current.name[1], plen);
-       buf[plen] = 0;
-       /* Special case for disk names */
-       if ( fss_current.parID <= 1 ) {
-               buf[plen++] = ':';
-               buf[plen] = 0;
-               return 0;
-       }
-       while (fss_current.parID > 1) {
-               /* Get parent folder name */
-                if (err = get_folder_parent(&fss_current, &fss_parent))
-                       return err;
-                fss_current = fss_parent;
-                /* Prepend path component just found to buf */
-                       plen = fss_current.name[0];
-                       if (strlen(buf) + plen + 1 > 1024) {
-                               /* Oops... Not enough space (shouldn't happen) */
-                               *buf = 0;
-                               return -1;
-                       }
-                       memcpy(tmpbuf, &fss_current.name[1], plen);
-                       tmpbuf[plen] = ':';
-                       strcpy(&tmpbuf[plen+1], buf);
-                       strcpy(buf, tmpbuf);
-        }
-        return 0;
-}
-
 /* Check that there aren't any args remaining in the event */
 
 static OSErr 
index bf5e3487b4444fa494e56f9adfe3aef92e4532e0..9df41fbf1e84cb359cf5e7223123f4dcc1b88294 100644 (file)
@@ -232,6 +232,66 @@ char *PyMac_getscript()
     }
 }
 
+/* Given an FSSpec, return the FSSpec of the parent folder */
+
+static OSErr
+get_folder_parent (FSSpec * fss, FSSpec * parent)
+{
+       CInfoPBRec rec;
+       short err;
+
+        * parent = * fss;
+        rec.hFileInfo.ioNamePtr = parent->name;
+        rec.hFileInfo.ioVRefNum = parent->vRefNum;
+        rec.hFileInfo.ioDirID = parent->parID;
+               rec.hFileInfo.ioFDirIndex = -1;
+        rec.hFileInfo.ioFVersNum = 0;
+        if (err = PBGetCatInfoSync (& rec))
+               return err;
+        parent->parID = rec.dirInfo.ioDrParID;
+/*     parent->name[0] = 0; */
+        return 0;
+}
+
+/* Given an FSSpec return a full, colon-separated pathname */
+
+OSErr
+PyMac_GetFullPath (FSSpec *fss, char *buf)
+{
+       short err;
+       FSSpec fss_parent, fss_current;
+       char tmpbuf[1024];
+       int plen;
+
+       fss_current = *fss;
+       plen = fss_current.name[0];
+       memcpy(buf, &fss_current.name[1], plen);
+       buf[plen] = 0;
+       /* Special case for disk names */
+       if ( fss_current.parID <= 1 ) {
+               buf[plen++] = ':';
+               buf[plen] = 0;
+               return 0;
+       }
+       while (fss_current.parID > 1) {
+               /* Get parent folder name */
+                if (err = get_folder_parent(&fss_current, &fss_parent))
+                       return err;
+                fss_current = fss_parent;
+                /* Prepend path component just found to buf */
+                       plen = fss_current.name[0];
+                       if (strlen(buf) + plen + 1 > 1024) {
+                               /* Oops... Not enough space (shouldn't happen) */
+                               *buf = 0;
+                               return -1;
+                       }
+                       memcpy(tmpbuf, &fss_current.name[1], plen);
+                       tmpbuf[plen] = ':';
+                       strcpy(&tmpbuf[plen+1], buf);
+                       strcpy(buf, tmpbuf);
+        }
+        return 0;
+}
 
 #ifdef USE_GUSI1
 /*