[Python-checkins] python/dist/src/Mac/Modules/file _Filemodule.c,1.11,1.12 filescan.py,1.6,1.7 filesupport.py,1.10,1.11
jackjansen@users.sourceforge.net
jackjansen@users.sourceforge.net
Sun, 12 Jan 2003 15:01:51 -0800
Update of /cvsroot/python/python/dist/src/Mac/Modules/file
In directory sc8-pr-cvs1:/tmp/cvs-serv2822
Modified Files:
_Filemodule.c filescan.py filesupport.py
Log Message:
Implemented FSCatalogInfo.
Index: _Filemodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Modules/file/_Filemodule.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** _Filemodule.c 26 Dec 2002 20:45:43 -0000 1.11
--- _Filemodule.c 12 Jan 2003 23:01:44 -0000 1.12
***************
*** 55,58 ****
--- 55,73 ----
/*
+ ** UTCDateTime records
+ */
+ static int
+ UTCDateTime_Convert(PyObject *v, UTCDateTime *ptr)
+ {
+ return PyArg_Parse(v, "(HlH)", &ptr->highSeconds, &ptr->lowSeconds, &ptr->fraction);
+ }
+
+ static PyObject *
+ UTCDateTime_New(UTCDateTime *ptr)
+ {
+ return Py_BuildValue("(HlH)", ptr->highSeconds, ptr->lowSeconds, ptr->fraction);
+ }
+
+ /*
** Optional fsspec and fsref pointers. None will pass NULL
*/
***************
*** 87,93 ****
}
-
static PyObject *File_Error;
/* ----------------------- Object type FInfo ------------------------ */
--- 102,471 ----
}
static PyObject *File_Error;
+ /* ------------------- Object type FSCatalogInfo -------------------- */
+
+ static PyTypeObject FSCatalogInfo_Type;
+
+ #define FSCatalogInfo_Check(x) ((x)->ob_type == &FSCatalogInfo_Type || PyObject_TypeCheck((x), &FSCatalogInfo_Type))
+
+ typedef struct FSCatalogInfoObject {
+ PyObject_HEAD
+ FSCatalogInfo ob_itself;
+ } FSCatalogInfoObject;
+
+ static PyObject *FSCatalogInfo_New(FSCatalogInfo *itself)
+ {
+ FSCatalogInfoObject *it;
+ if (itself == NULL) return Py_None;
+ it = PyObject_NEW(FSCatalogInfoObject, &FSCatalogInfo_Type);
+ if (it == NULL) return NULL;
+ it->ob_itself = *itself;
+ return (PyObject *)it;
+ }
+ static int FSCatalogInfo_Convert(PyObject *v, FSCatalogInfo *p_itself)
+ {
+ if (!FSCatalogInfo_Check(v))
+ {
+ PyErr_SetString(PyExc_TypeError, "FSCatalogInfo required");
+ return 0;
+ }
+ *p_itself = ((FSCatalogInfoObject *)v)->ob_itself;
+ return 1;
+ }
+
+ static void FSCatalogInfo_dealloc(FSCatalogInfoObject *self)
+ {
+ /* Cleanup of self->ob_itself goes here */
+ self->ob_type->tp_free((PyObject *)self);
+ }
+
+ static PyMethodDef FSCatalogInfo_methods[] = {
+ {NULL, NULL, 0}
+ };
+
+ static PyObject *FSCatalogInfo_get_nodeFlags(FSCatalogInfoObject *self, void *closure)
+ {
+ return Py_BuildValue("H", self->ob_itself.nodeFlags);
+ }
+
+ static int FSCatalogInfo_set_nodeFlags(FSCatalogInfoObject *self, PyObject *v, void *closure)
+ {
+ return PyArg_Parse(v, "H", &self->ob_itself.nodeFlags)-1;
+ return 0;
+ }
+
+ static PyObject *FSCatalogInfo_get_volume(FSCatalogInfoObject *self, void *closure)
+ {
+ return Py_BuildValue("h", self->ob_itself.volume);
+ }
+
+ static int FSCatalogInfo_set_volume(FSCatalogInfoObject *self, PyObject *v, void *closure)
+ {
+ return PyArg_Parse(v, "h", &self->ob_itself.volume)-1;
+ return 0;
+ }
+
+ static PyObject *FSCatalogInfo_get_parentDirID(FSCatalogInfoObject *self, void *closure)
+ {
+ return Py_BuildValue("l", self->ob_itself.parentDirID);
+ }
+
+ static int FSCatalogInfo_set_parentDirID(FSCatalogInfoObject *self, PyObject *v, void *closure)
+ {
+ return PyArg_Parse(v, "l", &self->ob_itself.parentDirID)-1;
+ return 0;
+ }
+
+ static PyObject *FSCatalogInfo_get_nodeID(FSCatalogInfoObject *self, void *closure)
+ {
+ return Py_BuildValue("l", self->ob_itself.nodeID);
+ }
+
+ static int FSCatalogInfo_set_nodeID(FSCatalogInfoObject *self, PyObject *v, void *closure)
+ {
+ return PyArg_Parse(v, "l", &self->ob_itself.nodeID)-1;
+ return 0;
+ }
+
+ static PyObject *FSCatalogInfo_get_createDate(FSCatalogInfoObject *self, void *closure)
+ {
+ return Py_BuildValue("O&", UTCDateTime_New, &self->ob_itself.createDate);
+ }
+
+ static int FSCatalogInfo_set_createDate(FSCatalogInfoObject *self, PyObject *v, void *closure)
+ {
+ return PyArg_Parse(v, "O&", UTCDateTime_Convert, &self->ob_itself.createDate)-1;
+ return 0;
+ }
+
+ static PyObject *FSCatalogInfo_get_contentModDate(FSCatalogInfoObject *self, void *closure)
+ {
+ return Py_BuildValue("O&", UTCDateTime_New, &self->ob_itself.contentModDate);
+ }
+
+ static int FSCatalogInfo_set_contentModDate(FSCatalogInfoObject *self, PyObject *v, void *closure)
+ {
+ return PyArg_Parse(v, "O&", UTCDateTime_Convert, &self->ob_itself.contentModDate)-1;
+ return 0;
+ }
+
+ static PyObject *FSCatalogInfo_get_attributeModDate(FSCatalogInfoObject *self, void *closure)
+ {
+ return Py_BuildValue("O&", UTCDateTime_New, &self->ob_itself.attributeModDate);
+ }
+
+ static int FSCatalogInfo_set_attributeModDate(FSCatalogInfoObject *self, PyObject *v, void *closure)
+ {
+ return PyArg_Parse(v, "O&", UTCDateTime_Convert, &self->ob_itself.attributeModDate)-1;
+ return 0;
+ }
+
+ static PyObject *FSCatalogInfo_get_accessDate(FSCatalogInfoObject *self, void *closure)
+ {
+ return Py_BuildValue("O&", UTCDateTime_New, &self->ob_itself.accessDate);
+ }
+
+ static int FSCatalogInfo_set_accessDate(FSCatalogInfoObject *self, PyObject *v, void *closure)
+ {
+ return PyArg_Parse(v, "O&", UTCDateTime_Convert, &self->ob_itself.accessDate)-1;
+ return 0;
+ }
+
+ static PyObject *FSCatalogInfo_get_backupDate(FSCatalogInfoObject *self, void *closure)
+ {
+ return Py_BuildValue("O&", UTCDateTime_New, &self->ob_itself.backupDate);
+ }
+
+ static int FSCatalogInfo_set_backupDate(FSCatalogInfoObject *self, PyObject *v, void *closure)
+ {
+ return PyArg_Parse(v, "O&", UTCDateTime_Convert, &self->ob_itself.backupDate)-1;
+ return 0;
+ }
+
+ 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]);
+ }
+
+ 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;
+ return 0;
+ }
+
+ static PyObject *FSCatalogInfo_get_valence(FSCatalogInfoObject *self, void *closure)
+ {
+ return Py_BuildValue("l", self->ob_itself.valence);
+ }
+
+ static int FSCatalogInfo_set_valence(FSCatalogInfoObject *self, PyObject *v, void *closure)
+ {
+ return PyArg_Parse(v, "l", &self->ob_itself.valence)-1;
+ return 0;
+ }
+
+ static PyObject *FSCatalogInfo_get_dataLogicalSize(FSCatalogInfoObject *self, void *closure)
+ {
+ return Py_BuildValue("l", self->ob_itself.dataLogicalSize);
+ }
+
+ static int FSCatalogInfo_set_dataLogicalSize(FSCatalogInfoObject *self, PyObject *v, void *closure)
+ {
+ return PyArg_Parse(v, "l", &self->ob_itself.dataLogicalSize)-1;
+ return 0;
+ }
+
+ static PyObject *FSCatalogInfo_get_dataPhysicalSize(FSCatalogInfoObject *self, void *closure)
+ {
+ return Py_BuildValue("l", self->ob_itself.dataPhysicalSize);
+ }
+
+ static int FSCatalogInfo_set_dataPhysicalSize(FSCatalogInfoObject *self, PyObject *v, void *closure)
+ {
+ return PyArg_Parse(v, "l", &self->ob_itself.dataPhysicalSize)-1;
+ return 0;
+ }
+
+ static PyObject *FSCatalogInfo_get_rsrcLogicalSize(FSCatalogInfoObject *self, void *closure)
+ {
+ return Py_BuildValue("l", self->ob_itself.rsrcLogicalSize);
+ }
+
+ static int FSCatalogInfo_set_rsrcLogicalSize(FSCatalogInfoObject *self, PyObject *v, void *closure)
+ {
+ return PyArg_Parse(v, "l", &self->ob_itself.rsrcLogicalSize)-1;
+ return 0;
+ }
+
+ static PyObject *FSCatalogInfo_get_rsrcPhysicalSize(FSCatalogInfoObject *self, void *closure)
+ {
+ return Py_BuildValue("l", self->ob_itself.rsrcPhysicalSize);
+ }
+
+ static int FSCatalogInfo_set_rsrcPhysicalSize(FSCatalogInfoObject *self, PyObject *v, void *closure)
+ {
+ return PyArg_Parse(v, "l", &self->ob_itself.rsrcPhysicalSize)-1;
+ return 0;
+ }
+
+ static PyObject *FSCatalogInfo_get_sharingFlags(FSCatalogInfoObject *self, void *closure)
+ {
+ return Py_BuildValue("l", self->ob_itself.sharingFlags);
+ }
+
+ static int FSCatalogInfo_set_sharingFlags(FSCatalogInfoObject *self, PyObject *v, void *closure)
+ {
+ return PyArg_Parse(v, "l", &self->ob_itself.sharingFlags)-1;
+ return 0;
+ }
+
+ static PyObject *FSCatalogInfo_get_userPrivileges(FSCatalogInfoObject *self, void *closure)
+ {
+ return Py_BuildValue("b", self->ob_itself.userPrivileges);
+ }
+
+ static int FSCatalogInfo_set_userPrivileges(FSCatalogInfoObject *self, PyObject *v, void *closure)
+ {
+ return PyArg_Parse(v, "b", &self->ob_itself.userPrivileges)-1;
+ return 0;
+ }
+
+ static PyGetSetDef FSCatalogInfo_getsetlist[] = {
+ {"nodeFlags", (getter)FSCatalogInfo_get_nodeFlags, (setter)FSCatalogInfo_set_nodeFlags, NULL},
+ {"volume", (getter)FSCatalogInfo_get_volume, (setter)FSCatalogInfo_set_volume, NULL},
+ {"parentDirID", (getter)FSCatalogInfo_get_parentDirID, (setter)FSCatalogInfo_set_parentDirID, NULL},
+ {"nodeID", (getter)FSCatalogInfo_get_nodeID, (setter)FSCatalogInfo_set_nodeID, NULL},
+ {"createDate", (getter)FSCatalogInfo_get_createDate, (setter)FSCatalogInfo_set_createDate, NULL},
+ {"contentModDate", (getter)FSCatalogInfo_get_contentModDate, (setter)FSCatalogInfo_set_contentModDate, NULL},
+ {"attributeModDate", (getter)FSCatalogInfo_get_attributeModDate, (setter)FSCatalogInfo_set_attributeModDate, NULL},
+ {"accessDate", (getter)FSCatalogInfo_get_accessDate, (setter)FSCatalogInfo_set_accessDate, NULL},
+ {"backupDate", (getter)FSCatalogInfo_get_backupDate, (setter)FSCatalogInfo_set_backupDate, NULL},
+ {"permissions", (getter)FSCatalogInfo_get_permissions, (setter)FSCatalogInfo_set_permissions, NULL},
+ {"valence", (getter)FSCatalogInfo_get_valence, (setter)FSCatalogInfo_set_valence, NULL},
+ {"dataLogicalSize", (getter)FSCatalogInfo_get_dataLogicalSize, (setter)FSCatalogInfo_set_dataLogicalSize, NULL},
+ {"dataPhysicalSize", (getter)FSCatalogInfo_get_dataPhysicalSize, (setter)FSCatalogInfo_set_dataPhysicalSize, NULL},
+ {"rsrcLogicalSize", (getter)FSCatalogInfo_get_rsrcLogicalSize, (setter)FSCatalogInfo_set_rsrcLogicalSize, NULL},
+ {"rsrcPhysicalSize", (getter)FSCatalogInfo_get_rsrcPhysicalSize, (setter)FSCatalogInfo_set_rsrcPhysicalSize, NULL},
+ {"sharingFlags", (getter)FSCatalogInfo_get_sharingFlags, (setter)FSCatalogInfo_set_sharingFlags, NULL},
+ {"userPrivileges", (getter)FSCatalogInfo_get_userPrivileges, (setter)FSCatalogInfo_set_userPrivileges, NULL},
+ {NULL, NULL, NULL, NULL},
+ };
+
+
+ #define FSCatalogInfo_compare NULL
+
+ #define FSCatalogInfo_repr NULL
+
+ #define FSCatalogInfo_hash NULL
+ static int FSCatalogInfo_tp_init(PyObject *self, PyObject *args, PyObject *kwds)
+ {
+ static char *kw[] = {
+ "nodeFlags",
+ "volume",
+ "parentDirID",
+ "nodeID",
+ "createDate",
+ "contentModDate",
+ "atributeModDate",
+ "accessDate",
+ "backupDate",
+ "permissions",
+ "valence",
+ "dataLogicalSize",
+ "dataPhysicalSize",
+ "rsrcLogicalSize",
+ "rsrcPhysicalSize",
+ "sharingFlags",
+ "userPrivileges"
+ , 0};
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "|HhllO&O&O&O&O&(llll)llllllb", kw, &((FSCatalogInfoObject *)self)->ob_itself.nodeFlags,
+ &((FSCatalogInfoObject *)self)->ob_itself.volume,
+ &((FSCatalogInfoObject *)self)->ob_itself.parentDirID,
+ &((FSCatalogInfoObject *)self)->ob_itself.nodeID,
+ UTCDateTime_Convert, &((FSCatalogInfoObject *)self)->ob_itself.createDate,
+ UTCDateTime_Convert, &((FSCatalogInfoObject *)self)->ob_itself.contentModDate,
+ UTCDateTime_Convert, &((FSCatalogInfoObject *)self)->ob_itself.attributeModDate,
+ UTCDateTime_Convert, &((FSCatalogInfoObject *)self)->ob_itself.accessDate,
+ UTCDateTime_Convert, &((FSCatalogInfoObject *)self)->ob_itself.backupDate,
+ &((FSCatalogInfoObject *)self)->ob_itself.permissions[0],
+ &((FSCatalogInfoObject *)self)->ob_itself.permissions[1],
+ &((FSCatalogInfoObject *)self)->ob_itself.permissions[2],
+ &((FSCatalogInfoObject *)self)->ob_itself.permissions[3],
+ &((FSCatalogInfoObject *)self)->ob_itself.valence,
+ &((FSCatalogInfoObject *)self)->ob_itself.dataLogicalSize,
+ &((FSCatalogInfoObject *)self)->ob_itself.dataPhysicalSize,
+ &((FSCatalogInfoObject *)self)->ob_itself.rsrcLogicalSize,
+ &((FSCatalogInfoObject *)self)->ob_itself.rsrcPhysicalSize,
+ &((FSCatalogInfoObject *)self)->ob_itself.sharingFlags,
+ &((FSCatalogInfoObject *)self)->ob_itself.userPrivileges))
+ {
+ return -1;
+ }
+ return 0;
+ }
+
+ #define FSCatalogInfo_tp_alloc PyType_GenericAlloc
+
+ static PyObject *FSCatalogInfo_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+ {
+ PyObject *self;
+
+ if ((self = type->tp_alloc(type, 0)) == NULL) return NULL;
+ memset(&((FSCatalogInfoObject *)self)->ob_itself, 0, sizeof(FSCatalogInfo));
+ return self;
+ }
+
+ #define FSCatalogInfo_tp_free PyObject_Del
+
+
+ static PyTypeObject FSCatalogInfo_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /*ob_size*/
+ "Carbon.File.FSCatalogInfo", /*tp_name*/
+ sizeof(FSCatalogInfoObject), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ /* methods */
+ (destructor) FSCatalogInfo_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ (getattrfunc)0, /*tp_getattr*/
+ (setattrfunc)0, /*tp_setattr*/
+ (cmpfunc) FSCatalogInfo_compare, /*tp_compare*/
+ (reprfunc) FSCatalogInfo_repr, /*tp_repr*/
+ (PyNumberMethods *)0, /* tp_as_number */
+ (PySequenceMethods *)0, /* tp_as_sequence */
+ (PyMappingMethods *)0, /* tp_as_mapping */
+ (hashfunc) FSCatalogInfo_hash, /*tp_hash*/
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ PyObject_GenericGetAttr, /*tp_getattro*/
+ PyObject_GenericSetAttr, /*tp_setattro */
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */
+ 0, /*tp_doc*/
+ 0, /*tp_traverse*/
+ 0, /*tp_clear*/
+ 0, /*tp_richcompare*/
+ 0, /*tp_weaklistoffset*/
+ 0, /*tp_iter*/
+ 0, /*tp_iternext*/
+ FSCatalogInfo_methods, /* tp_methods */
+ 0, /*tp_members*/
+ FSCatalogInfo_getsetlist, /*tp_getset*/
+ 0, /*tp_base*/
+ 0, /*tp_dict*/
+ 0, /*tp_descr_get*/
+ 0, /*tp_descr_set*/
+ 0, /*tp_dictoffset*/
+ FSCatalogInfo_tp_init, /* tp_init */
+ FSCatalogInfo_tp_alloc, /* tp_alloc */
+ FSCatalogInfo_tp_new, /* tp_new */
+ FSCatalogInfo_tp_free, /* tp_free */
+ };
+
+ /* ----------------- End object type FSCatalogInfo ------------------ */
+
+
/* ----------------------- Object type FInfo ------------------------ */
***************
*** 204,208 ****
{
FInfo *itself = NULL;
! char *kw[] = {"itself", 0};
if (PyArg_ParseTupleAndKeywords(args, kwds, "|O&", kw, FInfo_Convert, &itself))
--- 582,586 ----
{
FInfo *itself = NULL;
! static char *kw[] = {"itself", 0};
if (PyArg_ParseTupleAndKeywords(args, kwds, "|O&", kw, FInfo_Convert, &itself))
***************
*** 529,533 ****
int rawdatalen = 0;
Handle h;
! char *kw[] = {"itself", "rawdata", 0};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O&s#", kw, Alias_Convert, &itself, &rawdata, &rawdatalen))
--- 907,911 ----
int rawdatalen = 0;
Handle h;
! static char *kw[] = {"itself", "rawdata", 0};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O&s#", kw, Alias_Convert, &itself, &rawdata, &rawdatalen))
***************
*** 991,995 ****
char *rawdata = NULL;
int rawdatalen = 0;
! char *kw[] = {"itself", "rawdata", 0};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|Os#", kw, &v, &rawdata, &rawdatalen))
--- 1369,1373 ----
char *rawdata = NULL;
int rawdatalen = 0;
! static char *kw[] = {"itself", "rawdata", 0};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|Os#", kw, &v, &rawdata, &rawdatalen))
***************
*** 1147,1150 ****
--- 1525,1591 ----
}
+ static PyObject *FSRef_FSCreateFileUnicode(FSRefObject *_self, PyObject *_args)
+ {
+ PyObject *_res = NULL;
+ OSErr _err;
+ UniChar *nameLength__in__;
+ UniCharCount nameLength__len__;
+ int nameLength__in_len__;
+ FSCatalogInfoBitmap whichInfo;
+ FSCatalogInfo catalogInfo;
+ FSRef newRef;
+ FSSpec newSpec;
+ if (!PyArg_ParseTuple(_args, "u#lO&",
+ &nameLength__in__, &nameLength__in_len__,
+ &whichInfo,
+ FSCatalogInfo_Convert, &catalogInfo))
+ return NULL;
+ nameLength__len__ = nameLength__in_len__;
+ _err = FSCreateFileUnicode(&_self->ob_itself,
+ nameLength__len__, nameLength__in__,
+ whichInfo,
+ &catalogInfo,
+ &newRef,
+ &newSpec);
+ if (_err != noErr) return PyMac_Error(_err);
+ _res = Py_BuildValue("O&O&",
+ FSRef_New, &newRef,
+ FSSpec_New, &newSpec);
+ return _res;
+ }
+
+ static PyObject *FSRef_FSCreateDirectoryUnicode(FSRefObject *_self, PyObject *_args)
+ {
+ PyObject *_res = NULL;
+ OSErr _err;
+ UniChar *nameLength__in__;
+ UniCharCount nameLength__len__;
+ int nameLength__in_len__;
+ FSCatalogInfoBitmap whichInfo;
+ FSCatalogInfo catalogInfo;
+ FSRef newRef;
+ FSSpec newSpec;
+ UInt32 newDirID;
+ if (!PyArg_ParseTuple(_args, "u#lO&",
+ &nameLength__in__, &nameLength__in_len__,
+ &whichInfo,
+ FSCatalogInfo_Convert, &catalogInfo))
+ return NULL;
+ nameLength__len__ = nameLength__in_len__;
+ _err = FSCreateDirectoryUnicode(&_self->ob_itself,
+ nameLength__len__, nameLength__in__,
+ whichInfo,
+ &catalogInfo,
+ &newRef,
+ &newSpec,
+ &newDirID);
+ if (_err != noErr) return PyMac_Error(_err);
+ _res = Py_BuildValue("O&O&l",
+ FSRef_New, &newRef,
+ FSSpec_New, &newSpec,
+ newDirID);
+ return _res;
+ }
+
static PyObject *FSRef_FSDeleteObject(FSRefObject *_self, PyObject *_args)
{
***************
*** 1218,1221 ****
--- 1659,1708 ----
}
+ static PyObject *FSRef_FSGetCatalogInfo(FSRefObject *_self, PyObject *_args)
+ {
+ PyObject *_res = NULL;
+ OSErr _err;
+ FSCatalogInfoBitmap whichInfo;
+ FSCatalogInfo catalogInfo;
+ HFSUniStr255 outName;
+ FSSpec fsSpec;
+ FSRef parentRef;
+ if (!PyArg_ParseTuple(_args, "l",
+ &whichInfo))
+ return NULL;
+ _err = FSGetCatalogInfo(&_self->ob_itself,
+ whichInfo,
+ &catalogInfo,
+ &outName,
+ &fsSpec,
+ &parentRef);
+ if (_err != noErr) return PyMac_Error(_err);
+ _res = Py_BuildValue("O&O&O&O&",
+ FSCatalogInfo_New, &catalogInfo,
+ PyMac_BuildHFSUniStr255, &outName,
+ FSSpec_New, &fsSpec,
+ FSRef_New, &parentRef);
+ return _res;
+ }
+
+ static PyObject *FSRef_FSSetCatalogInfo(FSRefObject *_self, PyObject *_args)
+ {
+ PyObject *_res = NULL;
+ OSErr _err;
+ FSCatalogInfoBitmap whichInfo;
+ FSCatalogInfo catalogInfo;
+ if (!PyArg_ParseTuple(_args, "lO&",
+ &whichInfo,
+ FSCatalogInfo_Convert, &catalogInfo))
+ return NULL;
+ _err = FSSetCatalogInfo(&_self->ob_itself,
+ whichInfo,
+ &catalogInfo);
+ if (_err != noErr) return PyMac_Error(_err);
+ Py_INCREF(Py_None);
+ _res = Py_None;
+ return _res;
+ }
+
static PyObject *FSRef_FSCreateFork(FSRefObject *_self, PyObject *_args)
{
***************
*** 1369,1372 ****
--- 1856,1863 ----
{"FSCompareFSRefs", (PyCFunction)FSRef_FSCompareFSRefs, 1,
PyDoc_STR("(FSRef ref2) -> None")},
+ {"FSCreateFileUnicode", (PyCFunction)FSRef_FSCreateFileUnicode, 1,
+ PyDoc_STR("(Buffer nameLength, FSCatalogInfoBitmap whichInfo, FSCatalogInfo catalogInfo) -> (FSRef newRef, FSSpec newSpec)")},
+ {"FSCreateDirectoryUnicode", (PyCFunction)FSRef_FSCreateDirectoryUnicode, 1,
+ PyDoc_STR("(Buffer nameLength, FSCatalogInfoBitmap whichInfo, FSCatalogInfo catalogInfo) -> (FSRef newRef, FSSpec newSpec, UInt32 newDirID)")},
{"FSDeleteObject", (PyCFunction)FSRef_FSDeleteObject, 1,
PyDoc_STR("() -> None")},
***************
*** 1377,1380 ****
--- 1868,1875 ----
{"FSRenameUnicode", (PyCFunction)FSRef_FSRenameUnicode, 1,
PyDoc_STR("(Buffer nameLength, TextEncoding textEncodingHint) -> (FSRef newRef)")},
+ {"FSGetCatalogInfo", (PyCFunction)FSRef_FSGetCatalogInfo, 1,
+ PyDoc_STR("(FSCatalogInfoBitmap whichInfo) -> (FSCatalogInfo catalogInfo, HFSUniStr255 outName, FSSpec fsSpec, FSRef parentRef)")},
+ {"FSSetCatalogInfo", (PyCFunction)FSRef_FSSetCatalogInfo, 1,
+ PyDoc_STR("(FSCatalogInfoBitmap whichInfo, FSCatalogInfo catalogInfo) -> None")},
{"FSCreateFork", (PyCFunction)FSRef_FSCreateFork, 1,
PyDoc_STR("(Buffer forkNameLength) -> None")},
***************
*** 1422,1426 ****
char *rawdata = NULL;
int rawdatalen = 0;
! char *kw[] = {"itself", "rawdata", 0};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|Os#", kw, &v, &rawdata, &rawdatalen))
--- 1917,1921 ----
char *rawdata = NULL;
int rawdatalen = 0;
! static char *kw[] = {"itself", "rawdata", 0};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|Os#", kw, &v, &rawdata, &rawdatalen))
***************
*** 2742,2745 ****
--- 3237,3247 ----
PyDict_SetItemString(d, "Error", File_Error) != 0)
return;
+ FSCatalogInfo_Type.ob_type = &PyType_Type;
+ if (PyType_Ready(&FSCatalogInfo_Type) < 0) return;
+ Py_INCREF(&FSCatalogInfo_Type);
+ PyModule_AddObject(m, "FSCatalogInfo", (PyObject *)&FSCatalogInfo_Type);
+ /* Backward-compatible name */
+ Py_INCREF(&FSCatalogInfo_Type);
+ PyModule_AddObject(m, "FSCatalogInfoType", (PyObject *)&FSCatalogInfo_Type);
FInfo_Type.ob_type = &PyType_Type;
if (PyType_Ready(&FInfo_Type) < 0) return;
Index: filescan.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Modules/file/filescan.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** filescan.py 9 Jan 2003 23:37:36 -0000 1.6
--- filescan.py 12 Jan 2003 23:01:46 -0000 1.7
***************
*** 180,193 ****
[('OptFSRefPtr', 'fromFile', 'InMode')]),
! # FSCatalogInfo input handling
! ([('FSCatalogInfoBitmap', 'whichInfo', 'InMode'),
! ('FSCatalogInfo_ptr', 'catalogInfo', 'InMode')],
! [('FSCatalogInfoAndBitmap_in', 'catalogInfo', 'InMode')]),
!
! # FSCatalogInfo output handling
! ([('FSCatalogInfoBitmap', 'whichInfo', 'InMode'),
! ('FSCatalogInfo', 'catalogInfo', 'OutMode')],
! [('FSCatalogInfoAndBitmap_out', 'catalogInfo', 'InOutMode')]),
!
]
--- 180,193 ----
[('OptFSRefPtr', 'fromFile', 'InMode')]),
! ## # FSCatalogInfo input handling
! ## ([('FSCatalogInfoBitmap', 'whichInfo', 'InMode'),
! ## ('FSCatalogInfo_ptr', 'catalogInfo', 'InMode')],
! ## [('FSCatalogInfoAndBitmap_in', 'catalogInfo', 'InMode')]),
! ##
! ## # FSCatalogInfo output handling
! ## ([('FSCatalogInfoBitmap', 'whichInfo', 'InMode'),
! ## ('FSCatalogInfo', 'catalogInfo', 'OutMode')],
! ## [('FSCatalogInfoAndBitmap_out', 'catalogInfo', 'InOutMode')]),
! ##
]
Index: filesupport.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Modules/file/filesupport.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** filesupport.py 9 Jan 2003 23:37:37 -0000 1.10
--- filesupport.py 12 Jan 2003 23:01:46 -0000 1.11
***************
*** 58,63 ****
def declare(self, name):
! Output("PyObject *%s__object;", name)
! Output("FSCatalogInfoBitname %s__bitmap;", name)
Output("FSCatalogInfo %s;", name)
--- 58,63 ----
def declare(self, name):
! Output("PyObject *%s__object = NULL;", name)
! Output("FSCatalogInfoBitmap %s__bitmap = 0;", name)
Output("FSCatalogInfo %s;", name)
***************
*** 69,76 ****
def getargsCheck(self, name):
! Output("convert_FSCatalogInfo(%s__object, %s__bitmap, %s);", name, name, name)
def passOutput(self, name):
! return "%s__bitmap, %s"% (name, name)
def mkvalueFormat(self):
--- 69,79 ----
def getargsCheck(self, name):
! Output("if (!convert_FSCatalogInfo(%s__object, %s__bitmap, &%s)) return NULL;", name, name, name)
+ def passInput(self, name):
+ return "%s__bitmap, &%s"% (name, name)
+
def passOutput(self, name):
! return "%s__bitmap, &%s"% (name, name)
def mkvalueFormat(self):
***************
*** 81,85 ****
def xxxxmkvalueCheck(self, name):
! Output("%s__object = new_FSCatalogInfo(%s__bitmap, %s);", name, name)
class FSCatalogInfoAndBitmap_inType(FSCatalogInfoAndBitmapType, InputOnlyMixIn):
--- 84,88 ----
def xxxxmkvalueCheck(self, name):
! Output("if ((%s__object = new_FSCatalogInfo(%s__bitmap, &%s)) == NULL) return NULL;", name, name)
class FSCatalogInfoAndBitmap_inType(FSCatalogInfoAndBitmapType, InputOnlyMixIn):
***************
*** 108,113 ****
FSRef_ptr = OpaqueType("FSRef", "FSRef")
OptFSRefPtr = OptionalFSxxxType("FSRef", "BUG", "myPyMac_GetOptFSRefPtr")
! FSCatalogInfoAndBitmap_in = FSCatalogInfoAndBitmap_inType()
! FSCatalogInfoAndBitmap_out = FSCatalogInfoAndBitmap_outType()
# To be done:
--- 111,116 ----
FSRef_ptr = OpaqueType("FSRef", "FSRef")
OptFSRefPtr = OptionalFSxxxType("FSRef", "BUG", "myPyMac_GetOptFSRefPtr")
! FSCatalogInfo = OpaqueType("FSCatalogInfo", "FSCatalogInfo")
! FSCatalogInfo_ptr = OpaqueType("FSCatalogInfo", "FSCatalogInfo")
# To be done:
***************
*** 154,157 ****
--- 157,175 ----
/*
+ ** UTCDateTime records
+ */
+ static int
+ UTCDateTime_Convert(PyObject *v, UTCDateTime *ptr)
+ {
+ return PyArg_Parse(v, "(HlH)", &ptr->highSeconds, &ptr->lowSeconds, &ptr->fraction);
+ }
+
+ static PyObject *
+ UTCDateTime_New(UTCDateTime *ptr)
+ {
+ return Py_BuildValue("(HlH)", ptr->highSeconds, ptr->lowSeconds, ptr->fraction);
+ }
+
+ /*
** Optional fsspec and fsref pointers. None will pass NULL
*/
***************
*** 185,189 ****
return Py_BuildValue("u#", itself->unicode, itself->length);
}
-
"""
--- 203,206 ----
***************
*** 306,309 ****
--- 323,483 ----
# Our object types:
+ class FSCatalogInfoDefinition(PEP253Mixin, ObjectDefinition):
+ getsetlist = [
+ ("nodeFlags",
+ "return Py_BuildValue(\"H\", self->ob_itself.nodeFlags);",
+ "return PyArg_Parse(v, \"H\", &self->ob_itself.nodeFlags)-1;",
+ None
+ ),
+ ("volume",
+ "return Py_BuildValue(\"h\", self->ob_itself.volume);",
+ "return PyArg_Parse(v, \"h\", &self->ob_itself.volume)-1;",
+ None
+ ),
+ ("parentDirID",
+ "return Py_BuildValue(\"l\", self->ob_itself.parentDirID);",
+ "return PyArg_Parse(v, \"l\", &self->ob_itself.parentDirID)-1;",
+ None
+ ),
+ ("nodeID",
+ "return Py_BuildValue(\"l\", self->ob_itself.nodeID);",
+ "return PyArg_Parse(v, \"l\", &self->ob_itself.nodeID)-1;",
+ None
+ ),
+ ("createDate",
+ "return Py_BuildValue(\"O&\", UTCDateTime_New, &self->ob_itself.createDate);",
+ "return PyArg_Parse(v, \"O&\", UTCDateTime_Convert, &self->ob_itself.createDate)-1;",
+ None
+ ),
+ ("contentModDate",
+ "return Py_BuildValue(\"O&\", UTCDateTime_New, &self->ob_itself.contentModDate);",
+ "return PyArg_Parse(v, \"O&\", UTCDateTime_Convert, &self->ob_itself.contentModDate)-1;",
+ None
+ ),
+ ("attributeModDate",
+ "return Py_BuildValue(\"O&\", UTCDateTime_New, &self->ob_itself.attributeModDate);",
+ "return PyArg_Parse(v, \"O&\", UTCDateTime_Convert, &self->ob_itself.attributeModDate)-1;",
+ None
+ ),
+ ("accessDate",
+ "return Py_BuildValue(\"O&\", UTCDateTime_New, &self->ob_itself.accessDate);",
+ "return PyArg_Parse(v, \"O&\", UTCDateTime_Convert, &self->ob_itself.accessDate)-1;",
+ None
+ ),
+ ("backupDate",
+ "return Py_BuildValue(\"O&\", UTCDateTime_New, &self->ob_itself.backupDate);",
+ "return PyArg_Parse(v, \"O&\", UTCDateTime_Convert, &self->ob_itself.backupDate)-1;",
+ None
+ ),
+ ("permissions",
+ "return Py_BuildValue(\"(llll)\", self->ob_itself.permissions[0], self->ob_itself.permissions[1], self->ob_itself.permissions[2], self->ob_itself.permissions[3]);",
+ "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;",
+ None
+ ),
+ # XXXX FinderInfo TBD
+ # XXXX FinderXInfo TBD
+ ("valence",
+ "return Py_BuildValue(\"l\", self->ob_itself.valence);",
+ "return PyArg_Parse(v, \"l\", &self->ob_itself.valence)-1;",
+ None
+ ),
+ ("dataLogicalSize",
+ "return Py_BuildValue(\"l\", self->ob_itself.dataLogicalSize);",
+ "return PyArg_Parse(v, \"l\", &self->ob_itself.dataLogicalSize)-1;",
+ None
+ ),
+ ("dataPhysicalSize",
+ "return Py_BuildValue(\"l\", self->ob_itself.dataPhysicalSize);",
+ "return PyArg_Parse(v, \"l\", &self->ob_itself.dataPhysicalSize)-1;",
+ None
+ ),
+ ("rsrcLogicalSize",
+ "return Py_BuildValue(\"l\", self->ob_itself.rsrcLogicalSize);",
+ "return PyArg_Parse(v, \"l\", &self->ob_itself.rsrcLogicalSize)-1;",
+ None
+ ),
+ ("rsrcPhysicalSize",
+ "return Py_BuildValue(\"l\", self->ob_itself.rsrcPhysicalSize);",
+ "return PyArg_Parse(v, \"l\", &self->ob_itself.rsrcPhysicalSize)-1;",
+ None
+ ),
+ ("sharingFlags",
+ "return Py_BuildValue(\"l\", self->ob_itself.sharingFlags);",
+ "return PyArg_Parse(v, \"l\", &self->ob_itself.sharingFlags)-1;",
+ None
+ ),
+ ("userPrivileges",
+ "return Py_BuildValue(\"b\", self->ob_itself.userPrivileges);",
+ "return PyArg_Parse(v, \"b\", &self->ob_itself.userPrivileges)-1;",
+ None
+ ),
+ ]
+ # The same info, but in a different form
+ INITFORMAT = "HhllO&O&O&O&O&(llll)llllllb"
+ INITARGS = """&((FSCatalogInfoObject *)self)->ob_itself.nodeFlags,
+ &((FSCatalogInfoObject *)self)->ob_itself.volume,
+ &((FSCatalogInfoObject *)self)->ob_itself.parentDirID,
+ &((FSCatalogInfoObject *)self)->ob_itself.nodeID,
+ UTCDateTime_Convert, &((FSCatalogInfoObject *)self)->ob_itself.createDate,
+ UTCDateTime_Convert, &((FSCatalogInfoObject *)self)->ob_itself.contentModDate,
+ UTCDateTime_Convert, &((FSCatalogInfoObject *)self)->ob_itself.attributeModDate,
+ UTCDateTime_Convert, &((FSCatalogInfoObject *)self)->ob_itself.accessDate,
+ UTCDateTime_Convert, &((FSCatalogInfoObject *)self)->ob_itself.backupDate,
+ &((FSCatalogInfoObject *)self)->ob_itself.permissions[0],
+ &((FSCatalogInfoObject *)self)->ob_itself.permissions[1],
+ &((FSCatalogInfoObject *)self)->ob_itself.permissions[2],
+ &((FSCatalogInfoObject *)self)->ob_itself.permissions[3],
+ &((FSCatalogInfoObject *)self)->ob_itself.valence,
+ &((FSCatalogInfoObject *)self)->ob_itself.dataLogicalSize,
+ &((FSCatalogInfoObject *)self)->ob_itself.dataPhysicalSize,
+ &((FSCatalogInfoObject *)self)->ob_itself.rsrcLogicalSize,
+ &((FSCatalogInfoObject *)self)->ob_itself.rsrcPhysicalSize,
+ &((FSCatalogInfoObject *)self)->ob_itself.sharingFlags,
+ &((FSCatalogInfoObject *)self)->ob_itself.userPrivileges"""
+ INITNAMES = """
+ "nodeFlags",
+ "volume",
+ "parentDirID",
+ "nodeID",
+ "createDate",
+ "contentModDate",
+ "atributeModDate",
+ "accessDate",
+ "backupDate",
+ "permissions",
+ "valence",
+ "dataLogicalSize",
+ "dataPhysicalSize",
+ "rsrcLogicalSize",
+ "rsrcPhysicalSize",
+ "sharingFlags",
+ "userPrivileges"
+ """
+
+ def __init__(self, name, prefix, itselftype):
+ ObjectDefinition.__init__(self, name, prefix, itselftype)
+ self.argref = "*" # Store FSSpecs, but pass them by address
+
+ def outputCheckNewArg(self):
+ Output("if (itself == NULL) return Py_None;")
+
+ def output_tp_newBody(self):
+ Output("PyObject *self;");
+ Output()
+ Output("if ((self = type->tp_alloc(type, 0)) == NULL) return NULL;")
+ Output("memset(&((%s *)self)->ob_itself, 0, sizeof(%s));",
+ self.objecttype, self.itselftype)
+ Output("return self;")
+
+ def output_tp_initBody(self):
+ Output("static char *kw[] = {%s, 0};", self.INITNAMES)
+ Output()
+ Output("if (!PyArg_ParseTupleAndKeywords(args, kwds, \"|%s\", kw, %s))",
+ self.INITFORMAT, self.INITARGS)
+ OutLbrace()
+ Output("return -1;")
+ OutRbrace()
+ Output("return 0;")
+
class FInfoDefinition(PEP253Mixin, ObjectDefinition):
getsetlist = [
***************
*** 353,357 ****
def output_tp_initBody(self):
Output("%s *itself = NULL;", self.itselftype)
! Output("char *kw[] = {\"itself\", 0};")
Output()
Output("if (PyArg_ParseTupleAndKeywords(args, kwds, \"|O&\", kw, FInfo_Convert, &itself))")
--- 527,531 ----
def output_tp_initBody(self):
Output("%s *itself = NULL;", self.itselftype)
! Output("static char *kw[] = {\"itself\", 0};")
Output()
Output("if (PyArg_ParseTupleAndKeywords(args, kwds, \"|O&\", kw, FInfo_Convert, &itself))")
***************
*** 395,399 ****
Output("char *rawdata = NULL;")
Output("int rawdatalen = 0;")
! Output("char *kw[] = {\"itself\", \"rawdata\", 0};")
Output()
Output("if (!PyArg_ParseTupleAndKeywords(args, kwds, \"|Os#\", kw, &v, &rawdata, &rawdatalen))")
--- 569,573 ----
Output("char *rawdata = NULL;")
Output("int rawdatalen = 0;")
! Output("static char *kw[] = {\"itself\", \"rawdata\", 0};")
Output()
Output("if (!PyArg_ParseTupleAndKeywords(args, kwds, \"|Os#\", kw, &v, &rawdata, &rawdatalen))")
***************
*** 468,472 ****
Output("char *rawdata = NULL;")
Output("int rawdatalen = 0;")
! Output("char *kw[] = {\"itself\", \"rawdata\", 0};")
Output()
Output("if (!PyArg_ParseTupleAndKeywords(args, kwds, \"|Os#\", kw, &v, &rawdata, &rawdatalen))")
--- 642,646 ----
Output("char *rawdata = NULL;")
Output("int rawdatalen = 0;")
! Output("static char *kw[] = {\"itself\", \"rawdata\", 0};")
Output()
Output("if (!PyArg_ParseTupleAndKeywords(args, kwds, \"|Os#\", kw, &v, &rawdata, &rawdatalen))")
***************
*** 544,548 ****
Output("int rawdatalen = 0;")
Output("Handle h;")
! Output("char *kw[] = {\"itself\", \"rawdata\", 0};")
Output()
Output("if (!PyArg_ParseTupleAndKeywords(args, kwds, \"|O&s#\", kw, %s_Convert, &itself, &rawdata, &rawdatalen))",
--- 718,722 ----
Output("int rawdatalen = 0;")
Output("Handle h;")
! Output("static char *kw[] = {\"itself\", \"rawdata\", 0};")
Output()
Output("if (!PyArg_ParseTupleAndKeywords(args, kwds, \"|O&s#\", kw, %s_Convert, &itself, &rawdata, &rawdatalen))",
***************
*** 596,599 ****
--- 770,774 ----
longname=LONGMODNAME)
+ fscataloginfoobject = FSCatalogInfoDefinition('FSCatalogInfo', 'FSCatalogInfo', 'FSCatalogInfo')
finfoobject = FInfoDefinition('FInfo', 'FInfo', 'FInfo')
aliasobject = AliasDefinition('Alias', 'Alias', 'AliasHandle')
***************
*** 601,604 ****
--- 776,780 ----
fsrefobject = FSRefDefinition('FSRef', 'FSRef', 'FSRef')
+ module.addobject(fscataloginfoobject)
module.addobject(finfoobject)
module.addobject(aliasobject)