summaryrefslogtreecommitdiffstats
path: root/Mac
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>2002-02-24 22:55:34 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>2002-02-24 22:55:34 (GMT)
commitfe48a915962ad2f3c6068e72718efcb5eda4a832 (patch)
tree551287abff3503e11c9afbe32470f3c91906d3cd /Mac
parentad48e32cbcab0459e9a07b5ed54b350519f27dc7 (diff)
downloadcpython-fe48a915962ad2f3c6068e72718efcb5eda4a832.zip
cpython-fe48a915962ad2f3c6068e72718efcb5eda4a832.tar.gz
cpython-fe48a915962ad2f3c6068e72718efcb5eda4a832.tar.bz2
backport of 1.52 and 1.53:
- Added as_pathname() method to FSRef objects. - In MachoPython expect Unix-style pathnames for both FSSpec and FSRef initializers.
Diffstat (limited to 'Mac')
-rw-r--r--Mac/Modules/macfsmodule.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/Mac/Modules/macfsmodule.c b/Mac/Modules/macfsmodule.c
index 6dba578..b00f5dd 100644
--- a/Mac/Modules/macfsmodule.c
+++ b/Mac/Modules/macfsmodule.c
@@ -773,10 +773,26 @@ mfsr_as_fsspec(mfsrobject *self, PyObject *args)
return (PyObject *)newmfssobject(&fss);
}
+static PyObject *
+mfsr_as_pathname(mfsrobject *self, PyObject *args)
+{
+ char strbuf[PATHNAMELEN];
+ OSStatus err;
+
+ if (!PyArg_ParseTuple(args, ""))
+ return NULL;
+ err = FSRefMakePath(&self->fsref, strbuf, PATHNAMELEN);
+ if ( err ) {
+ PyErr_Mac(ErrorObject, err);
+ return NULL;
+ }
+ return PyString_FromString(strbuf);
+}
+
static struct PyMethodDef mfsr_methods[] = {
{"as_fsspec", (PyCFunction)mfsr_as_fsspec, 1},
+ {"as_pathname", (PyCFunction)mfsr_as_pathname, 1},
#if 0
- {"as_pathname", (PyCFunction)mfss_as_pathname, 1},
{"as_tuple", (PyCFunction)mfss_as_tuple, 1},
{"NewAlias", (PyCFunction)mfss_NewAlias, 1},
{"NewAliasMinimal", (PyCFunction)mfss_NewAliasMinimal, 1},
@@ -1189,11 +1205,21 @@ PyMac_GetFSSpec(PyObject *v, FSSpec *fs)
if (_mfs_GetFSSpecFromFSRef(v, fs))
return 1;
if ( PyString_Check(v) ) {
+#if TARGET_API_MAC_OSX
+ FSRef fsr;
+
+ if ( !PyMac_GetFSRef(v, &fsr) )
+ return 0;
+ if ( FSGetCatalogInfo(&fsr, kFSCatInfoNone, NULL, NULL, fs, NULL) == noErr )
+ return 1;
+ return 0;
+#else
/* It's a pathname */
if( !PyArg_Parse(v, "O&", PyMac_GetStr255, &path) )
return 0;
refnum = 0; /* XXXX Should get CurWD here?? */
parid = 0;
+#endif
} else {
if( !PyArg_Parse(v, "(hlO&); FSSpec should be FSSpec, FSRef, fullpath or (vrefnum,dirid,path)",
&refnum, &parid, PyMac_GetStr255, &path)) {