summaryrefslogtreecommitdiffstats
path: root/Mac/Modules
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>2003-01-26 20:22:41 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>2003-01-26 20:22:41 (GMT)
commit2b3ce3ba3f6f3fa688cb9e38de640e8cb15c4095 (patch)
treebf618e9fd5a4a471f3137ef6890023b0bf4d50a1 /Mac/Modules
parent57c115c8ad3d1827b8fb40b864cbd3a77f7e791e (diff)
downloadcpython-2b3ce3ba3f6f3fa688cb9e38de640e8cb15c4095.zip
cpython-2b3ce3ba3f6f3fa688cb9e38de640e8cb15c4095.tar.gz
cpython-2b3ce3ba3f6f3fa688cb9e38de640e8cb15c4095.tar.bz2
FSRef and EasyDialogs pathname support was pretty much broken in MacPython-OS9. Fixed.
Diffstat (limited to 'Mac/Modules')
-rw-r--r--Mac/Modules/file/_Filemodule.c27
-rw-r--r--Mac/Modules/file/filesupport.py27
2 files changed, 52 insertions, 2 deletions
diff --git a/Mac/Modules/file/_Filemodule.c b/Mac/Modules/file/_Filemodule.c
index 5d3901f..8309b35 100644
--- a/Mac/Modules/file/_Filemodule.c
+++ b/Mac/Modules/file/_Filemodule.c
@@ -1840,7 +1840,26 @@ static PyObject *FSRef_as_pathname(FSRefObject *_self, PyObject *_args)
{
PyObject *_res = NULL;
+#if TARGET_API_MAC_OSX
+ if (!PyArg_ParseTuple(_args, ""))
+ return NULL;
_res = FSRef_FSRefMakePath(_self, _args);
+#else
+ char strbuf[1024];
+ OSErr err;
+ FSSpec fss;
+
+ if (!PyArg_ParseTuple(_args, ""))
+ return NULL;
+ if ( !PyMac_GetFSSpec((PyObject *)_self, &fss))
+ return NULL;
+ err = PyMac_GetFullPathname(&fss, strbuf, sizeof(strbuf));
+ if ( err ) {
+ PyMac_Error(err);
+ return NULL;
+ }
+ _res = PyString_FromString(strbuf);
+#endif
return _res;
}
@@ -3190,6 +3209,7 @@ int
PyMac_GetFSRef(PyObject *v, FSRef *fsr)
{
OSStatus err;
+ FSSpec fss;
if (FSRef_Check(v)) {
*fsr = ((FSRefObject *)v)->ob_itself;
@@ -3208,8 +3228,13 @@ PyMac_GetFSRef(PyObject *v, FSRef *fsr)
/* XXXX Should try unicode here too */
#endif
/* Otherwise we try to go via an FSSpec */
+#if TARGET_API_MAC_OSX
if (FSSpec_Check(v)) {
- if ((err=FSpMakeFSRef(&((FSSpecObject *)v)->ob_itself, fsr)) == 0)
+ fss = ((FSSpecObject *)v)->ob_itself;
+#else
+ if (PyMac_GetFSSpec(v, &fss)) {
+#endif
+ if ((err=FSpMakeFSRef(&fss, fsr)) == 0)
return 1;
PyMac_Error(err);
return 0;
diff --git a/Mac/Modules/file/filesupport.py b/Mac/Modules/file/filesupport.py
index b7df7eb..26821dd 100644
--- a/Mac/Modules/file/filesupport.py
+++ b/Mac/Modules/file/filesupport.py
@@ -271,6 +271,7 @@ int
PyMac_GetFSRef(PyObject *v, FSRef *fsr)
{
OSStatus err;
+ FSSpec fss;
if (FSRef_Check(v)) {
*fsr = ((FSRefObject *)v)->ob_itself;
@@ -289,8 +290,13 @@ PyMac_GetFSRef(PyObject *v, FSRef *fsr)
/* XXXX Should try unicode here too */
#endif
/* Otherwise we try to go via an FSSpec */
+#if TARGET_API_MAC_OSX
if (FSSpec_Check(v)) {
- if ((err=FSpMakeFSRef(&((FSSpecObject *)v)->ob_itself, fsr)) == 0)
+ fss = ((FSSpecObject *)v)->ob_itself;
+#else
+ if (PyMac_GetFSSpec(v, &fss)) {
+#endif
+ if ((err=FSpMakeFSRef(&fss, fsr)) == 0)
return 1;
PyMac_Error(err);
return 0;
@@ -808,7 +814,26 @@ f.docstring = lambda: "() -> string"
fsref_methods.append(f)
FSRef_as_pathname_body = """
+#if TARGET_API_MAC_OSX
+if (!PyArg_ParseTuple(_args, ""))
+ return NULL;
_res = FSRef_FSRefMakePath(_self, _args);
+#else
+char strbuf[1024];
+OSErr err;
+FSSpec fss;
+
+if (!PyArg_ParseTuple(_args, ""))
+ return NULL;
+if ( !PyMac_GetFSSpec((PyObject *)_self, &fss))
+ return NULL;
+err = PyMac_GetFullPathname(&fss, strbuf, sizeof(strbuf));
+if ( err ) {
+ PyMac_Error(err);
+ return NULL;
+}
+_res = PyString_FromString(strbuf);
+#endif
return _res;
"""
f = ManualGenerator("as_pathname", FSRef_as_pathname_body)