mirror of
https://github.com/kennethreitz-archive/python-build.git
synced 2026-06-05 23:30:18 +00:00
1235 lines
36 KiB
Diff
1235 lines
36 KiB
Diff
--- Include/pymactoolbox.h.orig 2004-11-05 18:02:59.000000000 +1100
|
|
+++ Include/pymactoolbox.h 2009-09-10 18:08:58.000000000 +1000
|
|
@@ -8,7 +8,9 @@
|
|
#endif
|
|
|
|
#include <Carbon/Carbon.h>
|
|
+#ifndef __LP64__
|
|
#include <QuickTime/QuickTime.h>
|
|
+#endif /* !__LP64__ */
|
|
|
|
/*
|
|
** Helper routines for error codes and such.
|
|
@@ -18,8 +20,10 @@
|
|
PyObject *PyMac_GetOSErrException(void); /* Initialize & return it */
|
|
PyObject *PyErr_Mac(PyObject *, int); /* Exception with a mac error */
|
|
PyObject *PyMac_Error(OSErr); /* Uses PyMac_GetOSErrException */
|
|
+#ifndef __LP64__
|
|
extern OSErr PyMac_GetFullPathname(FSSpec *, char *, int); /* convert
|
|
fsspec->path */
|
|
+#endif /* !__LP64__ */
|
|
/*
|
|
** These conversion routines are defined in mactoolboxglue.c itself.
|
|
*/
|
|
@@ -83,9 +87,10 @@
|
|
#endif /* USE_TOOLBOX_OBJECT_GLUE */
|
|
|
|
/* macfs exports */
|
|
+#ifndef __LP64__
|
|
int PyMac_GetFSSpec(PyObject *, FSSpec *); /* argument parser for FSSpec */
|
|
PyObject *PyMac_BuildFSSpec(FSSpec *); /* Convert FSSpec to PyObject */
|
|
-
|
|
+#endif /* !__LP64__ */
|
|
int PyMac_GetFSRef(PyObject *, FSRef *); /* argument parser for FSRef */
|
|
PyObject *PyMac_BuildFSRef(FSRef *); /* Convert FSRef to PyObject */
|
|
|
|
@@ -101,39 +106,54 @@
|
|
extern int CmpInstObj_Convert(PyObject *, ComponentInstance *);
|
|
|
|
/* Ctl exports */
|
|
+#ifndef __LP64__
|
|
extern PyObject *CtlObj_New(ControlHandle);
|
|
extern int CtlObj_Convert(PyObject *, ControlHandle *);
|
|
+#endif /* !__LP64__ */
|
|
|
|
/* Dlg exports */
|
|
+#ifndef __LP64__
|
|
extern PyObject *DlgObj_New(DialogPtr);
|
|
extern int DlgObj_Convert(PyObject *, DialogPtr *);
|
|
extern PyObject *DlgObj_WhichDialog(DialogPtr);
|
|
+#endif /* !__LP64__ */
|
|
|
|
/* Drag exports */
|
|
+#ifndef __LP64__
|
|
extern PyObject *DragObj_New(DragReference);
|
|
extern int DragObj_Convert(PyObject *, DragReference *);
|
|
+#endif /* !__LP64__ */
|
|
|
|
/* List exports */
|
|
+#ifndef __LP64__
|
|
extern PyObject *ListObj_New(ListHandle);
|
|
extern int ListObj_Convert(PyObject *, ListHandle *);
|
|
+#endif /* !__LP64__ */
|
|
|
|
/* Menu exports */
|
|
+#ifndef __LP64__
|
|
extern PyObject *MenuObj_New(MenuHandle);
|
|
extern int MenuObj_Convert(PyObject *, MenuHandle *);
|
|
+#endif /* !__LP64__ */
|
|
|
|
/* Qd exports */
|
|
+#ifndef __LP64__
|
|
extern PyObject *GrafObj_New(GrafPtr);
|
|
extern int GrafObj_Convert(PyObject *, GrafPtr *);
|
|
extern PyObject *BMObj_New(BitMapPtr);
|
|
extern int BMObj_Convert(PyObject *, BitMapPtr *);
|
|
extern PyObject *QdRGB_New(RGBColor *);
|
|
extern int QdRGB_Convert(PyObject *, RGBColor *);
|
|
+#endif /* !__LP64__ */
|
|
|
|
/* Qdoffs exports */
|
|
+#ifndef __LP64__
|
|
extern PyObject *GWorldObj_New(GWorldPtr);
|
|
extern int GWorldObj_Convert(PyObject *, GWorldPtr *);
|
|
+#endif /* !__LP64__ */
|
|
|
|
/* Qt exports */
|
|
+#ifndef __LP64__
|
|
extern PyObject *TrackObj_New(Track);
|
|
extern int TrackObj_Convert(PyObject *, Track *);
|
|
extern PyObject *MovieObj_New(Movie);
|
|
@@ -146,6 +166,7 @@
|
|
extern int UserDataObj_Convert(PyObject *, UserData *);
|
|
extern PyObject *MediaObj_New(Media);
|
|
extern int MediaObj_Convert(PyObject *, Media *);
|
|
+#endif /* !__LP64__ */
|
|
|
|
/* Res exports */
|
|
extern PyObject *ResObj_New(Handle);
|
|
@@ -154,13 +175,17 @@
|
|
extern int OptResObj_Convert(PyObject *, Handle *);
|
|
|
|
/* TE exports */
|
|
+#ifndef __LP64__
|
|
extern PyObject *TEObj_New(TEHandle);
|
|
extern int TEObj_Convert(PyObject *, TEHandle *);
|
|
+#endif /* !__LP64__ */
|
|
|
|
/* Win exports */
|
|
+#ifndef __LP64__
|
|
extern PyObject *WinObj_New(WindowPtr);
|
|
extern int WinObj_Convert(PyObject *, WindowPtr *);
|
|
extern PyObject *WinObj_WhichWindow(WindowPtr);
|
|
+#endif /* !__LP64__ */
|
|
|
|
/* CF exports */
|
|
extern PyObject *CFObj_New(CFTypeRef);
|
|
--- Python/mactoolboxglue.c.orig 2006-07-12 02:44:25.000000000 +1000
|
|
+++ Python/mactoolboxglue.c 2009-09-10 19:26:39.000000000 +1000
|
|
@@ -105,7 +105,7 @@
|
|
return PyErr_Mac(PyMac_GetOSErrException(), err);
|
|
}
|
|
|
|
-
|
|
+#ifndef __LP64__
|
|
OSErr
|
|
PyMac_GetFullPathname(FSSpec *fss, char *path, int len)
|
|
{
|
|
@@ -153,6 +153,7 @@
|
|
Py_XDECREF(fs);
|
|
return err;
|
|
}
|
|
+#endif /* !__LP64__ */
|
|
|
|
/* Convert a 4-char string object argument to an OSType value */
|
|
int
|
|
@@ -417,6 +418,7 @@
|
|
GLUE_NEW(GWorldPtr, GWorldObj_New, "Carbon.Qdoffs")
|
|
GLUE_CONVERT(GWorldPtr, GWorldObj_Convert, "Carbon.Qdoffs")
|
|
|
|
+#ifndef __LP64__
|
|
GLUE_NEW(Track, TrackObj_New, "Carbon.Qt")
|
|
GLUE_CONVERT(Track, TrackObj_Convert, "Carbon.Qt")
|
|
GLUE_NEW(Movie, MovieObj_New, "Carbon.Qt")
|
|
@@ -429,6 +431,7 @@
|
|
GLUE_CONVERT(UserData, UserDataObj_Convert, "Carbon.Qt")
|
|
GLUE_NEW(Media, MediaObj_New, "Carbon.Qt")
|
|
GLUE_CONVERT(Media, MediaObj_Convert, "Carbon.Qt")
|
|
+#endif /* !__LP64__ */
|
|
|
|
GLUE_NEW(Handle, ResObj_New, "Carbon.Res")
|
|
GLUE_CONVERT(Handle, ResObj_Convert, "Carbon.Res")
|
|
--- Modules/_ctypes/libffi/src/darwin/ffitarget.h.orig 2006-05-26 07:58:05.000000000 +1000
|
|
+++ Modules/_ctypes/libffi/src/darwin/ffitarget.h 2009-09-10 20:15:39.000000000 +1000
|
|
@@ -4,7 +4,7 @@
|
|
* created by configure). This makes is possible to build a univeral binary
|
|
* of ctypes in one go.
|
|
*/
|
|
-#if defined(__i386__)
|
|
+#if defined(__i386__) || defined(__x86_64__)
|
|
|
|
#ifndef X86_DARWIN
|
|
#define X86_DARWIN
|
|
@@ -13,7 +13,7 @@
|
|
|
|
#include "../src/x86/ffitarget.h"
|
|
|
|
-#elif defined(__ppc__)
|
|
+#elif defined(__ppc__) || defined(__ppc64__)
|
|
|
|
#ifndef POWERPC_DARWIN
|
|
#define POWERPC_DARWIN
|
|
--- Mac/Modules/res/_Resmodule.c.orig 2005-07-04 06:59:44.000000000 +1000
|
|
+++ Mac/Modules/res/_Resmodule.c 2009-09-10 20:44:43.000000000 +1000
|
|
@@ -414,6 +414,7 @@
|
|
return _res;
|
|
}
|
|
|
|
+#ifndef __LP64__
|
|
static PyObject *ResObj_as_Control(ResourceObject *_self, PyObject *_args)
|
|
{
|
|
PyObject *_res = NULL;
|
|
@@ -431,6 +432,7 @@
|
|
return _res;
|
|
|
|
}
|
|
+#endif /* !__LP64__ */
|
|
|
|
static PyObject *ResObj_LoadResource(ResourceObject *_self, PyObject *_args)
|
|
{
|
|
@@ -501,10 +503,12 @@
|
|
PyDoc_STR("(long newSize) -> None")},
|
|
{"GetNextFOND", (PyCFunction)ResObj_GetNextFOND, 1,
|
|
PyDoc_STR("() -> (Handle _rv)")},
|
|
+#ifndef __LP64__
|
|
{"as_Control", (PyCFunction)ResObj_as_Control, 1,
|
|
PyDoc_STR("Return this resource/handle as a Control")},
|
|
{"as_Menu", (PyCFunction)ResObj_as_Menu, 1,
|
|
PyDoc_STR("Return this resource/handle as a Menu")},
|
|
+#endif /* !__LP64__ */
|
|
{"LoadResource", (PyCFunction)ResObj_LoadResource, 1,
|
|
PyDoc_STR("() -> None")},
|
|
{"AutoDispose", (PyCFunction)ResObj_AutoDispose, 1,
|
|
@@ -1152,6 +1156,7 @@
|
|
return _res;
|
|
}
|
|
|
|
+#ifndef __LP64__
|
|
static PyObject *Res_OpenRFPerm(PyObject *_self, PyObject *_args)
|
|
{
|
|
PyObject *_res = NULL;
|
|
@@ -1287,6 +1292,7 @@
|
|
_res = Py_None;
|
|
return _res;
|
|
}
|
|
+#endif /* !__LP64__ */
|
|
|
|
static PyObject *Res_InsertResourceFile(PyObject *_self, PyObject *_args)
|
|
{
|
|
@@ -1327,6 +1333,7 @@
|
|
return _res;
|
|
}
|
|
|
|
+#ifndef __LP64__
|
|
static PyObject *Res_FSpResourceFileAlreadyOpen(PyObject *_self, PyObject *_args)
|
|
{
|
|
PyObject *_res = NULL;
|
|
@@ -1413,6 +1420,7 @@
|
|
nextRefNum);
|
|
return _res;
|
|
}
|
|
+#endif /* !__LP64__ */
|
|
|
|
static PyObject *Res_FSOpenResFile(PyObject *_self, PyObject *_args)
|
|
{
|
|
@@ -1438,6 +1446,7 @@
|
|
return _res;
|
|
}
|
|
|
|
+#ifndef __LP64__
|
|
static PyObject *Res_FSCreateResFile(PyObject *_self, PyObject *_args)
|
|
{
|
|
PyObject *_res = NULL;
|
|
@@ -1534,6 +1543,7 @@
|
|
PyMac_BuildFSSpec, &newSpec);
|
|
return _res;
|
|
}
|
|
+#endif /* !__LP64__ */
|
|
|
|
static PyObject *Res_FSOpenResourceFile(PyObject *_self, PyObject *_args)
|
|
{
|
|
@@ -1637,6 +1647,7 @@
|
|
PyDoc_STR("(short refNum) -> (short _rv)")},
|
|
{"SetResFileAttrs", (PyCFunction)Res_SetResFileAttrs, 1,
|
|
PyDoc_STR("(short refNum, short attrs) -> None")},
|
|
+#ifndef __LP64__
|
|
{"OpenRFPerm", (PyCFunction)Res_OpenRFPerm, 1,
|
|
PyDoc_STR("(Str255 fileName, short vRefNum, SignedByte permission) -> (short _rv)")},
|
|
{"HOpenResFile", (PyCFunction)Res_HOpenResFile, 1,
|
|
@@ -1647,10 +1658,12 @@
|
|
PyDoc_STR("(FSSpec spec, SignedByte permission) -> (short _rv)")},
|
|
{"FSpCreateResFile", (PyCFunction)Res_FSpCreateResFile, 1,
|
|
PyDoc_STR("(FSSpec spec, OSType creator, OSType fileType, ScriptCode scriptTag) -> None")},
|
|
+#endif /* !__LP64__ */
|
|
{"InsertResourceFile", (PyCFunction)Res_InsertResourceFile, 1,
|
|
PyDoc_STR("(SInt16 refNum, RsrcChainLocation where) -> None")},
|
|
{"DetachResourceFile", (PyCFunction)Res_DetachResourceFile, 1,
|
|
PyDoc_STR("(SInt16 refNum) -> None")},
|
|
+#ifndef __LP64__
|
|
{"FSpResourceFileAlreadyOpen", (PyCFunction)Res_FSpResourceFileAlreadyOpen, 1,
|
|
PyDoc_STR("(FSSpec resourceFile) -> (Boolean _rv, Boolean inChain, SInt16 refNum)")},
|
|
{"FSpOpenOrphanResFile", (PyCFunction)Res_FSpOpenOrphanResFile, 1,
|
|
@@ -1659,14 +1672,17 @@
|
|
PyDoc_STR("() -> (SInt16 refNum)")},
|
|
{"GetNextResourceFile", (PyCFunction)Res_GetNextResourceFile, 1,
|
|
PyDoc_STR("(SInt16 curRefNum) -> (SInt16 nextRefNum)")},
|
|
+#endif /* !__LP64__ */
|
|
{"FSOpenResFile", (PyCFunction)Res_FSOpenResFile, 1,
|
|
PyDoc_STR("(FSRef ref, SignedByte permission) -> (short _rv)")},
|
|
+#ifndef __LP64__
|
|
{"FSCreateResFile", (PyCFunction)Res_FSCreateResFile, 1,
|
|
PyDoc_STR("(FSRef parentRef, Buffer nameLength) -> (FSRef newRef, FSSpec newSpec)")},
|
|
{"FSResourceFileAlreadyOpen", (PyCFunction)Res_FSResourceFileAlreadyOpen, 1,
|
|
PyDoc_STR("(FSRef resourceFileRef) -> (Boolean _rv, Boolean inChain, SInt16 refNum)")},
|
|
{"FSCreateResourceFile", (PyCFunction)Res_FSCreateResourceFile, 1,
|
|
PyDoc_STR("(FSRef parentRef, Buffer nameLength, Buffer forkNameLength) -> (FSRef newRef, FSSpec newSpec)")},
|
|
+#endif /* !__LP64__ */
|
|
{"FSOpenResourceFile", (PyCFunction)Res_FSOpenResourceFile, 1,
|
|
PyDoc_STR("(FSRef ref, Buffer forkNameLength, SignedByte permissions) -> (SInt16 refNum)")},
|
|
{"Handle", (PyCFunction)Res_Handle, 1,
|
|
--- Mac/Modules/MacOS.c.orig 2006-07-26 05:20:54.000000000 +1000
|
|
+++ Mac/Modules/MacOS.c 2009-09-10 21:47:34.000000000 +1000
|
|
@@ -54,7 +54,7 @@
|
|
do_close(rfobject *self)
|
|
{
|
|
if (self->isclosed ) return;
|
|
- (void)FSClose(self->fRefNum);
|
|
+ (void)FSCloseFork(self->fRefNum);
|
|
self->isclosed = 1;
|
|
}
|
|
|
|
@@ -68,6 +68,7 @@
|
|
long n;
|
|
PyObject *v;
|
|
OSErr err;
|
|
+ ByteCount n2;
|
|
|
|
if (self->isclosed) {
|
|
PyErr_SetString(PyExc_ValueError, "Operation on closed file");
|
|
@@ -81,13 +82,13 @@
|
|
if (v == NULL)
|
|
return NULL;
|
|
|
|
- err = FSRead(self->fRefNum, &n, PyString_AsString(v));
|
|
+ err = FSReadFork(self->fRefNum, fsAtMark, 0, n, PyString_AsString(v), &n2);
|
|
if (err && err != eofErr) {
|
|
PyMac_Error(err);
|
|
Py_DECREF(v);
|
|
return NULL;
|
|
}
|
|
- _PyString_Resize(&v, n);
|
|
+ _PyString_Resize(&v, n2);
|
|
return v;
|
|
}
|
|
|
|
@@ -109,7 +110,7 @@
|
|
}
|
|
if (!PyArg_ParseTuple(args, "s#", &buffer, &size))
|
|
return NULL;
|
|
- err = FSWrite(self->fRefNum, &size, buffer);
|
|
+ err = FSWriteFork(self->fRefNum, fsAtMark, 0, size, buffer, NULL);
|
|
if (err) {
|
|
PyMac_Error(err);
|
|
return NULL;
|
|
@@ -126,9 +127,9 @@
|
|
static PyObject *
|
|
rf_seek(rfobject *self, PyObject *args)
|
|
{
|
|
- long amount, pos;
|
|
+ long amount;
|
|
int whence = SEEK_SET;
|
|
- long eof;
|
|
+ int mode;
|
|
OSErr err;
|
|
|
|
if (self->isclosed) {
|
|
@@ -138,35 +139,23 @@
|
|
if (!PyArg_ParseTuple(args, "l|i", &amount, &whence))
|
|
return NULL;
|
|
|
|
- if ((err = GetEOF(self->fRefNum, &eof)))
|
|
- goto ioerr;
|
|
-
|
|
switch (whence) {
|
|
case SEEK_CUR:
|
|
- if ((err = GetFPos(self->fRefNum, &pos)))
|
|
- goto ioerr;
|
|
+ mode = fsFromMark;
|
|
break;
|
|
case SEEK_END:
|
|
- pos = eof;
|
|
+ mode = fsFromLEOF;
|
|
break;
|
|
case SEEK_SET:
|
|
- pos = 0;
|
|
+ mode = fsFromStart;
|
|
break;
|
|
default:
|
|
PyErr_BadArgument();
|
|
return NULL;
|
|
}
|
|
|
|
- pos += amount;
|
|
-
|
|
- /* Don't bother implementing seek past EOF */
|
|
- if (pos > eof || pos < 0) {
|
|
- PyErr_BadArgument();
|
|
- return NULL;
|
|
- }
|
|
-
|
|
- if ((err = SetFPos(self->fRefNum, fsFromStart, pos)) ) {
|
|
-ioerr:
|
|
+ err = FSSetForkPosition(self->fRefNum, mode, amount);
|
|
+ if (err != noErr) {
|
|
PyMac_Error(err);
|
|
return NULL;
|
|
}
|
|
@@ -182,7 +171,7 @@
|
|
static PyObject *
|
|
rf_tell(rfobject *self, PyObject *args)
|
|
{
|
|
- long where;
|
|
+ long long where;
|
|
OSErr err;
|
|
|
|
if (self->isclosed) {
|
|
@@ -191,11 +180,13 @@
|
|
}
|
|
if (!PyArg_ParseTuple(args, ""))
|
|
return NULL;
|
|
- if ((err = GetFPos(self->fRefNum, &where)) ) {
|
|
+
|
|
+ err = FSGetForkPosition(self->fRefNum, &where);
|
|
+ if (err != noErr) {
|
|
PyMac_Error(err);
|
|
return NULL;
|
|
}
|
|
- return PyInt_FromLong(where);
|
|
+ return PyLong_FromLongLong(where);
|
|
}
|
|
|
|
static char rf_close__doc__[] =
|
|
@@ -292,17 +283,61 @@
|
|
static PyObject *
|
|
MacOS_GetCreatorAndType(PyObject *self, PyObject *args)
|
|
{
|
|
- FSSpec fss;
|
|
- FInfo info;
|
|
PyObject *creator, *type, *res;
|
|
OSErr err;
|
|
-
|
|
- if (!PyArg_ParseTuple(args, "O&", PyMac_GetFSSpec, &fss))
|
|
+ FSRef ref;
|
|
+ FSCatalogInfo cataloginfo;
|
|
+ FileInfo* finfo;
|
|
+
|
|
+ if (!PyArg_ParseTuple(args, "O&", PyMac_GetFSRef, &ref)) {
|
|
+#ifndef __LP64__
|
|
+ /* This function is documented to take an FSSpec as well,
|
|
+ * which only works in 32-bit mode.
|
|
+ */
|
|
+ PyErr_Clear();
|
|
+ FSSpec fss;
|
|
+ FInfo info;
|
|
+
|
|
+ if (!PyArg_ParseTuple(args, "O&", PyMac_GetFSSpec, &fss))
|
|
+ return NULL;
|
|
+
|
|
+ if ((err = FSpGetFInfo(&fss, &info)) != noErr) {
|
|
+ return PyErr_Mac(MacOS_Error, err);
|
|
+ }
|
|
+ creator = PyString_FromStringAndSize(
|
|
+ (char *)&info.fdCreator, 4);
|
|
+ type = PyString_FromStringAndSize((char *)&info.fdType, 4);
|
|
+ res = Py_BuildValue("OO", creator, type);
|
|
+ Py_DECREF(creator);
|
|
+ Py_DECREF(type);
|
|
+ return res;
|
|
+#else /* __LP64__ */
|
|
+ return NULL;
|
|
+#endif /* __LP64__ */
|
|
+ }
|
|
+
|
|
+ err = FSGetCatalogInfo(&ref,
|
|
+ kFSCatInfoFinderInfo|kFSCatInfoNodeFlags, &cataloginfo,
|
|
+ NULL, NULL, NULL);
|
|
+ if (err != noErr) {
|
|
+ PyErr_Mac(MacOS_Error, err);
|
|
return NULL;
|
|
- if ((err = FSpGetFInfo(&fss, &info)) != noErr)
|
|
- return PyErr_Mac(MacOS_Error, err);
|
|
- creator = PyString_FromStringAndSize((char *)&info.fdCreator, 4);
|
|
- type = PyString_FromStringAndSize((char *)&info.fdType, 4);
|
|
+ }
|
|
+
|
|
+ if ((cataloginfo.nodeFlags & kFSNodeIsDirectoryMask) != 0) {
|
|
+ /* Directory: doesn't have type/creator info.
|
|
+ *
|
|
+ * The specific error code is for backward compatibility with
|
|
+ * earlier versions.
|
|
+ */
|
|
+ PyErr_Mac(MacOS_Error, fnfErr);
|
|
+ return NULL;
|
|
+
|
|
+ }
|
|
+ finfo = (FileInfo*)&(cataloginfo.finderInfo);
|
|
+ creator = PyString_FromStringAndSize((char*)&(finfo->fileCreator), 4);
|
|
+ type = PyString_FromStringAndSize((char*)&(finfo->fileType), 4);
|
|
+
|
|
res = Py_BuildValue("OO", creator, type);
|
|
Py_DECREF(creator);
|
|
Py_DECREF(type);
|
|
@@ -314,20 +349,66 @@
|
|
static PyObject *
|
|
MacOS_SetCreatorAndType(PyObject *self, PyObject *args)
|
|
{
|
|
- FSSpec fss;
|
|
ResType creator, type;
|
|
- FInfo info;
|
|
+ FSRef ref;
|
|
+ FileInfo* finfo;
|
|
OSErr err;
|
|
-
|
|
+ FSCatalogInfo cataloginfo;
|
|
+
|
|
if (!PyArg_ParseTuple(args, "O&O&O&",
|
|
+ PyMac_GetFSRef, &ref, PyMac_GetOSType, &creator, PyMac_GetOSType, &type)) {
|
|
+#ifndef __LP64__
|
|
+ /* Try to handle FSSpec arguments, for backward compatibility */
|
|
+ FSSpec fss;
|
|
+ FInfo info;
|
|
+
|
|
+ if (!PyArg_ParseTuple(args, "O&O&O&",
|
|
PyMac_GetFSSpec, &fss, PyMac_GetOSType, &creator, PyMac_GetOSType, &type))
|
|
+ return NULL;
|
|
+
|
|
+ if ((err = FSpGetFInfo(&fss, &info)) != noErr)
|
|
+ return PyErr_Mac(MacOS_Error, err);
|
|
+
|
|
+ info.fdCreator = creator;
|
|
+ info.fdType = type;
|
|
+
|
|
+ if ((err = FSpSetFInfo(&fss, &info)) != noErr)
|
|
+ return PyErr_Mac(MacOS_Error, err);
|
|
+ Py_INCREF(Py_None);
|
|
+ return Py_None;
|
|
+#else /* __LP64__ */
|
|
+ return NULL;
|
|
+#endif /* __LP64__ */
|
|
+ }
|
|
+
|
|
+ err = FSGetCatalogInfo(&ref,
|
|
+ kFSCatInfoFinderInfo|kFSCatInfoNodeFlags, &cataloginfo,
|
|
+ NULL, NULL, NULL);
|
|
+ if (err != noErr) {
|
|
+ PyErr_Mac(MacOS_Error, err);
|
|
return NULL;
|
|
- if ((err = FSpGetFInfo(&fss, &info)) != noErr)
|
|
- return PyErr_Mac(MacOS_Error, err);
|
|
- info.fdCreator = creator;
|
|
- info.fdType = type;
|
|
- if ((err = FSpSetFInfo(&fss, &info)) != noErr)
|
|
- return PyErr_Mac(MacOS_Error, err);
|
|
+ }
|
|
+
|
|
+ if ((cataloginfo.nodeFlags & kFSNodeIsDirectoryMask) != 0) {
|
|
+ /* Directory: doesn't have type/creator info.
|
|
+ *
|
|
+ * The specific error code is for backward compatibility with
|
|
+ * earlier versions.
|
|
+ */
|
|
+ PyErr_Mac(MacOS_Error, fnfErr);
|
|
+ return NULL;
|
|
+
|
|
+ }
|
|
+ finfo = (FileInfo*)&(cataloginfo.finderInfo);
|
|
+ finfo->fileCreator = creator;
|
|
+ finfo->fileType = type;
|
|
+
|
|
+ err = FSSetCatalogInfo(&ref, kFSCatInfoFinderInfo, &cataloginfo);
|
|
+ if (err != noErr) {
|
|
+ PyErr_Mac(MacOS_Error, fnfErr);
|
|
+ return NULL;
|
|
+ }
|
|
+
|
|
Py_INCREF(Py_None);
|
|
return Py_None;
|
|
}
|
|
@@ -399,6 +480,7 @@
|
|
return Py_BuildValue("s", buf);
|
|
}
|
|
|
|
+#ifndef __LP64__
|
|
static char splash_doc[] = "Open a splash-screen dialog by resource-id (0=close)";
|
|
|
|
static PyObject *
|
|
@@ -470,6 +552,7 @@
|
|
Py_INCREF(Py_None);
|
|
return Py_None;
|
|
}
|
|
+#endif /* !__LP64__ */
|
|
|
|
static char WMAvailable_doc[] =
|
|
"True if this process can interact with the display."
|
|
@@ -530,17 +613,18 @@
|
|
{
|
|
OSErr err;
|
|
char *mode = "r";
|
|
- FSSpec fss;
|
|
- SignedByte permission = 1;
|
|
+ FSRef ref;
|
|
+ SInt8 permission = fsRdPerm;
|
|
rfobject *fp;
|
|
+ HFSUniStr255 name;
|
|
|
|
- if (!PyArg_ParseTuple(args, "O&|s", PyMac_GetFSSpec, &fss, &mode))
|
|
+ if (!PyArg_ParseTuple(args, "O&|s", PyMac_GetFSRef, &ref, &mode))
|
|
return NULL;
|
|
while (*mode) {
|
|
switch (*mode++) {
|
|
case '*': break;
|
|
- case 'r': permission = 1; break;
|
|
- case 'w': permission = 2; break;
|
|
+ case 'r': permission = fsRdPerm; break;
|
|
+ case 'w': permission = fsWrPerm; break;
|
|
case 'b': break;
|
|
default:
|
|
PyErr_BadArgument();
|
|
@@ -548,33 +632,18 @@
|
|
}
|
|
}
|
|
|
|
- if ( (fp = newrfobject()) == NULL )
|
|
+ err = FSGetResourceForkName(&name);
|
|
+ if (err != noErr) {
|
|
+ PyMac_Error(err);
|
|
return NULL;
|
|
+ }
|
|
|
|
- err = HOpenRF(fss.vRefNum, fss.parID, fss.name, permission, &fp->fRefNum);
|
|
+ if ( (fp = newrfobject()) == NULL )
|
|
+ return NULL;
|
|
+
|
|
|
|
- if ( err == fnfErr ) {
|
|
- /* In stead of doing complicated things here to get creator/type
|
|
- ** correct we let the standard i/o library handle it
|
|
- */
|
|
- FILE *tfp;
|
|
- char pathname[PATHNAMELEN];
|
|
-
|
|
- if ( (err=PyMac_GetFullPathname(&fss, pathname, PATHNAMELEN)) ) {
|
|
- PyMac_Error(err);
|
|
- Py_DECREF(fp);
|
|
- return NULL;
|
|
- }
|
|
-
|
|
- if ( (tfp = fopen(pathname, "w")) == NULL ) {
|
|
- PyMac_Error(fnfErr); /* What else... */
|
|
- Py_DECREF(fp);
|
|
- return NULL;
|
|
- }
|
|
- fclose(tfp);
|
|
- err = HOpenRF(fss.vRefNum, fss.parID, fss.name, permission, &fp->fRefNum);
|
|
- }
|
|
- if ( err ) {
|
|
+ err = FSOpenFork(&ref, name.length, name.unicode, permission, &fp->fRefNum);
|
|
+ if (err != noErr) {
|
|
Py_DECREF(fp);
|
|
PyMac_Error(err);
|
|
return NULL;
|
|
@@ -589,10 +658,12 @@
|
|
{"SetCreatorAndType", MacOS_SetCreatorAndType, 1, setcrtp_doc},
|
|
{"GetErrorString", MacOS_GetErrorString, 1, geterr_doc},
|
|
{"openrf", MacOS_openrf, 1, openrf_doc},
|
|
+#ifndef __LP64__
|
|
{"splash", MacOS_splash, 1, splash_doc},
|
|
{"DebugStr", MacOS_DebugStr, 1, DebugStr_doc},
|
|
- {"GetTicks", MacOS_GetTicks, 1, GetTicks_doc},
|
|
{"SysBeep", MacOS_SysBeep, 1, SysBeep_doc},
|
|
+#endif /* !__LP64__ */
|
|
+ {"GetTicks", MacOS_GetTicks, 1, GetTicks_doc},
|
|
{"WMAvailable", MacOS_WMAvailable, 1, WMAvailable_doc},
|
|
{NULL, NULL} /* Sentinel */
|
|
};
|
|
--- Mac/Modules/file/_Filemodule.c.orig 2006-05-29 07:57:35.000000000 +1000
|
|
+++ Mac/Modules/file/_Filemodule.c 2009-09-10 22:48:47.000000000 +1000
|
|
@@ -18,9 +18,11 @@
|
|
#include <Carbon/Carbon.h>
|
|
|
|
#ifdef USE_TOOLBOX_OBJECT_GLUE
|
|
+#ifndef __LP64__
|
|
extern int _PyMac_GetFSSpec(PyObject *v, FSSpec *spec);
|
|
-extern int _PyMac_GetFSRef(PyObject *v, FSRef *fsr);
|
|
extern PyObject *_PyMac_BuildFSSpec(FSSpec *spec);
|
|
+#endif /* !__LP64__ */
|
|
+extern int _PyMac_GetFSRef(PyObject *v, FSRef *fsr);
|
|
extern PyObject *_PyMac_BuildFSRef(FSRef *spec);
|
|
|
|
#define PyMac_GetFSSpec _PyMac_GetFSSpec
|
|
@@ -28,20 +30,26 @@
|
|
#define PyMac_BuildFSSpec _PyMac_BuildFSSpec
|
|
#define PyMac_BuildFSRef _PyMac_BuildFSRef
|
|
#else
|
|
+#ifndef __LP64__
|
|
extern int PyMac_GetFSSpec(PyObject *v, FSSpec *spec);
|
|
-extern int PyMac_GetFSRef(PyObject *v, FSRef *fsr);
|
|
extern PyObject *PyMac_BuildFSSpec(FSSpec *spec);
|
|
+#endif /* !__LP64__ */
|
|
+extern int PyMac_GetFSRef(PyObject *v, FSRef *fsr);
|
|
extern PyObject *PyMac_BuildFSRef(FSRef *spec);
|
|
#endif
|
|
|
|
/* Forward declarations */
|
|
+#ifndef __LP64__
|
|
static PyObject *FInfo_New(FInfo *itself);
|
|
-static PyObject *FSRef_New(FSRef *itself);
|
|
static PyObject *FSSpec_New(FSSpec *itself);
|
|
+#define FSSpec_Convert PyMac_GetFSSpec
|
|
+#endif /* !__LP64__ */
|
|
+static PyObject *FSRef_New(FSRef *itself);
|
|
static PyObject *Alias_New(AliasHandle itself);
|
|
+#ifndef __LP64__
|
|
static int FInfo_Convert(PyObject *v, FInfo *p_itself);
|
|
+#endif /* !__LP64__ */
|
|
#define FSRef_Convert PyMac_GetFSRef
|
|
-#define FSSpec_Convert PyMac_GetFSSpec
|
|
static int Alias_Convert(PyObject *v, AliasHandle *p_itself);
|
|
|
|
/*
|
|
@@ -62,6 +70,7 @@
|
|
/*
|
|
** Optional fsspec and fsref pointers. None will pass NULL
|
|
*/
|
|
+#ifndef __LP64__
|
|
static int
|
|
myPyMac_GetOptFSSpecPtr(PyObject *v, FSSpec **spec)
|
|
{
|
|
@@ -71,6 +80,7 @@
|
|
}
|
|
return PyMac_GetFSSpec(v, *spec);
|
|
}
|
|
+#endif /* !__LP64__ */
|
|
|
|
static int
|
|
myPyMac_GetOptFSRefPtr(PyObject *v, FSRef **ref)
|
|
@@ -92,6 +102,7 @@
|
|
return Py_BuildValue("u#", itself->unicode, itself->length);
|
|
}
|
|
|
|
+#ifndef __LP64__
|
|
static OSErr
|
|
_PyMac_GetFullPathname(FSSpec *fss, char *path, int len)
|
|
{
|
|
@@ -135,6 +146,7 @@
|
|
}
|
|
return 0;
|
|
}
|
|
+#endif /* !__LP64__ */
|
|
|
|
|
|
static PyObject *File_Error;
|
|
@@ -282,12 +294,28 @@
|
|
|
|
static PyObject *FSCatalogInfo_get_permissions(FSCatalogInfoObject *self, void *closure)
|
|
{
|
|
- return Py_BuildValue("(llll)", self->ob_itself.permissions[0], self->ob_itself.permissions[1], self->ob_itself.permissions[2], self->ob_itself.permissions[3]);
|
|
+ FSPermissionInfo* info = (FSPermissionInfo*)&(self->ob_itself.permissions);
|
|
+ return Py_BuildValue("(llll)", info->userID, info->groupID, info->userAccess, info->mode);
|
|
}
|
|
|
|
static int FSCatalogInfo_set_permissions(FSCatalogInfoObject *self, PyObject *v, void *closure)
|
|
{
|
|
- return PyArg_Parse(v, "(llll)", &self->ob_itself.permissions[0], &self->ob_itself.permissions[1], &self->ob_itself.permissions[2], &self->ob_itself.permissions[3])-1;
|
|
+ long userID;
|
|
+ long groupID;
|
|
+ long userAccess;
|
|
+ long mode;
|
|
+ int r;
|
|
+
|
|
+ FSPermissionInfo* info = (FSPermissionInfo*)&(self->ob_itself.permissions);
|
|
+
|
|
+ r = PyArg_Parse(v, "(llll)", &userID, &groupID, &userAccess, &mode);
|
|
+ if (!r) {
|
|
+ return -1;
|
|
+ }
|
|
+ info->userID = userID;
|
|
+ info->groupID = groupID;
|
|
+ info->userAccess = userAccess;
|
|
+ info->mode = mode;
|
|
return 0;
|
|
}
|
|
|
|
@@ -501,6 +529,7 @@
|
|
|
|
/* ----------------------- Object type FInfo ------------------------ */
|
|
|
|
+#ifndef __LP64__
|
|
static PyTypeObject FInfo_Type;
|
|
|
|
#define FInfo_Check(x) ((x)->ob_type == &FInfo_Type || PyObject_TypeCheck((x), &FInfo_Type))
|
|
@@ -682,6 +711,7 @@
|
|
FInfo_tp_free, /* tp_free */
|
|
};
|
|
|
|
+#endif /* !__LP64__ */
|
|
/* --------------------- End object type FInfo ---------------------- */
|
|
|
|
|
|
@@ -729,6 +759,7 @@
|
|
self->ob_type->tp_free((PyObject *)self);
|
|
}
|
|
|
|
+#ifndef __LP64__
|
|
static PyObject *Alias_ResolveAlias(AliasObject *_self, PyObject *_args)
|
|
{
|
|
PyObject *_res = NULL;
|
|
@@ -818,6 +849,7 @@
|
|
wasChanged);
|
|
return _res;
|
|
}
|
|
+#endif /* !__LP64__ */
|
|
|
|
static PyObject *Alias_FSResolveAliasWithMountFlags(AliasObject *_self, PyObject *_args)
|
|
{
|
|
@@ -891,6 +923,7 @@
|
|
}
|
|
|
|
static PyMethodDef Alias_methods[] = {
|
|
+#ifndef __LP64__
|
|
{"ResolveAlias", (PyCFunction)Alias_ResolveAlias, 1,
|
|
PyDoc_STR("(FSSpec fromFile) -> (FSSpec target, Boolean wasChanged)")},
|
|
{"GetAliasInfo", (PyCFunction)Alias_GetAliasInfo, 1,
|
|
@@ -899,6 +932,7 @@
|
|
PyDoc_STR("(FSSpec fromFile, unsigned long mountFlags) -> (FSSpec target, Boolean wasChanged)")},
|
|
{"FollowFinderAlias", (PyCFunction)Alias_FollowFinderAlias, 1,
|
|
PyDoc_STR("(FSSpec fromFile, Boolean logon) -> (FSSpec target, Boolean wasChanged)")},
|
|
+#endif /* !__LP64__ */
|
|
{"FSResolveAliasWithMountFlags", (PyCFunction)Alias_FSResolveAliasWithMountFlags, 1,
|
|
PyDoc_STR("(FSRef fromFile, unsigned long mountFlags) -> (FSRef target, Boolean wasChanged)")},
|
|
{"FSResolveAlias", (PyCFunction)Alias_FSResolveAlias, 1,
|
|
@@ -1033,6 +1067,7 @@
|
|
|
|
|
|
/* ----------------------- Object type FSSpec ----------------------- */
|
|
+#ifndef __LP64__
|
|
|
|
static PyTypeObject FSSpec_Type;
|
|
|
|
@@ -1488,6 +1523,7 @@
|
|
FSSpec_tp_free, /* tp_free */
|
|
};
|
|
|
|
+#endif /* !__LP64__ */
|
|
/* --------------------- End object type FSSpec --------------------- */
|
|
|
|
|
|
@@ -1568,7 +1604,9 @@
|
|
FSCatalogInfoBitmap whichInfo;
|
|
FSCatalogInfo catalogInfo;
|
|
FSRef newRef;
|
|
+#ifndef __LP64__
|
|
FSSpec newSpec;
|
|
+#endif /* !__LP64__ */
|
|
if (!PyArg_ParseTuple(_args, "u#lO&",
|
|
&nameLength__in__, &nameLength__in_len__,
|
|
&whichInfo,
|
|
@@ -1580,11 +1618,20 @@
|
|
whichInfo,
|
|
&catalogInfo,
|
|
&newRef,
|
|
- &newSpec);
|
|
+#ifndef __LP64__
|
|
+ &newSpec
|
|
+#else
|
|
+ NULL
|
|
+#endif /* !__LP64__ */
|
|
+ );
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
+#ifndef __LP64__
|
|
_res = Py_BuildValue("O&O&",
|
|
FSRef_New, &newRef,
|
|
FSSpec_New, &newSpec);
|
|
+#else
|
|
+ _res = Py_BuildValue("O&O", FSRef_New, &newRef, Py_None);
|
|
+#endif /* !__LP64__ */
|
|
return _res;
|
|
}
|
|
|
|
@@ -1598,7 +1645,9 @@
|
|
FSCatalogInfoBitmap whichInfo;
|
|
FSCatalogInfo catalogInfo;
|
|
FSRef newRef;
|
|
+#ifndef __LP64__
|
|
FSSpec newSpec;
|
|
+#endif /* !__LP64__ */
|
|
UInt32 newDirID;
|
|
if (!PyArg_ParseTuple(_args, "u#lO&",
|
|
&nameLength__in__, &nameLength__in_len__,
|
|
@@ -1611,13 +1660,25 @@
|
|
whichInfo,
|
|
&catalogInfo,
|
|
&newRef,
|
|
+#ifndef __LP64__
|
|
&newSpec,
|
|
+#else
|
|
+ NULL,
|
|
+#endif /* !__LP64__ */
|
|
&newDirID);
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
+
|
|
+#ifndef __LP64__
|
|
_res = Py_BuildValue("O&O&l",
|
|
FSRef_New, &newRef,
|
|
FSSpec_New, &newSpec,
|
|
newDirID);
|
|
+#else
|
|
+ _res = Py_BuildValue("O&Ol",
|
|
+ FSRef_New, &newRef,
|
|
+ Py_None,
|
|
+ newDirID);
|
|
+#endif /* !__LP64__ */
|
|
return _res;
|
|
}
|
|
|
|
@@ -1699,7 +1760,9 @@
|
|
FSCatalogInfoBitmap whichInfo;
|
|
FSCatalogInfo catalogInfo;
|
|
HFSUniStr255 outName;
|
|
+#ifndef __LP64__
|
|
FSSpec fsSpec;
|
|
+#endif /* !__LP64__ */
|
|
FSRef parentRef;
|
|
if (!PyArg_ParseTuple(_args, "l",
|
|
&whichInfo))
|
|
@@ -1708,14 +1771,26 @@
|
|
whichInfo,
|
|
&catalogInfo,
|
|
&outName,
|
|
+#ifndef __LP64__
|
|
&fsSpec,
|
|
+#else
|
|
+ NULL,
|
|
+#endif /* !__LP64__ */
|
|
&parentRef);
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
+#ifndef __LP64__
|
|
_res = Py_BuildValue("O&O&O&O&",
|
|
FSCatalogInfo_New, &catalogInfo,
|
|
PyMac_BuildHFSUniStr255, &outName,
|
|
FSSpec_New, &fsSpec,
|
|
FSRef_New, &parentRef);
|
|
+#else
|
|
+ _res = Py_BuildValue("O&O&OO&",
|
|
+ FSCatalogInfo_New, &catalogInfo,
|
|
+ PyMac_BuildHFSUniStr255, &outName,
|
|
+ Py_None,
|
|
+ FSRef_New, &parentRef);
|
|
+#endif /* !__LP64__ */
|
|
return _res;
|
|
}
|
|
|
|
@@ -1784,7 +1859,7 @@
|
|
UniCharCount forkNameLength__len__;
|
|
int forkNameLength__in_len__;
|
|
SInt8 permissions;
|
|
- SInt16 forkRefNum;
|
|
+ FSIORefNum forkRefNum;
|
|
if (!PyArg_ParseTuple(_args, "u#b",
|
|
&forkNameLength__in__, &forkNameLength__in_len__,
|
|
&permissions))
|
|
@@ -2034,7 +2109,7 @@
|
|
|
|
/* --------------------- End object type FSRef ---------------------- */
|
|
|
|
-
|
|
+#ifndef __LP64__
|
|
static PyObject *File_UnmountVol(PyObject *_self, PyObject *_args)
|
|
{
|
|
PyObject *_res = NULL;
|
|
@@ -2562,6 +2637,7 @@
|
|
FSSpec_New, &spec);
|
|
return _res;
|
|
}
|
|
+#endif /* !__LP64__ */
|
|
|
|
static PyObject *File_FSGetForkPosition(PyObject *_self, PyObject *_args)
|
|
{
|
|
@@ -2785,6 +2861,7 @@
|
|
return _res;
|
|
}
|
|
|
|
+#ifndef __LP64__
|
|
static PyObject *File_NewAlias(PyObject *_self, PyObject *_args)
|
|
{
|
|
PyObject *_res = NULL;
|
|
@@ -2933,6 +3010,7 @@
|
|
wasAliased);
|
|
return _res;
|
|
}
|
|
+#endif /* !__LP64__ */
|
|
|
|
static PyObject *File_FSNewAlias(PyObject *_self, PyObject *_args)
|
|
{
|
|
@@ -3050,6 +3128,7 @@
|
|
}
|
|
|
|
static PyMethodDef File_methods[] = {
|
|
+#ifndef __LP64__
|
|
{"UnmountVol", (PyCFunction)File_UnmountVol, 1,
|
|
PyDoc_STR("(Str63 volName, short vRefNum) -> None")},
|
|
{"FlushVol", (PyCFunction)File_FlushVol, 1,
|
|
@@ -3100,6 +3179,7 @@
|
|
PyDoc_STR("(short vRefNum, long dirID, Str255 oldName, long newDirID, Str255 newName) -> None")},
|
|
{"FSMakeFSSpec", (PyCFunction)File_FSMakeFSSpec, 1,
|
|
PyDoc_STR("(short vRefNum, long dirID, Str255 fileName) -> (FSSpec spec)")},
|
|
+#endif /* !__LP64__ */
|
|
{"FSGetForkPosition", (PyCFunction)File_FSGetForkPosition, 1,
|
|
PyDoc_STR("(SInt16 forkRefNum) -> (SInt64 position)")},
|
|
{"FSSetForkPosition", (PyCFunction)File_FSSetForkPosition, 1,
|
|
@@ -3124,6 +3204,7 @@
|
|
PyDoc_STR("(UInt8 * path, FNMessage message, OptionBits flags) -> None")},
|
|
{"FNNotifyAll", (PyCFunction)File_FNNotifyAll, 1,
|
|
PyDoc_STR("(FNMessage message, OptionBits flags) -> None")},
|
|
+#ifndef __LP64__
|
|
{"NewAlias", (PyCFunction)File_NewAlias, 1,
|
|
PyDoc_STR("(FSSpec fromFile, FSSpec target) -> (AliasHandle alias)")},
|
|
{"NewAliasMinimalFromFullPath", (PyCFunction)File_NewAliasMinimalFromFullPath, 1,
|
|
@@ -3136,6 +3217,7 @@
|
|
PyDoc_STR("(FSSpec fromFile, FSSpec target, AliasHandle alias) -> (Boolean wasChanged)")},
|
|
{"ResolveAliasFileWithMountFlagsNoUI", (PyCFunction)File_ResolveAliasFileWithMountFlagsNoUI, 1,
|
|
PyDoc_STR("(FSSpec theSpec, Boolean resolveAliasChains, unsigned long mountFlags) -> (FSSpec theSpec, Boolean targetIsFolder, Boolean wasAliased)")},
|
|
+#endif /* !__LP64__ */
|
|
{"FSNewAlias", (PyCFunction)File_FSNewAlias, 1,
|
|
PyDoc_STR("(FSRef fromFile, FSRef target) -> (AliasHandle inAlias)")},
|
|
{"FSResolveAliasFileWithMountFlags", (PyCFunction)File_FSResolveAliasFileWithMountFlags, 1,
|
|
@@ -3150,7 +3232,7 @@
|
|
};
|
|
|
|
|
|
-
|
|
+#ifndef __LP64__
|
|
int
|
|
PyMac_GetFSSpec(PyObject *v, FSSpec *spec)
|
|
{
|
|
@@ -3188,12 +3270,15 @@
|
|
}
|
|
return 0;
|
|
}
|
|
+#endif /* !__LP64__ */
|
|
|
|
int
|
|
PyMac_GetFSRef(PyObject *v, FSRef *fsr)
|
|
{
|
|
OSStatus err;
|
|
+#ifndef __LP64__
|
|
FSSpec fss;
|
|
+#endif /* !__LP64__ */
|
|
|
|
if (FSRef_Check(v)) {
|
|
*fsr = ((FSRefObject *)v)->ob_itself;
|
|
@@ -3211,6 +3296,7 @@
|
|
return !err;
|
|
}
|
|
/* XXXX Should try unicode here too */
|
|
+#ifndef __LP64__
|
|
/* Otherwise we try to go via an FSSpec */
|
|
if (FSSpec_Check(v)) {
|
|
fss = ((FSSpecObject *)v)->ob_itself;
|
|
@@ -3219,15 +3305,18 @@
|
|
PyMac_Error(err);
|
|
return 0;
|
|
}
|
|
+#endif /* !__LP64__ */
|
|
PyErr_SetString(PyExc_TypeError, "FSRef, FSSpec or pathname required");
|
|
return 0;
|
|
}
|
|
|
|
+#ifndef __LP64__
|
|
extern PyObject *
|
|
PyMac_BuildFSSpec(FSSpec *spec)
|
|
{
|
|
return FSSpec_New(spec);
|
|
}
|
|
+#endif /* !__LP64__ */
|
|
|
|
extern PyObject *
|
|
PyMac_BuildFSRef(FSRef *spec)
|
|
@@ -3242,10 +3331,11 @@
|
|
PyObject *d;
|
|
|
|
|
|
-
|
|
+#ifndef __LP64__
|
|
PyMac_INIT_TOOLBOX_OBJECT_NEW(FSSpec *, PyMac_BuildFSSpec);
|
|
- PyMac_INIT_TOOLBOX_OBJECT_NEW(FSRef *, PyMac_BuildFSRef);
|
|
PyMac_INIT_TOOLBOX_OBJECT_CONVERT(FSSpec, PyMac_GetFSSpec);
|
|
+#endif /* !__LP64__ */
|
|
+ PyMac_INIT_TOOLBOX_OBJECT_NEW(FSRef *, PyMac_BuildFSRef);
|
|
PyMac_INIT_TOOLBOX_OBJECT_CONVERT(FSRef, PyMac_GetFSRef);
|
|
|
|
|
|
@@ -3262,6 +3352,7 @@
|
|
/* Backward-compatible name */
|
|
Py_INCREF(&FSCatalogInfo_Type);
|
|
PyModule_AddObject(m, "FSCatalogInfoType", (PyObject *)&FSCatalogInfo_Type);
|
|
+#ifndef __LP64__
|
|
FInfo_Type.ob_type = &PyType_Type;
|
|
if (PyType_Ready(&FInfo_Type) < 0) return;
|
|
Py_INCREF(&FInfo_Type);
|
|
@@ -3269,6 +3360,7 @@
|
|
/* Backward-compatible name */
|
|
Py_INCREF(&FInfo_Type);
|
|
PyModule_AddObject(m, "FInfoType", (PyObject *)&FInfo_Type);
|
|
+#endif /* !__LP64__ */
|
|
Alias_Type.ob_type = &PyType_Type;
|
|
if (PyType_Ready(&Alias_Type) < 0) return;
|
|
Py_INCREF(&Alias_Type);
|
|
@@ -3276,6 +3368,7 @@
|
|
/* Backward-compatible name */
|
|
Py_INCREF(&Alias_Type);
|
|
PyModule_AddObject(m, "AliasType", (PyObject *)&Alias_Type);
|
|
+#ifndef __LP64__
|
|
FSSpec_Type.ob_type = &PyType_Type;
|
|
if (PyType_Ready(&FSSpec_Type) < 0) return;
|
|
Py_INCREF(&FSSpec_Type);
|
|
@@ -3283,6 +3376,7 @@
|
|
/* Backward-compatible name */
|
|
Py_INCREF(&FSSpec_Type);
|
|
PyModule_AddObject(m, "FSSpecType", (PyObject *)&FSSpec_Type);
|
|
+#endif /* !__LP64__ */
|
|
FSRef_Type.ob_type = &PyType_Type;
|
|
if (PyType_Ready(&FSRef_Type) < 0) return;
|
|
Py_INCREF(&FSRef_Type);
|
|
Index: Lib/plat-mac/macresource.py
|
|
===================================================================
|
|
--- Lib/plat-mac/macresource.py (revision 74680)
|
|
+++ Lib/plat-mac/macresource.py (revision 74681)
|
|
@@ -79,8 +79,8 @@
|
|
AppleSingle file"""
|
|
try:
|
|
refno = Res.FSpOpenResFile(pathname, 1)
|
|
- except Res.Error, arg:
|
|
- if arg[0] in (-37, -39):
|
|
+ except (AttributeError, Res.Error), arg:
|
|
+ if isinstance(arg, AttributeError) or arg[0] in (-37, -39):
|
|
# No resource fork. We may be on OSX, and this may be either
|
|
# a data-fork based resource file or a AppleSingle file
|
|
# from the CVS repository.
|
|
@@ -106,8 +106,8 @@
|
|
try:
|
|
refno = Res.FSpOpenResFile(pathname, 1)
|
|
Res.CloseResFile(refno)
|
|
- except Res.Error, arg:
|
|
- if arg[0] in (-37, -39):
|
|
+ except (AttributeError, Res.Error), arg:
|
|
+ if isinstance(arg, AttributeError) or arg[0] in (-37, -39):
|
|
# No resource fork. We may be on OSX, and this may be either
|
|
# a data-fork based resource file or a AppleSingle file
|
|
# from the CVS repository.
|
|
Index: Lib/plat-mac/applesingle.py
|
|
===================================================================
|
|
--- Lib/plat-mac/applesingle.py (revision 74680)
|
|
+++ Lib/plat-mac/applesingle.py (revision 74681)
|
|
@@ -119,8 +119,13 @@
|
|
if not hasattr(infile, 'read'):
|
|
if isinstance(infile, Carbon.File.Alias):
|
|
infile = infile.ResolveAlias()[0]
|
|
- if isinstance(infile, (Carbon.File.FSSpec, Carbon.File.FSRef)):
|
|
- infile = infile.as_pathname()
|
|
+
|
|
+ if hasattr(Carbon.File, "FSSpec"):
|
|
+ if isinstance(infile, (Carbon.File.FSSpec, Carbon.File.FSRef)):
|
|
+ infile = infile.as_pathname()
|
|
+ else:
|
|
+ if isinstance(infile, Carbon.File.FSRef):
|
|
+ infile = infile.as_pathname()
|
|
infile = open(infile, 'rb')
|
|
|
|
asfile = AppleSingle(infile, verbose=verbose)
|
|
Index: Mac/scripts/BuildApplet.py
|
|
===================================================================
|
|
--- Mac/scripts/BuildApplet.py (revision 74680)
|
|
+++ Mac/scripts/BuildApplet.py (revision 74681)
|
|
@@ -12,7 +12,10 @@
|
|
|
|
import os
|
|
import MacOS
|
|
-import EasyDialogs
|
|
+try:
|
|
+ import EasyDialogs
|
|
+except ImportError:
|
|
+ EasyDialogs = None
|
|
import buildtools
|
|
import getopt
|
|
|
|
@@ -32,7 +35,10 @@
|
|
try:
|
|
buildapplet()
|
|
except buildtools.BuildError, detail:
|
|
- EasyDialogs.Message(detail)
|
|
+ if EasyDialogs is None:
|
|
+ print detail
|
|
+ else:
|
|
+ EasyDialogs.Message(detail)
|
|
|
|
|
|
def buildapplet():
|
|
@@ -46,6 +52,10 @@
|
|
# Ask for source text if not specified in sys.argv[1:]
|
|
|
|
if not sys.argv[1:]:
|
|
+ if EasyDialogs is None:
|
|
+ usage()
|
|
+ sys.exit(1)
|
|
+
|
|
filename = EasyDialogs.AskFileForOpen(message='Select Python source or applet:',
|
|
typeList=('TEXT', 'APPL'))
|
|
if not filename:
|
|
Index: Lib/plat-mac/buildtools.py
|
|
===================================================================
|
|
--- Lib/plat-mac/buildtools.py (revision 74680)
|
|
+++ Lib/plat-mac/buildtools.py (revision 74681)
|
|
@@ -15,7 +15,10 @@
|
|
import MacOS
|
|
import macostools
|
|
import macresource
|
|
-import EasyDialogs
|
|
+try:
|
|
+ import EasyDialogs
|
|
+except ImportError:
|
|
+ EasyDialogs = None
|
|
import shutil
|
|
|
|
|
|
@@ -67,9 +70,13 @@
|
|
rsrcname=None, others=[], raw=0, progress="default", destroot=""):
|
|
|
|
if progress == "default":
|
|
- progress = EasyDialogs.ProgressBar("Processing %s..."%os.path.split(filename)[1], 120)
|
|
- progress.label("Compiling...")
|
|
- progress.inc(0)
|
|
+ if EasyDialogs is None:
|
|
+ print "Compiling %s"%(os.path.split(filename)[1],)
|
|
+ process = None
|
|
+ else:
|
|
+ progress = EasyDialogs.ProgressBar("Processing %s..."%os.path.split(filename)[1], 120)
|
|
+ progress.label("Compiling...")
|
|
+ progress.inc(0)
|
|
# check for the script name being longer than 32 chars. This may trigger a bug
|
|
# on OSX that can destroy your sourcefile.
|
|
if '#' in os.path.split(filename)[1]:
|
|
@@ -119,7 +126,11 @@
|
|
if MacOS.runtimemodel == 'macho':
|
|
raise BuildError, "No updating yet for MachO applets"
|
|
if progress:
|
|
- progress = EasyDialogs.ProgressBar("Updating %s..."%os.path.split(filename)[1], 120)
|
|
+ if EasyDialogs is None:
|
|
+ print "Updating %s"%(os.path.split(filename)[1],)
|
|
+ progress = None
|
|
+ else:
|
|
+ progress = EasyDialogs.ProgressBar("Updating %s..."%os.path.split(filename)[1], 120)
|
|
else:
|
|
progress = None
|
|
if not output:
|