summaryrefslogtreecommitdiffstats
path: root/Mac
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>2001-05-19 12:55:57 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>2001-05-19 12:55:57 (GMT)
commit741e0378e44567c76d268c755851446aa641fcfe (patch)
tree5e013bbfec4ac8c8593951c1ec6c98ade1a02f6f /Mac
parentf3163303a98d4c384fa97a949dbe77cc700ab3cd (diff)
downloadcpython-741e0378e44567c76d268c755851446aa641fcfe.zip
cpython-741e0378e44567c76d268c755851446aa641fcfe.tar.gz
cpython-741e0378e44567c76d268c755851446aa641fcfe.tar.bz2
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
have been there in the first place.
Diffstat (limited to 'Mac')
-rw-r--r--Mac/Python/macgetargv.c40
-rw-r--r--Mac/Python/macglue.c60
2 files changed, 60 insertions, 40 deletions
diff --git a/Mac/Python/macgetargv.c b/Mac/Python/macgetargv.c
index bef197c..bc5bbd5 100644
--- a/Mac/Python/macgetargv.c
+++ b/Mac/Python/macgetargv.c
@@ -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
diff --git a/Mac/Python/macglue.c b/Mac/Python/macglue.c
index bf5e348..9df41fb 100644
--- a/Mac/Python/macglue.c
+++ b/Mac/Python/macglue.c
@@ -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
/*