Ignore:
Timestamp:
Mar 19, 2014, 11:31:01 PM (11 years ago)
Author:
dmik
Message:

python: Merge vendor 2.7.6 to trunk.

Location:
python/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • python/trunk

  • python/trunk/Mac/Modules/file/_Filemodule.c

    r2 r391  
    99
    1010#ifndef HAVE_OSX105_SDK
    11 typedef SInt16  FSIORefNum;
     11typedef SInt16  FSIORefNum;
    1212#endif
    1313
    1414/* Macro to test whether a weak-loaded CFM function exists */
    1515#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL )  {\
    16         PyErr_SetString(PyExc_NotImplementedError, \
    17         "Not available in this shared library/OS version"); \
    18         return NULL; \
     16    PyErr_SetString(PyExc_NotImplementedError, \
     17    "Not available in this shared library/OS version"); \
     18    return NULL; \
    1919    }} while(0)
    2020
     
    3636#define PyMac_GetFSRef _PyMac_GetFSRef
    3737
    38 #else   /* !USE_TOOLBOX_OBJECT_GLUE */
     38#else   /* !USE_TOOLBOX_OBJECT_GLUE */
    3939
    4040#ifndef __LP64__
     
    4646extern PyObject *PyMac_BuildFSRef(FSRef *spec);
    4747
    48 #endif  /* !USE_TOOLBOX_OBJECT_GLUE */
     48#endif  /* !USE_TOOLBOX_OBJECT_GLUE */
    4949
    5050/* Forward declarations */
     
    7070UTCDateTime_Convert(PyObject *v, UTCDateTime *ptr)
    7171{
    72         return PyArg_Parse(v, "(HlH)", &ptr->highSeconds, &ptr->lowSeconds, &ptr->fraction);
     72    return PyArg_Parse(v, "(HlH)", &ptr->highSeconds, &ptr->lowSeconds, &ptr->fraction);
    7373}
    7474
     
    7676UTCDateTime_New(UTCDateTime *ptr)
    7777{
    78         return Py_BuildValue("(HlH)", ptr->highSeconds, ptr->lowSeconds, ptr->fraction);
     78    return Py_BuildValue("(HlH)", ptr->highSeconds, ptr->lowSeconds, ptr->fraction);
    7979}
    8080
     
    8686myPyMac_GetOptFSSpecPtr(PyObject *v, FSSpec **spec)
    8787{
    88         if (v == Py_None) {
    89                 *spec = NULL;
    90                 return 1;
    91         }
    92         return PyMac_GetFSSpec(v, *spec);
     88    if (v == Py_None) {
     89        *spec = NULL;
     90        return 1;
     91    }
     92    return PyMac_GetFSSpec(v, *spec);
    9393}
    9494#endif /* !__LP64__ */
     
    9797myPyMac_GetOptFSRefPtr(PyObject *v, FSRef **ref)
    9898{
    99         if (v == Py_None) {
    100                 *ref = NULL;
    101                 return 1;
    102         }
    103         return PyMac_GetFSRef(v, *ref);
     99    if (v == Py_None) {
     100        *ref = NULL;
     101        return 1;
     102    }
     103    return PyMac_GetFSRef(v, *ref);
    104104}
    105105
     
    111111{
    112112
    113         return Py_BuildValue("u#", itself->unicode, itself->length);
     113    return Py_BuildValue("u#", itself->unicode, itself->length);
    114114}
    115115
     
    118118_PyMac_GetFullPathname(FSSpec *fss, char *path, int len)
    119119{
    120         FSRef fsr;
    121         OSErr err;
    122 
    123         *path = '\0';
    124         err = FSpMakeFSRef(fss, &fsr);
    125         if (err == fnfErr) {
    126                 /* FSSpecs can point to non-existing files, fsrefs can't. */
    127                 FSSpec fss2;
    128                 int tocopy;
    129 
    130                 err = FSMakeFSSpec(fss->vRefNum, fss->parID,
    131                                    (unsigned char*)"", &fss2);
    132                 if (err)
    133                         return err;
    134                 err = FSpMakeFSRef(&fss2, &fsr);
    135                 if (err)
    136                         return err;
    137                 err = (OSErr)FSRefMakePath(&fsr, (unsigned char*)path, len-1);
    138                 if (err)
    139                         return err;
    140                 /* This part is not 100% safe: we append the filename part, but
    141                 ** I'm not sure that we don't run afoul of the various 8bit
    142                 ** encodings here. Will have to look this up at some point...
    143                 */
    144                 strcat(path, "/");
    145                 tocopy = fss->name[0];
    146                 if ((strlen(path) + tocopy) >= len)
    147                         tocopy = len - strlen(path) - 1;
    148                 if (tocopy > 0)
    149                         strncat(path, (char*)fss->name+1, tocopy);
    150         }
    151         else {
    152                 if (err)
    153                         return err;
    154                 err = (OSErr)FSRefMakePath(&fsr, (unsigned char*)path, len);
    155                 if (err)
    156                         return err;
    157         }
    158         return 0;
     120    FSRef fsr;
     121    OSErr err;
     122
     123    *path = '\0';
     124    err = FSpMakeFSRef(fss, &fsr);
     125    if (err == fnfErr) {
     126        /* FSSpecs can point to non-existing files, fsrefs can't. */
     127        FSSpec fss2;
     128        int tocopy;
     129
     130        err = FSMakeFSSpec(fss->vRefNum, fss->parID,
     131                           (unsigned char*)"", &fss2);
     132        if (err)
     133            return err;
     134        err = FSpMakeFSRef(&fss2, &fsr);
     135        if (err)
     136            return err;
     137        err = (OSErr)FSRefMakePath(&fsr, (unsigned char*)path, len-1);
     138        if (err)
     139            return err;
     140        /* This part is not 100% safe: we append the filename part, but
     141        ** I'm not sure that we don't run afoul of the various 8bit
     142        ** encodings here. Will have to look this up at some point...
     143        */
     144        strcat(path, "/");
     145        tocopy = fss->name[0];
     146        if ((strlen(path) + tocopy) >= len)
     147            tocopy = len - strlen(path) - 1;
     148        if (tocopy > 0)
     149            strncat(path, (char*)fss->name+1, tocopy);
     150    }
     151    else {
     152        if (err)
     153            return err;
     154        err = (OSErr)FSRefMakePath(&fsr, (unsigned char*)path, len);
     155        if (err)
     156            return err;
     157    }
     158    return 0;
    159159}
    160160#endif /* !__LP64__ */
     
    170170
    171171typedef struct FSCatalogInfoObject {
    172         PyObject_HEAD
    173         FSCatalogInfo ob_itself;
     172    PyObject_HEAD
     173    FSCatalogInfo ob_itself;
    174174} FSCatalogInfoObject;
    175175
    176176static PyObject *FSCatalogInfo_New(FSCatalogInfo *itself)
    177177{
    178         FSCatalogInfoObject *it;
    179         if (itself == NULL) { Py_INCREF(Py_None); return Py_None; }
    180         it = PyObject_NEW(FSCatalogInfoObject, &FSCatalogInfo_Type);
    181         if (it == NULL) return NULL;
    182         it->ob_itself = *itself;
    183         return (PyObject *)it;
     178    FSCatalogInfoObject *it;
     179    if (itself == NULL) { Py_INCREF(Py_None); return Py_None; }
     180    it = PyObject_NEW(FSCatalogInfoObject, &FSCatalogInfo_Type);
     181    if (it == NULL) return NULL;
     182    it->ob_itself = *itself;
     183    return (PyObject *)it;
    184184}
    185185
    186186static int FSCatalogInfo_Convert(PyObject *v, FSCatalogInfo *p_itself)
    187187{
    188         if (!FSCatalogInfo_Check(v))
    189         {
    190                 PyErr_SetString(PyExc_TypeError, "FSCatalogInfo required");
    191                 return 0;
    192         }
    193         *p_itself = ((FSCatalogInfoObject *)v)->ob_itself;
    194         return 1;
     188    if (!FSCatalogInfo_Check(v))
     189    {
     190        PyErr_SetString(PyExc_TypeError, "FSCatalogInfo required");
     191        return 0;
     192    }
     193    *p_itself = ((FSCatalogInfoObject *)v)->ob_itself;
     194    return 1;
    195195}
    196196
    197197static void FSCatalogInfo_dealloc(FSCatalogInfoObject *self)
    198198{
    199         /* Cleanup of self->ob_itself goes here */
    200         self->ob_type->tp_free((PyObject *)self);
     199    /* Cleanup of self->ob_itself goes here */
     200    self->ob_type->tp_free((PyObject *)self);
    201201}
    202202
    203203static PyMethodDef FSCatalogInfo_methods[] = {
    204         {NULL, NULL, 0}
     204    {NULL, NULL, 0}
    205205};
    206206
    207207static PyObject *FSCatalogInfo_get_nodeFlags(FSCatalogInfoObject *self, void *closure)
    208208{
    209         return Py_BuildValue("H", self->ob_itself.nodeFlags);
     209    return Py_BuildValue("H", self->ob_itself.nodeFlags);
    210210}
    211211
    212212static int FSCatalogInfo_set_nodeFlags(FSCatalogInfoObject *self, PyObject *v, void *closure)
    213213{
    214         return PyArg_Parse(v, "H", &self->ob_itself.nodeFlags)-1;
    215         return 0;
     214    return PyArg_Parse(v, "H", &self->ob_itself.nodeFlags)-1;
     215    return 0;
    216216}
    217217
    218218static PyObject *FSCatalogInfo_get_volume(FSCatalogInfoObject *self, void *closure)
    219219{
    220         return Py_BuildValue("h", self->ob_itself.volume);
     220    return Py_BuildValue("h", self->ob_itself.volume);
    221221}
    222222
    223223static int FSCatalogInfo_set_volume(FSCatalogInfoObject *self, PyObject *v, void *closure)
    224224{
    225         return PyArg_Parse(v, "h", &self->ob_itself.volume)-1;
    226         return 0;
     225    return PyArg_Parse(v, "h", &self->ob_itself.volume)-1;
     226    return 0;
    227227}
    228228
    229229static PyObject *FSCatalogInfo_get_parentDirID(FSCatalogInfoObject *self, void *closure)
    230230{
    231         return Py_BuildValue("l", self->ob_itself.parentDirID);
     231    return Py_BuildValue("l", self->ob_itself.parentDirID);
    232232}
    233233
    234234static int FSCatalogInfo_set_parentDirID(FSCatalogInfoObject *self, PyObject *v, void *closure)
    235235{
    236         return PyArg_Parse(v, "l", &self->ob_itself.parentDirID)-1;
    237         return 0;
     236    return PyArg_Parse(v, "l", &self->ob_itself.parentDirID)-1;
     237    return 0;
    238238}
    239239
    240240static PyObject *FSCatalogInfo_get_nodeID(FSCatalogInfoObject *self, void *closure)
    241241{
    242         return Py_BuildValue("l", self->ob_itself.nodeID);
     242    return Py_BuildValue("l", self->ob_itself.nodeID);
    243243}
    244244
    245245static int FSCatalogInfo_set_nodeID(FSCatalogInfoObject *self, PyObject *v, void *closure)
    246246{
    247         return PyArg_Parse(v, "l", &self->ob_itself.nodeID)-1;
    248         return 0;
     247    return PyArg_Parse(v, "l", &self->ob_itself.nodeID)-1;
     248    return 0;
    249249}
    250250
    251251static PyObject *FSCatalogInfo_get_createDate(FSCatalogInfoObject *self, void *closure)
    252252{
    253         return Py_BuildValue("O&", UTCDateTime_New, &self->ob_itself.createDate);
     253    return Py_BuildValue("O&", UTCDateTime_New, &self->ob_itself.createDate);
    254254}
    255255
    256256static int FSCatalogInfo_set_createDate(FSCatalogInfoObject *self, PyObject *v, void *closure)
    257257{
    258         return PyArg_Parse(v, "O&", UTCDateTime_Convert, &self->ob_itself.createDate)-1;
    259         return 0;
     258    return PyArg_Parse(v, "O&", UTCDateTime_Convert, &self->ob_itself.createDate)-1;
     259    return 0;
    260260}
    261261
    262262static PyObject *FSCatalogInfo_get_contentModDate(FSCatalogInfoObject *self, void *closure)
    263263{
    264         return Py_BuildValue("O&", UTCDateTime_New, &self->ob_itself.contentModDate);
     264    return Py_BuildValue("O&", UTCDateTime_New, &self->ob_itself.contentModDate);
    265265}
    266266
    267267static int FSCatalogInfo_set_contentModDate(FSCatalogInfoObject *self, PyObject *v, void *closure)
    268268{
    269         return PyArg_Parse(v, "O&", UTCDateTime_Convert, &self->ob_itself.contentModDate)-1;
    270         return 0;
     269    return PyArg_Parse(v, "O&", UTCDateTime_Convert, &self->ob_itself.contentModDate)-1;
     270    return 0;
    271271}
    272272
    273273static PyObject *FSCatalogInfo_get_attributeModDate(FSCatalogInfoObject *self, void *closure)
    274274{
    275         return Py_BuildValue("O&", UTCDateTime_New, &self->ob_itself.attributeModDate);
     275    return Py_BuildValue("O&", UTCDateTime_New, &self->ob_itself.attributeModDate);
    276276}
    277277
    278278static int FSCatalogInfo_set_attributeModDate(FSCatalogInfoObject *self, PyObject *v, void *closure)
    279279{
    280         return PyArg_Parse(v, "O&", UTCDateTime_Convert, &self->ob_itself.attributeModDate)-1;
    281         return 0;
     280    return PyArg_Parse(v, "O&", UTCDateTime_Convert, &self->ob_itself.attributeModDate)-1;
     281    return 0;
    282282}
    283283
    284284static PyObject *FSCatalogInfo_get_accessDate(FSCatalogInfoObject *self, void *closure)
    285285{
    286         return Py_BuildValue("O&", UTCDateTime_New, &self->ob_itself.accessDate);
     286    return Py_BuildValue("O&", UTCDateTime_New, &self->ob_itself.accessDate);
    287287}
    288288
    289289static int FSCatalogInfo_set_accessDate(FSCatalogInfoObject *self, PyObject *v, void *closure)
    290290{
    291         return PyArg_Parse(v, "O&", UTCDateTime_Convert, &self->ob_itself.accessDate)-1;
    292         return 0;
     291    return PyArg_Parse(v, "O&", UTCDateTime_Convert, &self->ob_itself.accessDate)-1;
     292    return 0;
    293293}
    294294
    295295static PyObject *FSCatalogInfo_get_backupDate(FSCatalogInfoObject *self, void *closure)
    296296{
    297         return Py_BuildValue("O&", UTCDateTime_New, &self->ob_itself.backupDate);
     297    return Py_BuildValue("O&", UTCDateTime_New, &self->ob_itself.backupDate);
    298298}
    299299
    300300static int FSCatalogInfo_set_backupDate(FSCatalogInfoObject *self, PyObject *v, void *closure)
    301301{
    302         return PyArg_Parse(v, "O&", UTCDateTime_Convert, &self->ob_itself.backupDate)-1;
    303         return 0;
     302    return PyArg_Parse(v, "O&", UTCDateTime_Convert, &self->ob_itself.backupDate)-1;
     303    return 0;
    304304}
    305305
    306306static PyObject *FSCatalogInfo_get_permissions(FSCatalogInfoObject *self, void *closure)
    307307{
    308         FSPermissionInfo* info = (FSPermissionInfo*)&(self->ob_itself.permissions);
    309         return Py_BuildValue("(llll)", info->userID, info->groupID, info->userAccess, info->mode);
     308    FSPermissionInfo* info = (FSPermissionInfo*)&(self->ob_itself.permissions);
     309    return Py_BuildValue("(llll)", info->userID, info->groupID, info->userAccess, info->mode);
    310310}
    311311
    312312static int FSCatalogInfo_set_permissions(FSCatalogInfoObject *self, PyObject *v, void *closure)
    313313{
    314         long userID;
    315         long groupID;
    316         long userAccess;
    317         long mode;
    318         int r;
    319 
    320         FSPermissionInfo* info = (FSPermissionInfo*)&(self->ob_itself.permissions);
    321 
    322         r = PyArg_Parse(v, "(llll)", &userID, &groupID, &userAccess, &mode);
    323         if (!r) {
    324                 return -1;
    325         }
    326         info->userID = userID;
    327         info->groupID = groupID;
    328         info->userAccess = userAccess;
    329         info->mode = mode;
    330         return 0;
     314    long userID;
     315    long groupID;
     316    long userAccess;
     317    long mode;
     318    int r;
     319
     320    FSPermissionInfo* info = (FSPermissionInfo*)&(self->ob_itself.permissions);
     321
     322    r = PyArg_Parse(v, "(llll)", &userID, &groupID, &userAccess, &mode);
     323    if (!r) {
     324        return -1;
     325    }
     326    info->userID = userID;
     327    info->groupID = groupID;
     328    info->userAccess = userAccess;
     329    info->mode = mode;
     330    return 0;
    331331}
    332332
    333333static PyObject *FSCatalogInfo_get_valence(FSCatalogInfoObject *self, void *closure)
    334334{
    335         return Py_BuildValue("l", self->ob_itself.valence);
     335    return Py_BuildValue("l", self->ob_itself.valence);
    336336}
    337337
    338338static int FSCatalogInfo_set_valence(FSCatalogInfoObject *self, PyObject *v, void *closure)
    339339{
    340         return PyArg_Parse(v, "l", &self->ob_itself.valence)-1;
    341         return 0;
     340    return PyArg_Parse(v, "l", &self->ob_itself.valence)-1;
     341    return 0;
    342342}
    343343
    344344static PyObject *FSCatalogInfo_get_dataLogicalSize(FSCatalogInfoObject *self, void *closure)
    345345{
    346         return Py_BuildValue("l", self->ob_itself.dataLogicalSize);
     346    return Py_BuildValue("l", self->ob_itself.dataLogicalSize);
    347347}
    348348
    349349static int FSCatalogInfo_set_dataLogicalSize(FSCatalogInfoObject *self, PyObject *v, void *closure)
    350350{
    351         return PyArg_Parse(v, "l", &self->ob_itself.dataLogicalSize)-1;
    352         return 0;
     351    return PyArg_Parse(v, "l", &self->ob_itself.dataLogicalSize)-1;
     352    return 0;
    353353}
    354354
    355355static PyObject *FSCatalogInfo_get_dataPhysicalSize(FSCatalogInfoObject *self, void *closure)
    356356{
    357         return Py_BuildValue("l", self->ob_itself.dataPhysicalSize);
     357    return Py_BuildValue("l", self->ob_itself.dataPhysicalSize);
    358358}
    359359
    360360static int FSCatalogInfo_set_dataPhysicalSize(FSCatalogInfoObject *self, PyObject *v, void *closure)
    361361{
    362         return PyArg_Parse(v, "l", &self->ob_itself.dataPhysicalSize)-1;
    363         return 0;
     362    return PyArg_Parse(v, "l", &self->ob_itself.dataPhysicalSize)-1;
     363    return 0;
    364364}
    365365
    366366static PyObject *FSCatalogInfo_get_rsrcLogicalSize(FSCatalogInfoObject *self, void *closure)
    367367{
    368         return Py_BuildValue("l", self->ob_itself.rsrcLogicalSize);
     368    return Py_BuildValue("l", self->ob_itself.rsrcLogicalSize);
    369369}
    370370
    371371static int FSCatalogInfo_set_rsrcLogicalSize(FSCatalogInfoObject *self, PyObject *v, void *closure)
    372372{
    373         return PyArg_Parse(v, "l", &self->ob_itself.rsrcLogicalSize)-1;
    374         return 0;
     373    return PyArg_Parse(v, "l", &self->ob_itself.rsrcLogicalSize)-1;
     374    return 0;
    375375}
    376376
    377377static PyObject *FSCatalogInfo_get_rsrcPhysicalSize(FSCatalogInfoObject *self, void *closure)
    378378{
    379         return Py_BuildValue("l", self->ob_itself.rsrcPhysicalSize);
     379    return Py_BuildValue("l", self->ob_itself.rsrcPhysicalSize);
    380380}
    381381
    382382static int FSCatalogInfo_set_rsrcPhysicalSize(FSCatalogInfoObject *self, PyObject *v, void *closure)
    383383{
    384         return PyArg_Parse(v, "l", &self->ob_itself.rsrcPhysicalSize)-1;
    385         return 0;
     384    return PyArg_Parse(v, "l", &self->ob_itself.rsrcPhysicalSize)-1;
     385    return 0;
    386386}
    387387
    388388static PyObject *FSCatalogInfo_get_sharingFlags(FSCatalogInfoObject *self, void *closure)
    389389{
    390         return Py_BuildValue("l", self->ob_itself.sharingFlags);
     390    return Py_BuildValue("l", self->ob_itself.sharingFlags);
    391391}
    392392
    393393static int FSCatalogInfo_set_sharingFlags(FSCatalogInfoObject *self, PyObject *v, void *closure)
    394394{
    395         return PyArg_Parse(v, "l", &self->ob_itself.sharingFlags)-1;
    396         return 0;
     395    return PyArg_Parse(v, "l", &self->ob_itself.sharingFlags)-1;
     396    return 0;
    397397}
    398398
    399399static PyObject *FSCatalogInfo_get_userPrivileges(FSCatalogInfoObject *self, void *closure)
    400400{
    401         return Py_BuildValue("b", self->ob_itself.userPrivileges);
     401    return Py_BuildValue("b", self->ob_itself.userPrivileges);
    402402}
    403403
    404404static int FSCatalogInfo_set_userPrivileges(FSCatalogInfoObject *self, PyObject *v, void *closure)
    405405{
    406         return PyArg_Parse(v, "b", &self->ob_itself.userPrivileges)-1;
    407         return 0;
     406    return PyArg_Parse(v, "b", &self->ob_itself.userPrivileges)-1;
     407    return 0;
    408408}
    409409
    410410static PyGetSetDef FSCatalogInfo_getsetlist[] = {
    411         {"nodeFlags", (getter)FSCatalogInfo_get_nodeFlags, (setter)FSCatalogInfo_set_nodeFlags, NULL},
    412         {"volume", (getter)FSCatalogInfo_get_volume, (setter)FSCatalogInfo_set_volume, NULL},
    413         {"parentDirID", (getter)FSCatalogInfo_get_parentDirID, (setter)FSCatalogInfo_set_parentDirID, NULL},
    414         {"nodeID", (getter)FSCatalogInfo_get_nodeID, (setter)FSCatalogInfo_set_nodeID, NULL},
    415         {"createDate", (getter)FSCatalogInfo_get_createDate, (setter)FSCatalogInfo_set_createDate, NULL},
    416         {"contentModDate", (getter)FSCatalogInfo_get_contentModDate, (setter)FSCatalogInfo_set_contentModDate, NULL},
    417         {"attributeModDate", (getter)FSCatalogInfo_get_attributeModDate, (setter)FSCatalogInfo_set_attributeModDate, NULL},
    418         {"accessDate", (getter)FSCatalogInfo_get_accessDate, (setter)FSCatalogInfo_set_accessDate, NULL},
    419         {"backupDate", (getter)FSCatalogInfo_get_backupDate, (setter)FSCatalogInfo_set_backupDate, NULL},
    420         {"permissions", (getter)FSCatalogInfo_get_permissions, (setter)FSCatalogInfo_set_permissions, NULL},
    421         {"valence", (getter)FSCatalogInfo_get_valence, (setter)FSCatalogInfo_set_valence, NULL},
    422         {"dataLogicalSize", (getter)FSCatalogInfo_get_dataLogicalSize, (setter)FSCatalogInfo_set_dataLogicalSize, NULL},
    423         {"dataPhysicalSize", (getter)FSCatalogInfo_get_dataPhysicalSize, (setter)FSCatalogInfo_set_dataPhysicalSize, NULL},
    424         {"rsrcLogicalSize", (getter)FSCatalogInfo_get_rsrcLogicalSize, (setter)FSCatalogInfo_set_rsrcLogicalSize, NULL},
    425         {"rsrcPhysicalSize", (getter)FSCatalogInfo_get_rsrcPhysicalSize, (setter)FSCatalogInfo_set_rsrcPhysicalSize, NULL},
    426         {"sharingFlags", (getter)FSCatalogInfo_get_sharingFlags, (setter)FSCatalogInfo_set_sharingFlags, NULL},
    427         {"userPrivileges", (getter)FSCatalogInfo_get_userPrivileges, (setter)FSCatalogInfo_set_userPrivileges, NULL},
    428         {NULL, NULL, NULL, NULL},
     411    {"nodeFlags", (getter)FSCatalogInfo_get_nodeFlags, (setter)FSCatalogInfo_set_nodeFlags, NULL},
     412    {"volume", (getter)FSCatalogInfo_get_volume, (setter)FSCatalogInfo_set_volume, NULL},
     413    {"parentDirID", (getter)FSCatalogInfo_get_parentDirID, (setter)FSCatalogInfo_set_parentDirID, NULL},
     414    {"nodeID", (getter)FSCatalogInfo_get_nodeID, (setter)FSCatalogInfo_set_nodeID, NULL},
     415    {"createDate", (getter)FSCatalogInfo_get_createDate, (setter)FSCatalogInfo_set_createDate, NULL},
     416    {"contentModDate", (getter)FSCatalogInfo_get_contentModDate, (setter)FSCatalogInfo_set_contentModDate, NULL},
     417    {"attributeModDate", (getter)FSCatalogInfo_get_attributeModDate, (setter)FSCatalogInfo_set_attributeModDate, NULL},
     418    {"accessDate", (getter)FSCatalogInfo_get_accessDate, (setter)FSCatalogInfo_set_accessDate, NULL},
     419    {"backupDate", (getter)FSCatalogInfo_get_backupDate, (setter)FSCatalogInfo_set_backupDate, NULL},
     420    {"permissions", (getter)FSCatalogInfo_get_permissions, (setter)FSCatalogInfo_set_permissions, NULL},
     421    {"valence", (getter)FSCatalogInfo_get_valence, (setter)FSCatalogInfo_set_valence, NULL},
     422    {"dataLogicalSize", (getter)FSCatalogInfo_get_dataLogicalSize, (setter)FSCatalogInfo_set_dataLogicalSize, NULL},
     423    {"dataPhysicalSize", (getter)FSCatalogInfo_get_dataPhysicalSize, (setter)FSCatalogInfo_set_dataPhysicalSize, NULL},
     424    {"rsrcLogicalSize", (getter)FSCatalogInfo_get_rsrcLogicalSize, (setter)FSCatalogInfo_set_rsrcLogicalSize, NULL},
     425    {"rsrcPhysicalSize", (getter)FSCatalogInfo_get_rsrcPhysicalSize, (setter)FSCatalogInfo_set_rsrcPhysicalSize, NULL},
     426    {"sharingFlags", (getter)FSCatalogInfo_get_sharingFlags, (setter)FSCatalogInfo_set_sharingFlags, NULL},
     427    {"userPrivileges", (getter)FSCatalogInfo_get_userPrivileges, (setter)FSCatalogInfo_set_userPrivileges, NULL},
     428    {NULL, NULL, NULL, NULL},
    429429};
    430430
     
    437437static int FSCatalogInfo_tp_init(PyObject *_self, PyObject *_args, PyObject *_kwds)
    438438{
    439         static char *kw[] = {
    440                     "nodeFlags",
    441                     "volume",
    442                     "parentDirID",
    443                     "nodeID",
    444                     "createDate",
    445                     "contentModDate",
    446                     "atributeModDate",
    447                     "accessDate",
    448                     "backupDate",
    449                     "valence",
    450                     "dataLogicalSize",
    451                     "dataPhysicalSize",
    452                     "rsrcLogicalSize",
    453                     "rsrcPhysicalSize",
    454                     "sharingFlags",
    455                     "userPrivileges"
    456                     , 0};
    457 
    458         if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "|HhllO&O&O&O&O&llllllb", kw, &((FSCatalogInfoObject *)_self)->ob_itself.nodeFlags,
    459                     &((FSCatalogInfoObject *)_self)->ob_itself.volume,
    460                     &((FSCatalogInfoObject *)_self)->ob_itself.parentDirID,
    461                     &((FSCatalogInfoObject *)_self)->ob_itself.nodeID,
    462                     UTCDateTime_Convert, &((FSCatalogInfoObject *)_self)->ob_itself.createDate,
    463                     UTCDateTime_Convert, &((FSCatalogInfoObject *)_self)->ob_itself.contentModDate,
    464                     UTCDateTime_Convert, &((FSCatalogInfoObject *)_self)->ob_itself.attributeModDate,
    465                     UTCDateTime_Convert, &((FSCatalogInfoObject *)_self)->ob_itself.accessDate,
    466                     UTCDateTime_Convert, &((FSCatalogInfoObject *)_self)->ob_itself.backupDate,
    467                     &((FSCatalogInfoObject *)_self)->ob_itself.valence,
    468                     &((FSCatalogInfoObject *)_self)->ob_itself.dataLogicalSize,
    469                     &((FSCatalogInfoObject *)_self)->ob_itself.dataPhysicalSize,
    470                     &((FSCatalogInfoObject *)_self)->ob_itself.rsrcLogicalSize,
    471                     &((FSCatalogInfoObject *)_self)->ob_itself.rsrcPhysicalSize,
    472                     &((FSCatalogInfoObject *)_self)->ob_itself.sharingFlags,
    473                     &((FSCatalogInfoObject *)_self)->ob_itself.userPrivileges))
    474         {
    475                 return -1;
    476         }
    477         return 0;
     439    static char *kw[] = {
     440                "nodeFlags",
     441                "volume",
     442                "parentDirID",
     443                "nodeID",
     444                "createDate",
     445                "contentModDate",
     446                "atributeModDate",
     447                "accessDate",
     448                "backupDate",
     449                "valence",
     450                "dataLogicalSize",
     451                "dataPhysicalSize",
     452                "rsrcLogicalSize",
     453                "rsrcPhysicalSize",
     454                "sharingFlags",
     455                "userPrivileges"
     456                , 0};
     457
     458    if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "|HhllO&O&O&O&O&llllllb", kw, &((FSCatalogInfoObject *)_self)->ob_itself.nodeFlags,
     459                &((FSCatalogInfoObject *)_self)->ob_itself.volume,
     460                &((FSCatalogInfoObject *)_self)->ob_itself.parentDirID,
     461                &((FSCatalogInfoObject *)_self)->ob_itself.nodeID,
     462                UTCDateTime_Convert, &((FSCatalogInfoObject *)_self)->ob_itself.createDate,
     463                UTCDateTime_Convert, &((FSCatalogInfoObject *)_self)->ob_itself.contentModDate,
     464                UTCDateTime_Convert, &((FSCatalogInfoObject *)_self)->ob_itself.attributeModDate,
     465                UTCDateTime_Convert, &((FSCatalogInfoObject *)_self)->ob_itself.accessDate,
     466                UTCDateTime_Convert, &((FSCatalogInfoObject *)_self)->ob_itself.backupDate,
     467                &((FSCatalogInfoObject *)_self)->ob_itself.valence,
     468                &((FSCatalogInfoObject *)_self)->ob_itself.dataLogicalSize,
     469                &((FSCatalogInfoObject *)_self)->ob_itself.dataPhysicalSize,
     470                &((FSCatalogInfoObject *)_self)->ob_itself.rsrcLogicalSize,
     471                &((FSCatalogInfoObject *)_self)->ob_itself.rsrcPhysicalSize,
     472                &((FSCatalogInfoObject *)_self)->ob_itself.sharingFlags,
     473                &((FSCatalogInfoObject *)_self)->ob_itself.userPrivileges))
     474    {
     475        return -1;
     476    }
     477    return 0;
    478478}
    479479
     
    482482static PyObject *FSCatalogInfo_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds)
    483483{
    484         PyObject *self;
    485 
    486         if ((self = type->tp_alloc(type, 0)) == NULL) return NULL;
    487         memset(&((FSCatalogInfoObject *)self)->ob_itself, 0, sizeof(FSCatalogInfo));
    488         return self;
     484    PyObject *self;
     485
     486    if ((self = type->tp_alloc(type, 0)) == NULL) return NULL;
     487    memset(&((FSCatalogInfoObject *)self)->ob_itself, 0, sizeof(FSCatalogInfo));
     488    return self;
    489489}
    490490
     
    493493
    494494static PyTypeObject FSCatalogInfo_Type = {
    495         PyObject_HEAD_INIT(NULL)
    496         0, /*ob_size*/
    497         "Carbon.File.FSCatalogInfo", /*tp_name*/
    498         sizeof(FSCatalogInfoObject), /*tp_basicsize*/
    499         0, /*tp_itemsize*/
    500         /* methods */
    501         (destructor) FSCatalogInfo_dealloc, /*tp_dealloc*/
    502         0, /*tp_print*/
    503         (getattrfunc)0, /*tp_getattr*/
    504         (setattrfunc)0, /*tp_setattr*/
    505         (cmpfunc) FSCatalogInfo_compare, /*tp_compare*/
    506         (reprfunc) FSCatalogInfo_repr, /*tp_repr*/
    507         (PyNumberMethods *)0, /* tp_as_number */
    508         (PySequenceMethods *)0, /* tp_as_sequence */
    509         (PyMappingMethods *)0, /* tp_as_mapping */
    510         (hashfunc) FSCatalogInfo_hash, /*tp_hash*/
    511         0, /*tp_call*/
    512         0, /*tp_str*/
    513         PyObject_GenericGetAttr, /*tp_getattro*/
    514         PyObject_GenericSetAttr, /*tp_setattro */
    515         0, /*tp_as_buffer*/
    516         Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */
    517         0, /*tp_doc*/
    518         0, /*tp_traverse*/
    519         0, /*tp_clear*/
    520         0, /*tp_richcompare*/
    521         0, /*tp_weaklistoffset*/
    522         0, /*tp_iter*/
    523         0, /*tp_iternext*/
    524         FSCatalogInfo_methods, /* tp_methods */
    525         0, /*tp_members*/
    526         FSCatalogInfo_getsetlist, /*tp_getset*/
    527         0, /*tp_base*/
    528         0, /*tp_dict*/
    529         0, /*tp_descr_get*/
    530         0, /*tp_descr_set*/
    531         0, /*tp_dictoffset*/
    532         FSCatalogInfo_tp_init, /* tp_init */
    533         FSCatalogInfo_tp_alloc, /* tp_alloc */
    534         FSCatalogInfo_tp_new, /* tp_new */
    535         FSCatalogInfo_tp_free, /* tp_free */
     495    PyObject_HEAD_INIT(NULL)
     496    0, /*ob_size*/
     497    "Carbon.File.FSCatalogInfo", /*tp_name*/
     498    sizeof(FSCatalogInfoObject), /*tp_basicsize*/
     499    0, /*tp_itemsize*/
     500    /* methods */
     501    (destructor) FSCatalogInfo_dealloc, /*tp_dealloc*/
     502    0, /*tp_print*/
     503    (getattrfunc)0, /*tp_getattr*/
     504    (setattrfunc)0, /*tp_setattr*/
     505    (cmpfunc) FSCatalogInfo_compare, /*tp_compare*/
     506    (reprfunc) FSCatalogInfo_repr, /*tp_repr*/
     507    (PyNumberMethods *)0, /* tp_as_number */
     508    (PySequenceMethods *)0, /* tp_as_sequence */
     509    (PyMappingMethods *)0, /* tp_as_mapping */
     510    (hashfunc) FSCatalogInfo_hash, /*tp_hash*/
     511    0, /*tp_call*/
     512    0, /*tp_str*/
     513    PyObject_GenericGetAttr, /*tp_getattro*/
     514    PyObject_GenericSetAttr, /*tp_setattro */
     515    0, /*tp_as_buffer*/
     516    Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */
     517    0, /*tp_doc*/
     518    0, /*tp_traverse*/
     519    0, /*tp_clear*/
     520    0, /*tp_richcompare*/
     521    0, /*tp_weaklistoffset*/
     522    0, /*tp_iter*/
     523    0, /*tp_iternext*/
     524    FSCatalogInfo_methods, /* tp_methods */
     525    0, /*tp_members*/
     526    FSCatalogInfo_getsetlist, /*tp_getset*/
     527    0, /*tp_base*/
     528    0, /*tp_dict*/
     529    0, /*tp_descr_get*/
     530    0, /*tp_descr_set*/
     531    0, /*tp_dictoffset*/
     532    FSCatalogInfo_tp_init, /* tp_init */
     533    FSCatalogInfo_tp_alloc, /* tp_alloc */
     534    FSCatalogInfo_tp_new, /* tp_new */
     535    FSCatalogInfo_tp_free, /* tp_free */
    536536};
    537537
     
    548548
    549549typedef struct FInfoObject {
    550         PyObject_HEAD
    551         FInfo ob_itself;
     550    PyObject_HEAD
     551    FInfo ob_itself;
    552552} FInfoObject;
    553553
    554554static PyObject *FInfo_New(FInfo *itself)
    555555{
    556         FInfoObject *it;
    557         if (itself == NULL) return PyMac_Error(resNotFound);
    558         it = PyObject_NEW(FInfoObject, &FInfo_Type);
    559         if (it == NULL) return NULL;
    560         it->ob_itself = *itself;
    561         return (PyObject *)it;
     556    FInfoObject *it;
     557    if (itself == NULL) return PyMac_Error(resNotFound);
     558    it = PyObject_NEW(FInfoObject, &FInfo_Type);
     559    if (it == NULL) return NULL;
     560    it->ob_itself = *itself;
     561    return (PyObject *)it;
    562562}
    563563
    564564static int FInfo_Convert(PyObject *v, FInfo *p_itself)
    565565{
    566         if (!FInfo_Check(v))
    567         {
    568                 PyErr_SetString(PyExc_TypeError, "FInfo required");
    569                 return 0;
    570         }
    571         *p_itself = ((FInfoObject *)v)->ob_itself;
    572         return 1;
     566    if (!FInfo_Check(v))
     567    {
     568        PyErr_SetString(PyExc_TypeError, "FInfo required");
     569        return 0;
     570    }
     571    *p_itself = ((FInfoObject *)v)->ob_itself;
     572    return 1;
    573573}
    574574
    575575static void FInfo_dealloc(FInfoObject *self)
    576576{
    577         /* Cleanup of self->ob_itself goes here */
    578         self->ob_type->tp_free((PyObject *)self);
     577    /* Cleanup of self->ob_itself goes here */
     578    self->ob_type->tp_free((PyObject *)self);
    579579}
    580580
    581581static PyMethodDef FInfo_methods[] = {
    582         {NULL, NULL, 0}
     582    {NULL, NULL, 0}
    583583};
    584584
    585585static PyObject *FInfo_get_Type(FInfoObject *self, void *closure)
    586586{
    587         return Py_BuildValue("O&", PyMac_BuildOSType, self->ob_itself.fdType);
     587    return Py_BuildValue("O&", PyMac_BuildOSType, self->ob_itself.fdType);
    588588}
    589589
    590590static int FInfo_set_Type(FInfoObject *self, PyObject *v, void *closure)
    591591{
    592         return PyArg_Parse(v, "O&", PyMac_GetOSType, &self->ob_itself.fdType)-1;
    593         return 0;
     592    return PyArg_Parse(v, "O&", PyMac_GetOSType, &self->ob_itself.fdType)-1;
     593    return 0;
    594594}
    595595
    596596static PyObject *FInfo_get_Creator(FInfoObject *self, void *closure)
    597597{
    598         return Py_BuildValue("O&", PyMac_BuildOSType, self->ob_itself.fdCreator);
     598    return Py_BuildValue("O&", PyMac_BuildOSType, self->ob_itself.fdCreator);
    599599}
    600600
    601601static int FInfo_set_Creator(FInfoObject *self, PyObject *v, void *closure)
    602602{
    603         return PyArg_Parse(v, "O&", PyMac_GetOSType, &self->ob_itself.fdCreator)-1;
    604         return 0;
     603    return PyArg_Parse(v, "O&", PyMac_GetOSType, &self->ob_itself.fdCreator)-1;
     604    return 0;
    605605}
    606606
    607607static PyObject *FInfo_get_Flags(FInfoObject *self, void *closure)
    608608{
    609         return Py_BuildValue("H", self->ob_itself.fdFlags);
     609    return Py_BuildValue("H", self->ob_itself.fdFlags);
    610610}
    611611
    612612static int FInfo_set_Flags(FInfoObject *self, PyObject *v, void *closure)
    613613{
    614         return PyArg_Parse(v, "H", &self->ob_itself.fdFlags)-1;
    615         return 0;
     614    return PyArg_Parse(v, "H", &self->ob_itself.fdFlags)-1;
     615    return 0;
    616616}
    617617
    618618static PyObject *FInfo_get_Location(FInfoObject *self, void *closure)
    619619{
    620         return Py_BuildValue("O&", PyMac_BuildPoint, self->ob_itself.fdLocation);
     620    return Py_BuildValue("O&", PyMac_BuildPoint, self->ob_itself.fdLocation);
    621621}
    622622
    623623static int FInfo_set_Location(FInfoObject *self, PyObject *v, void *closure)
    624624{
    625         return PyArg_Parse(v, "O&", PyMac_GetPoint, &self->ob_itself.fdLocation)-1;
    626         return 0;
     625    return PyArg_Parse(v, "O&", PyMac_GetPoint, &self->ob_itself.fdLocation)-1;
     626    return 0;
    627627}
    628628
    629629static PyObject *FInfo_get_Fldr(FInfoObject *self, void *closure)
    630630{
    631         return Py_BuildValue("h", self->ob_itself.fdFldr);
     631    return Py_BuildValue("h", self->ob_itself.fdFldr);
    632632}
    633633
    634634static int FInfo_set_Fldr(FInfoObject *self, PyObject *v, void *closure)
    635635{
    636         return PyArg_Parse(v, "h", &self->ob_itself.fdFldr)-1;
    637         return 0;
     636    return PyArg_Parse(v, "h", &self->ob_itself.fdFldr)-1;
     637    return 0;
    638638}
    639639
    640640static PyGetSetDef FInfo_getsetlist[] = {
    641         {"Type", (getter)FInfo_get_Type, (setter)FInfo_set_Type, "4-char file type"},
    642         {"Creator", (getter)FInfo_get_Creator, (setter)FInfo_set_Creator, "4-char file creator"},
    643         {"Flags", (getter)FInfo_get_Flags, (setter)FInfo_set_Flags, "Finder flag bits"},
    644         {"Location", (getter)FInfo_get_Location, (setter)FInfo_set_Location, "(x, y) location of the file's icon in its parent finder window"},
    645         {"Fldr", (getter)FInfo_get_Fldr, (setter)FInfo_set_Fldr, "Original folder, for 'put away'"},
    646         {NULL, NULL, NULL, NULL},
     641    {"Type", (getter)FInfo_get_Type, (setter)FInfo_set_Type, "4-char file type"},
     642    {"Creator", (getter)FInfo_get_Creator, (setter)FInfo_set_Creator, "4-char file creator"},
     643    {"Flags", (getter)FInfo_get_Flags, (setter)FInfo_set_Flags, "Finder flag bits"},
     644    {"Location", (getter)FInfo_get_Location, (setter)FInfo_set_Location, "(x, y) location of the file's icon in its parent finder window"},
     645    {"Fldr", (getter)FInfo_get_Fldr, (setter)FInfo_set_Fldr, "Original folder, for 'put away'"},
     646    {NULL, NULL, NULL, NULL},
    647647};
    648648
     
    655655static int FInfo_tp_init(PyObject *_self, PyObject *_args, PyObject *_kwds)
    656656{
    657         FInfo *itself = NULL;
    658         static char *kw[] = {"itself", 0};
    659 
    660         if (PyArg_ParseTupleAndKeywords(_args, _kwds, "|O&", kw, FInfo_Convert, &itself))
    661         {
    662                 if (itself) memcpy(&((FInfoObject *)_self)->ob_itself, itself, sizeof(FInfo));
    663                 return 0;
    664         }
    665         return -1;
     657    FInfo *itself = NULL;
     658    static char *kw[] = {"itself", 0};
     659
     660    if (PyArg_ParseTupleAndKeywords(_args, _kwds, "|O&", kw, FInfo_Convert, &itself))
     661    {
     662        if (itself) memcpy(&((FInfoObject *)_self)->ob_itself, itself, sizeof(FInfo));
     663        return 0;
     664    }
     665    return -1;
    666666}
    667667
     
    670670static PyObject *FInfo_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds)
    671671{
    672         PyObject *self;
    673 
    674         if ((self = type->tp_alloc(type, 0)) == NULL) return NULL;
    675         memset(&((FInfoObject *)self)->ob_itself, 0, sizeof(FInfo));
    676         return self;
     672    PyObject *self;
     673
     674    if ((self = type->tp_alloc(type, 0)) == NULL) return NULL;
     675    memset(&((FInfoObject *)self)->ob_itself, 0, sizeof(FInfo));
     676    return self;
    677677}
    678678
     
    681681
    682682static PyTypeObject FInfo_Type = {
    683         PyObject_HEAD_INIT(NULL)
    684         0, /*ob_size*/
    685         "Carbon.File.FInfo", /*tp_name*/
    686         sizeof(FInfoObject), /*tp_basicsize*/
    687         0, /*tp_itemsize*/
    688         /* methods */
    689         (destructor) FInfo_dealloc, /*tp_dealloc*/
    690         0, /*tp_print*/
    691         (getattrfunc)0, /*tp_getattr*/
    692         (setattrfunc)0, /*tp_setattr*/
    693         (cmpfunc) FInfo_compare, /*tp_compare*/
    694         (reprfunc) FInfo_repr, /*tp_repr*/
    695         (PyNumberMethods *)0, /* tp_as_number */
    696         (PySequenceMethods *)0, /* tp_as_sequence */
    697         (PyMappingMethods *)0, /* tp_as_mapping */
    698         (hashfunc) FInfo_hash, /*tp_hash*/
    699         0, /*tp_call*/
    700         0, /*tp_str*/
    701         PyObject_GenericGetAttr, /*tp_getattro*/
    702         PyObject_GenericSetAttr, /*tp_setattro */
    703         0, /*tp_as_buffer*/
    704         Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */
    705         0, /*tp_doc*/
    706         0, /*tp_traverse*/
    707         0, /*tp_clear*/
    708         0, /*tp_richcompare*/
    709         0, /*tp_weaklistoffset*/
    710         0, /*tp_iter*/
    711         0, /*tp_iternext*/
    712         FInfo_methods, /* tp_methods */
    713         0, /*tp_members*/
    714         FInfo_getsetlist, /*tp_getset*/
    715         0, /*tp_base*/
    716         0, /*tp_dict*/
    717         0, /*tp_descr_get*/
    718         0, /*tp_descr_set*/
    719         0, /*tp_dictoffset*/
    720         FInfo_tp_init, /* tp_init */
    721         FInfo_tp_alloc, /* tp_alloc */
    722         FInfo_tp_new, /* tp_new */
    723         FInfo_tp_free, /* tp_free */
     683    PyObject_HEAD_INIT(NULL)
     684    0, /*ob_size*/
     685    "Carbon.File.FInfo", /*tp_name*/
     686    sizeof(FInfoObject), /*tp_basicsize*/
     687    0, /*tp_itemsize*/
     688    /* methods */
     689    (destructor) FInfo_dealloc, /*tp_dealloc*/
     690    0, /*tp_print*/
     691    (getattrfunc)0, /*tp_getattr*/
     692    (setattrfunc)0, /*tp_setattr*/
     693    (cmpfunc) FInfo_compare, /*tp_compare*/
     694    (reprfunc) FInfo_repr, /*tp_repr*/
     695    (PyNumberMethods *)0, /* tp_as_number */
     696    (PySequenceMethods *)0, /* tp_as_sequence */
     697    (PyMappingMethods *)0, /* tp_as_mapping */
     698    (hashfunc) FInfo_hash, /*tp_hash*/
     699    0, /*tp_call*/
     700    0, /*tp_str*/
     701    PyObject_GenericGetAttr, /*tp_getattro*/
     702    PyObject_GenericSetAttr, /*tp_setattro */
     703    0, /*tp_as_buffer*/
     704    Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */
     705    0, /*tp_doc*/
     706    0, /*tp_traverse*/
     707    0, /*tp_clear*/
     708    0, /*tp_richcompare*/
     709    0, /*tp_weaklistoffset*/
     710    0, /*tp_iter*/
     711    0, /*tp_iternext*/
     712    FInfo_methods, /* tp_methods */
     713    0, /*tp_members*/
     714    FInfo_getsetlist, /*tp_getset*/
     715    0, /*tp_base*/
     716    0, /*tp_dict*/
     717    0, /*tp_descr_get*/
     718    0, /*tp_descr_set*/
     719    0, /*tp_dictoffset*/
     720    FInfo_tp_init, /* tp_init */
     721    FInfo_tp_alloc, /* tp_alloc */
     722    FInfo_tp_new, /* tp_new */
     723    FInfo_tp_free, /* tp_free */
    724724};
    725725
     
    735735
    736736typedef struct AliasObject {
    737         PyObject_HEAD
    738         AliasHandle ob_itself;
    739         void (*ob_freeit)(AliasHandle ptr);
     737    PyObject_HEAD
     738    AliasHandle ob_itself;
     739    void (*ob_freeit)(AliasHandle ptr);
    740740} AliasObject;
    741741
    742742static PyObject *Alias_New(AliasHandle itself)
    743743{
    744         AliasObject *it;
    745         if (itself == NULL) return PyMac_Error(resNotFound);
    746         it = PyObject_NEW(AliasObject, &Alias_Type);
    747         if (it == NULL) return NULL;
    748         it->ob_itself = itself;
    749         it->ob_freeit = NULL;
    750         return (PyObject *)it;
     744    AliasObject *it;
     745    if (itself == NULL) return PyMac_Error(resNotFound);
     746    it = PyObject_NEW(AliasObject, &Alias_Type);
     747    if (it == NULL) return NULL;
     748    it->ob_itself = itself;
     749    it->ob_freeit = NULL;
     750    return (PyObject *)it;
    751751}
    752752
    753753static int Alias_Convert(PyObject *v, AliasHandle *p_itself)
    754754{
    755         if (!Alias_Check(v))
    756         {
    757                 PyErr_SetString(PyExc_TypeError, "Alias required");
    758                 return 0;
    759         }
    760         *p_itself = ((AliasObject *)v)->ob_itself;
    761         return 1;
     755    if (!Alias_Check(v))
     756    {
     757        PyErr_SetString(PyExc_TypeError, "Alias required");
     758        return 0;
     759    }
     760    *p_itself = ((AliasObject *)v)->ob_itself;
     761    return 1;
    762762}
    763763
    764764static void Alias_dealloc(AliasObject *self)
    765765{
    766         if (self->ob_freeit && self->ob_itself)
    767         {
    768                 self->ob_freeit(self->ob_itself);
    769         }
    770         self->ob_itself = NULL;
    771         self->ob_type->tp_free((PyObject *)self);
     766    if (self->ob_freeit && self->ob_itself)
     767    {
     768        self->ob_freeit(self->ob_itself);
     769    }
     770    self->ob_itself = NULL;
     771    self->ob_type->tp_free((PyObject *)self);
    772772}
    773773
     
    775775static PyObject *Alias_ResolveAlias(AliasObject *_self, PyObject *_args)
    776776{
    777         PyObject *_res = NULL;
    778         OSErr _err;
    779         FSSpec fromFile__buf__;
    780         FSSpec *fromFile = &fromFile__buf__;
    781         FSSpec target;
    782         Boolean wasChanged;
    783         if (!PyArg_ParseTuple(_args, "O&",
    784                               myPyMac_GetOptFSSpecPtr, &fromFile))
    785                 return NULL;
    786         _err = ResolveAlias(fromFile,
    787                             _self->ob_itself,
    788                             &target,
    789                             &wasChanged);
    790         if (_err != noErr) return PyMac_Error(_err);
    791         _res = Py_BuildValue("O&b",
    792                              FSSpec_New, &target,
    793                              wasChanged);
    794         return _res;
     777    PyObject *_res = NULL;
     778    OSErr _err;
     779    FSSpec fromFile__buf__;
     780    FSSpec *fromFile = &fromFile__buf__;
     781    FSSpec target;
     782    Boolean wasChanged;
     783    if (!PyArg_ParseTuple(_args, "O&",
     784                          myPyMac_GetOptFSSpecPtr, &fromFile))
     785        return NULL;
     786    _err = ResolveAlias(fromFile,
     787                        _self->ob_itself,
     788                        &target,
     789                        &wasChanged);
     790    if (_err != noErr) return PyMac_Error(_err);
     791    _res = Py_BuildValue("O&b",
     792                         FSSpec_New, &target,
     793                         wasChanged);
     794    return _res;
    795795}
    796796
    797797static PyObject *Alias_GetAliasInfo(AliasObject *_self, PyObject *_args)
    798798{
    799         PyObject *_res = NULL;
    800         OSErr _err;
    801         AliasInfoType index;
    802         Str63 theString;
    803         if (!PyArg_ParseTuple(_args, "h",
    804                               &index))
    805                 return NULL;
    806         _err = GetAliasInfo(_self->ob_itself,
    807                             index,
    808                             theString);
    809         if (_err != noErr) return PyMac_Error(_err);
    810         _res = Py_BuildValue("O&",
    811                              PyMac_BuildStr255, theString);
    812         return _res;
     799    PyObject *_res = NULL;
     800    OSErr _err;
     801    AliasInfoType index;
     802    Str63 theString;
     803    if (!PyArg_ParseTuple(_args, "h",
     804                          &index))
     805        return NULL;
     806    _err = GetAliasInfo(_self->ob_itself,
     807                        index,
     808                        theString);
     809    if (_err != noErr) return PyMac_Error(_err);
     810    _res = Py_BuildValue("O&",
     811                         PyMac_BuildStr255, theString);
     812    return _res;
    813813}
    814814
    815815static PyObject *Alias_ResolveAliasWithMountFlags(AliasObject *_self, PyObject *_args)
    816816{
    817         PyObject *_res = NULL;
    818         OSErr _err;
    819         FSSpec fromFile__buf__;
    820         FSSpec *fromFile = &fromFile__buf__;
    821         FSSpec target;
    822         Boolean wasChanged;
    823         unsigned long mountFlags;
    824         if (!PyArg_ParseTuple(_args, "O&l",
    825                               myPyMac_GetOptFSSpecPtr, &fromFile,
    826                               &mountFlags))
    827                 return NULL;
    828         _err = ResolveAliasWithMountFlags(fromFile,
    829                                           _self->ob_itself,
    830                                           &target,
    831                                           &wasChanged,
    832                                           mountFlags);
    833         if (_err != noErr) return PyMac_Error(_err);
    834         _res = Py_BuildValue("O&b",
    835                              FSSpec_New, &target,
    836                              wasChanged);
    837         return _res;
     817    PyObject *_res = NULL;
     818    OSErr _err;
     819    FSSpec fromFile__buf__;
     820    FSSpec *fromFile = &fromFile__buf__;
     821    FSSpec target;
     822    Boolean wasChanged;
     823    unsigned long mountFlags;
     824    if (!PyArg_ParseTuple(_args, "O&l",
     825                          myPyMac_GetOptFSSpecPtr, &fromFile,
     826                          &mountFlags))
     827        return NULL;
     828    _err = ResolveAliasWithMountFlags(fromFile,
     829                                      _self->ob_itself,
     830                                      &target,
     831                                      &wasChanged,
     832                                      mountFlags);
     833    if (_err != noErr) return PyMac_Error(_err);
     834    _res = Py_BuildValue("O&b",
     835                         FSSpec_New, &target,
     836                         wasChanged);
     837    return _res;
    838838}
    839839
    840840static PyObject *Alias_FollowFinderAlias(AliasObject *_self, PyObject *_args)
    841841{
    842         PyObject *_res = NULL;
    843         OSErr _err;
    844         FSSpec fromFile__buf__;
    845         FSSpec *fromFile = &fromFile__buf__;
    846         Boolean logon;
    847         FSSpec target;
    848         Boolean wasChanged;
    849         if (!PyArg_ParseTuple(_args, "O&b",
    850                               myPyMac_GetOptFSSpecPtr, &fromFile,
    851                               &logon))
    852                 return NULL;
    853         _err = FollowFinderAlias(fromFile,
    854                                  _self->ob_itself,
    855                                  logon,
    856                                  &target,
    857                                  &wasChanged);
    858         if (_err != noErr) return PyMac_Error(_err);
    859         _res = Py_BuildValue("O&b",
    860                              FSSpec_New, &target,
    861                              wasChanged);
    862         return _res;
     842    PyObject *_res = NULL;
     843    OSErr _err;
     844    FSSpec fromFile__buf__;
     845    FSSpec *fromFile = &fromFile__buf__;
     846    Boolean logon;
     847    FSSpec target;
     848    Boolean wasChanged;
     849    if (!PyArg_ParseTuple(_args, "O&b",
     850                          myPyMac_GetOptFSSpecPtr, &fromFile,
     851                          &logon))
     852        return NULL;
     853    _err = FollowFinderAlias(fromFile,
     854                             _self->ob_itself,
     855                             logon,
     856                             &target,
     857                             &wasChanged);
     858    if (_err != noErr) return PyMac_Error(_err);
     859    _res = Py_BuildValue("O&b",
     860                         FSSpec_New, &target,
     861                         wasChanged);
     862    return _res;
    863863}
    864864#endif /* !__LP64__ */
     
    866866static PyObject *Alias_FSResolveAliasWithMountFlags(AliasObject *_self, PyObject *_args)
    867867{
    868         PyObject *_res = NULL;
    869         OSErr _err;
    870         FSRef fromFile__buf__;
    871         FSRef *fromFile = &fromFile__buf__;
    872         FSRef target;
    873         Boolean wasChanged;
    874         unsigned long mountFlags;
    875         if (!PyArg_ParseTuple(_args, "O&l",
    876                               myPyMac_GetOptFSRefPtr, &fromFile,
    877                               &mountFlags))
    878                 return NULL;
    879         _err = FSResolveAliasWithMountFlags(fromFile,
    880                                             _self->ob_itself,
    881                                             &target,
    882                                             &wasChanged,
    883                                             mountFlags);
    884         if (_err != noErr) return PyMac_Error(_err);
    885         _res = Py_BuildValue("O&b",
    886                              FSRef_New, &target,
    887                              wasChanged);
    888         return _res;
     868    PyObject *_res = NULL;
     869    OSErr _err;
     870    FSRef fromFile__buf__;
     871    FSRef *fromFile = &fromFile__buf__;
     872    FSRef target;
     873    Boolean wasChanged;
     874    unsigned long mountFlags;
     875    if (!PyArg_ParseTuple(_args, "O&l",
     876                          myPyMac_GetOptFSRefPtr, &fromFile,
     877                          &mountFlags))
     878        return NULL;
     879    _err = FSResolveAliasWithMountFlags(fromFile,
     880                                        _self->ob_itself,
     881                                        &target,
     882                                        &wasChanged,
     883                                        mountFlags);
     884    if (_err != noErr) return PyMac_Error(_err);
     885    _res = Py_BuildValue("O&b",
     886                         FSRef_New, &target,
     887                         wasChanged);
     888    return _res;
    889889}
    890890
    891891static PyObject *Alias_FSResolveAlias(AliasObject *_self, PyObject *_args)
    892892{
    893         PyObject *_res = NULL;
    894         OSErr _err;
    895         FSRef fromFile__buf__;
    896         FSRef *fromFile = &fromFile__buf__;
    897         FSRef target;
    898         Boolean wasChanged;
    899         if (!PyArg_ParseTuple(_args, "O&",
    900                               myPyMac_GetOptFSRefPtr, &fromFile))
    901                 return NULL;
    902         _err = FSResolveAlias(fromFile,
    903                               _self->ob_itself,
    904                               &target,
    905                               &wasChanged);
    906         if (_err != noErr) return PyMac_Error(_err);
    907         _res = Py_BuildValue("O&b",
    908                              FSRef_New, &target,
    909                              wasChanged);
    910         return _res;
     893    PyObject *_res = NULL;
     894    OSErr _err;
     895    FSRef fromFile__buf__;
     896    FSRef *fromFile = &fromFile__buf__;
     897    FSRef target;
     898    Boolean wasChanged;
     899    if (!PyArg_ParseTuple(_args, "O&",
     900                          myPyMac_GetOptFSRefPtr, &fromFile))
     901        return NULL;
     902    _err = FSResolveAlias(fromFile,
     903                          _self->ob_itself,
     904                          &target,
     905                          &wasChanged);
     906    if (_err != noErr) return PyMac_Error(_err);
     907    _res = Py_BuildValue("O&b",
     908                         FSRef_New, &target,
     909                         wasChanged);
     910    return _res;
    911911}
    912912
    913913static PyObject *Alias_FSFollowFinderAlias(AliasObject *_self, PyObject *_args)
    914914{
    915         PyObject *_res = NULL;
    916         OSErr _err;
    917         FSRef fromFile;
    918         Boolean logon;
    919         FSRef target;
    920         Boolean wasChanged;
    921         if (!PyArg_ParseTuple(_args, "b",
    922                               &logon))
    923                 return NULL;
    924         _err = FSFollowFinderAlias(&fromFile,
    925                                    _self->ob_itself,
    926                                    logon,
    927                                    &target,
    928                                    &wasChanged);
    929         if (_err != noErr) return PyMac_Error(_err);
    930         _res = Py_BuildValue("O&O&b",
    931                              FSRef_New, &fromFile,
    932                              FSRef_New, &target,
    933                              wasChanged);
    934         return _res;
     915    PyObject *_res = NULL;
     916    OSErr _err;
     917    FSRef fromFile;
     918    Boolean logon;
     919    FSRef target;
     920    Boolean wasChanged;
     921    if (!PyArg_ParseTuple(_args, "b",
     922                          &logon))
     923        return NULL;
     924    _err = FSFollowFinderAlias(&fromFile,
     925                               _self->ob_itself,
     926                               logon,
     927                               &target,
     928                               &wasChanged);
     929    if (_err != noErr) return PyMac_Error(_err);
     930    _res = Py_BuildValue("O&O&b",
     931                         FSRef_New, &fromFile,
     932                         FSRef_New, &target,
     933                         wasChanged);
     934    return _res;
    935935}
    936936
    937937static PyMethodDef Alias_methods[] = {
    938938#ifndef __LP64__
    939         {"ResolveAlias", (PyCFunction)Alias_ResolveAlias, 1,
    940         PyDoc_STR("(FSSpec fromFile) -> (FSSpec target, Boolean wasChanged)")},
    941         {"GetAliasInfo", (PyCFunction)Alias_GetAliasInfo, 1,
    942         PyDoc_STR("(AliasInfoType index) -> (Str63 theString)")},
    943         {"ResolveAliasWithMountFlags", (PyCFunction)Alias_ResolveAliasWithMountFlags, 1,
    944         PyDoc_STR("(FSSpec fromFile, unsigned long mountFlags) -> (FSSpec target, Boolean wasChanged)")},
    945         {"FollowFinderAlias", (PyCFunction)Alias_FollowFinderAlias, 1,
    946         PyDoc_STR("(FSSpec fromFile, Boolean logon) -> (FSSpec target, Boolean wasChanged)")},
     939    {"ResolveAlias", (PyCFunction)Alias_ResolveAlias, 1,
     940    PyDoc_STR("(FSSpec fromFile) -> (FSSpec target, Boolean wasChanged)")},
     941    {"GetAliasInfo", (PyCFunction)Alias_GetAliasInfo, 1,
     942    PyDoc_STR("(AliasInfoType index) -> (Str63 theString)")},
     943    {"ResolveAliasWithMountFlags", (PyCFunction)Alias_ResolveAliasWithMountFlags, 1,
     944    PyDoc_STR("(FSSpec fromFile, unsigned long mountFlags) -> (FSSpec target, Boolean wasChanged)")},
     945    {"FollowFinderAlias", (PyCFunction)Alias_FollowFinderAlias, 1,
     946    PyDoc_STR("(FSSpec fromFile, Boolean logon) -> (FSSpec target, Boolean wasChanged)")},
    947947#endif /* !__LP64__ */
    948         {"FSResolveAliasWithMountFlags", (PyCFunction)Alias_FSResolveAliasWithMountFlags, 1,
    949         PyDoc_STR("(FSRef fromFile, unsigned long mountFlags) -> (FSRef target, Boolean wasChanged)")},
    950         {"FSResolveAlias", (PyCFunction)Alias_FSResolveAlias, 1,
    951         PyDoc_STR("(FSRef fromFile) -> (FSRef target, Boolean wasChanged)")},
    952         {"FSFollowFinderAlias", (PyCFunction)Alias_FSFollowFinderAlias, 1,
    953         PyDoc_STR("(Boolean logon) -> (FSRef fromFile, FSRef target, Boolean wasChanged)")},
    954         {NULL, NULL, 0}
     948    {"FSResolveAliasWithMountFlags", (PyCFunction)Alias_FSResolveAliasWithMountFlags, 1,
     949    PyDoc_STR("(FSRef fromFile, unsigned long mountFlags) -> (FSRef target, Boolean wasChanged)")},
     950    {"FSResolveAlias", (PyCFunction)Alias_FSResolveAlias, 1,
     951    PyDoc_STR("(FSRef fromFile) -> (FSRef target, Boolean wasChanged)")},
     952    {"FSFollowFinderAlias", (PyCFunction)Alias_FSFollowFinderAlias, 1,
     953    PyDoc_STR("(Boolean logon) -> (FSRef fromFile, FSRef target, Boolean wasChanged)")},
     954    {NULL, NULL, 0}
    955955};
    956956
    957957static PyObject *Alias_get_data(AliasObject *self, void *closure)
    958958{
    959         int size;
    960                             PyObject *rv;
    961 
    962                             size = GetHandleSize((Handle)self->ob_itself);
    963                             HLock((Handle)self->ob_itself);
    964                             rv = PyString_FromStringAndSize(*(Handle)self->ob_itself, size);
    965                             HUnlock((Handle)self->ob_itself);
    966                             return rv;
    967                    
     959    int size;
     960                        PyObject *rv;
     961
     962                        size = GetHandleSize((Handle)self->ob_itself);
     963                        HLock((Handle)self->ob_itself);
     964                        rv = PyString_FromStringAndSize(*(Handle)self->ob_itself, size);
     965                        HUnlock((Handle)self->ob_itself);
     966                        return rv;
     967
    968968}
    969969
     
    971971
    972972static PyGetSetDef Alias_getsetlist[] = {
    973         {"data", (getter)Alias_get_data, (setter)Alias_set_data, "Raw data of the alias object"},
    974         {NULL, NULL, NULL, NULL},
     973    {"data", (getter)Alias_get_data, (setter)Alias_set_data, "Raw data of the alias object"},
     974    {NULL, NULL, NULL, NULL},
    975975};
    976976
     
    983983static int Alias_tp_init(PyObject *_self, PyObject *_args, PyObject *_kwds)
    984984{
    985         AliasHandle itself = NULL;
    986         char *rawdata = NULL;
    987         int rawdatalen = 0;
    988         Handle h;
    989         static char *kw[] = {"itself", "rawdata", 0};
    990 
    991         if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "|O&s#", kw, Alias_Convert, &itself, &rawdata, &rawdatalen))
    992         return -1;
    993         if (itself && rawdata)
    994         {
    995                 PyErr_SetString(PyExc_TypeError, "Only one of itself or rawdata may be specified");
    996                 return -1;
    997         }
    998         if (!itself && !rawdata)
    999         {
    1000                 PyErr_SetString(PyExc_TypeError, "One of itself or rawdata must be specified");
    1001                 return -1;
    1002         }
    1003         if (rawdata)
    1004         {
    1005                 if ((h = NewHandle(rawdatalen)) == NULL)
    1006                 {
    1007                         PyErr_NoMemory();
    1008                         return -1;
    1009                 }
    1010                 HLock(h);
    1011                 memcpy((char *)*h, rawdata, rawdatalen);
    1012                 HUnlock(h);
    1013                 ((AliasObject *)_self)->ob_itself = (AliasHandle)h;
    1014                 return 0;
    1015         }
    1016         ((AliasObject *)_self)->ob_itself = itself;
    1017         return 0;
     985    AliasHandle itself = NULL;
     986    char *rawdata = NULL;
     987    int rawdatalen = 0;
     988    Handle h;
     989    static char *kw[] = {"itself", "rawdata", 0};
     990
     991    if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "|O&s#", kw, Alias_Convert, &itself, &rawdata, &rawdatalen))
     992    return -1;
     993    if (itself && rawdata)
     994    {
     995        PyErr_SetString(PyExc_TypeError, "Only one of itself or rawdata may be specified");
     996        return -1;
     997    }
     998    if (!itself && !rawdata)
     999    {
     1000        PyErr_SetString(PyExc_TypeError, "One of itself or rawdata must be specified");
     1001        return -1;
     1002    }
     1003    if (rawdata)
     1004    {
     1005        if ((h = NewHandle(rawdatalen)) == NULL)
     1006        {
     1007            PyErr_NoMemory();
     1008            return -1;
     1009        }
     1010        HLock(h);
     1011        memcpy((char *)*h, rawdata, rawdatalen);
     1012        HUnlock(h);
     1013        ((AliasObject *)_self)->ob_itself = (AliasHandle)h;
     1014        return 0;
     1015    }
     1016    ((AliasObject *)_self)->ob_itself = itself;
     1017    return 0;
    10181018}
    10191019
     
    10221022static PyObject *Alias_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds)
    10231023{
    1024         PyObject *self;
    1025 
    1026         if ((self = type->tp_alloc(type, 0)) == NULL) return NULL;
    1027         ((AliasObject *)self)->ob_itself = NULL;
    1028         return self;
     1024    PyObject *self;
     1025
     1026    if ((self = type->tp_alloc(type, 0)) == NULL) return NULL;
     1027    ((AliasObject *)self)->ob_itself = NULL;
     1028    return self;
    10291029}
    10301030
     
    10331033
    10341034static PyTypeObject Alias_Type = {
    1035         PyObject_HEAD_INIT(NULL)
    1036         0, /*ob_size*/
    1037         "Carbon.File.Alias", /*tp_name*/
    1038         sizeof(AliasObject), /*tp_basicsize*/
    1039         0, /*tp_itemsize*/
    1040         /* methods */
    1041         (destructor) Alias_dealloc, /*tp_dealloc*/
    1042         0, /*tp_print*/
    1043         (getattrfunc)0, /*tp_getattr*/
    1044         (setattrfunc)0, /*tp_setattr*/
    1045         (cmpfunc) Alias_compare, /*tp_compare*/
    1046         (reprfunc) Alias_repr, /*tp_repr*/
    1047         (PyNumberMethods *)0, /* tp_as_number */
    1048         (PySequenceMethods *)0, /* tp_as_sequence */
    1049         (PyMappingMethods *)0, /* tp_as_mapping */
    1050         (hashfunc) Alias_hash, /*tp_hash*/
    1051         0, /*tp_call*/
    1052         0, /*tp_str*/
    1053         PyObject_GenericGetAttr, /*tp_getattro*/
    1054         PyObject_GenericSetAttr, /*tp_setattro */
    1055         0, /*tp_as_buffer*/
    1056         Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */
    1057         0, /*tp_doc*/
    1058         0, /*tp_traverse*/
    1059         0, /*tp_clear*/
    1060         0, /*tp_richcompare*/
    1061         0, /*tp_weaklistoffset*/
    1062         0, /*tp_iter*/
    1063         0, /*tp_iternext*/
    1064         Alias_methods, /* tp_methods */
    1065         0, /*tp_members*/
    1066         Alias_getsetlist, /*tp_getset*/
    1067         0, /*tp_base*/
    1068         0, /*tp_dict*/
    1069         0, /*tp_descr_get*/
    1070         0, /*tp_descr_set*/
    1071         0, /*tp_dictoffset*/
    1072         Alias_tp_init, /* tp_init */
    1073         Alias_tp_alloc, /* tp_alloc */
    1074         Alias_tp_new, /* tp_new */
    1075         Alias_tp_free, /* tp_free */
     1035    PyObject_HEAD_INIT(NULL)
     1036    0, /*ob_size*/
     1037    "Carbon.File.Alias", /*tp_name*/
     1038    sizeof(AliasObject), /*tp_basicsize*/
     1039    0, /*tp_itemsize*/
     1040    /* methods */
     1041    (destructor) Alias_dealloc, /*tp_dealloc*/
     1042    0, /*tp_print*/
     1043    (getattrfunc)0, /*tp_getattr*/
     1044    (setattrfunc)0, /*tp_setattr*/
     1045    (cmpfunc) Alias_compare, /*tp_compare*/
     1046    (reprfunc) Alias_repr, /*tp_repr*/
     1047    (PyNumberMethods *)0, /* tp_as_number */
     1048    (PySequenceMethods *)0, /* tp_as_sequence */
     1049    (PyMappingMethods *)0, /* tp_as_mapping */
     1050    (hashfunc) Alias_hash, /*tp_hash*/
     1051    0, /*tp_call*/
     1052    0, /*tp_str*/
     1053    PyObject_GenericGetAttr, /*tp_getattro*/
     1054    PyObject_GenericSetAttr, /*tp_setattro */
     1055    0, /*tp_as_buffer*/
     1056    Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */
     1057    0, /*tp_doc*/
     1058    0, /*tp_traverse*/
     1059    0, /*tp_clear*/
     1060    0, /*tp_richcompare*/
     1061    0, /*tp_weaklistoffset*/
     1062    0, /*tp_iter*/
     1063    0, /*tp_iternext*/
     1064    Alias_methods, /* tp_methods */
     1065    0, /*tp_members*/
     1066    Alias_getsetlist, /*tp_getset*/
     1067    0, /*tp_base*/
     1068    0, /*tp_dict*/
     1069    0, /*tp_descr_get*/
     1070    0, /*tp_descr_set*/
     1071    0, /*tp_dictoffset*/
     1072    Alias_tp_init, /* tp_init */
     1073    Alias_tp_alloc, /* tp_alloc */
     1074    Alias_tp_new, /* tp_new */
     1075    Alias_tp_free, /* tp_free */
    10761076};
    10771077
     
    10871087
    10881088typedef struct FSSpecObject {
    1089         PyObject_HEAD
    1090         FSSpec ob_itself;
     1089    PyObject_HEAD
     1090    FSSpec ob_itself;
    10911091} FSSpecObject;
    10921092
    10931093static PyObject *FSSpec_New(FSSpec *itself)
    10941094{
    1095         FSSpecObject *it;
    1096         if (itself == NULL) return PyMac_Error(resNotFound);
    1097         it = PyObject_NEW(FSSpecObject, &FSSpec_Type);
    1098         if (it == NULL) return NULL;
    1099         it->ob_itself = *itself;
    1100         return (PyObject *)it;
     1095    FSSpecObject *it;
     1096    if (itself == NULL) return PyMac_Error(resNotFound);
     1097    it = PyObject_NEW(FSSpecObject, &FSSpec_Type);
     1098    if (it == NULL) return NULL;
     1099    it->ob_itself = *itself;
     1100    return (PyObject *)it;
    11011101}
    11021102
    11031103static void FSSpec_dealloc(FSSpecObject *self)
    11041104{
    1105         /* Cleanup of self->ob_itself goes here */
    1106         self->ob_type->tp_free((PyObject *)self);
     1105    /* Cleanup of self->ob_itself goes here */
     1106    self->ob_type->tp_free((PyObject *)self);
    11071107}
    11081108
    11091109static PyObject *FSSpec_FSpOpenDF(FSSpecObject *_self, PyObject *_args)
    11101110{
    1111         PyObject *_res = NULL;
    1112         OSErr _err;
    1113         SInt8 permission;
    1114         short refNum;
    1115         if (!PyArg_ParseTuple(_args, "b",
    1116                               &permission))
    1117                 return NULL;
    1118         _err = FSpOpenDF(&_self->ob_itself,
    1119                          permission,
    1120                          &refNum);
    1121         if (_err != noErr) return PyMac_Error(_err);
    1122         _res = Py_BuildValue("h",
    1123                              refNum);
    1124         return _res;
     1111    PyObject *_res = NULL;
     1112    OSErr _err;
     1113    SInt8 permission;
     1114    short refNum;
     1115    if (!PyArg_ParseTuple(_args, "b",
     1116                          &permission))
     1117        return NULL;
     1118    _err = FSpOpenDF(&_self->ob_itself,
     1119                     permission,
     1120                     &refNum);
     1121    if (_err != noErr) return PyMac_Error(_err);
     1122    _res = Py_BuildValue("h",
     1123                         refNum);
     1124    return _res;
    11251125}
    11261126
    11271127static PyObject *FSSpec_FSpOpenRF(FSSpecObject *_self, PyObject *_args)
    11281128{
    1129         PyObject *_res = NULL;
    1130         OSErr _err;
    1131         SInt8 permission;
    1132         short refNum;
    1133         if (!PyArg_ParseTuple(_args, "b",
    1134                               &permission))
    1135                 return NULL;
    1136         _err = FSpOpenRF(&_self->ob_itself,
    1137                          permission,
    1138                          &refNum);
    1139         if (_err != noErr) return PyMac_Error(_err);
    1140         _res = Py_BuildValue("h",
    1141                              refNum);
    1142         return _res;
     1129    PyObject *_res = NULL;
     1130    OSErr _err;
     1131    SInt8 permission;
     1132    short refNum;
     1133    if (!PyArg_ParseTuple(_args, "b",
     1134                          &permission))
     1135        return NULL;
     1136    _err = FSpOpenRF(&_self->ob_itself,
     1137                     permission,
     1138                     &refNum);
     1139    if (_err != noErr) return PyMac_Error(_err);
     1140    _res = Py_BuildValue("h",
     1141                         refNum);
     1142    return _res;
    11431143}
    11441144
    11451145static PyObject *FSSpec_FSpCreate(FSSpecObject *_self, PyObject *_args)
    11461146{
    1147         PyObject *_res = NULL;
    1148         OSErr _err;
    1149         OSType creator;
    1150         OSType fileType;
    1151         ScriptCode scriptTag;
    1152         if (!PyArg_ParseTuple(_args, "O&O&h",
    1153                               PyMac_GetOSType, &creator,
    1154                               PyMac_GetOSType, &fileType,
    1155                               &scriptTag))
    1156                 return NULL;
    1157         _err = FSpCreate(&_self->ob_itself,
    1158                          creator,
    1159                          fileType,
    1160                          scriptTag);
    1161         if (_err != noErr) return PyMac_Error(_err);
    1162         Py_INCREF(Py_None);
    1163         _res = Py_None;
    1164         return _res;
     1147    PyObject *_res = NULL;
     1148    OSErr _err;
     1149    OSType creator;
     1150    OSType fileType;
     1151    ScriptCode scriptTag;
     1152    if (!PyArg_ParseTuple(_args, "O&O&h",
     1153                          PyMac_GetOSType, &creator,
     1154                          PyMac_GetOSType, &fileType,
     1155                          &scriptTag))
     1156        return NULL;
     1157    _err = FSpCreate(&_self->ob_itself,
     1158                     creator,
     1159                     fileType,
     1160                     scriptTag);
     1161    if (_err != noErr) return PyMac_Error(_err);
     1162    Py_INCREF(Py_None);
     1163    _res = Py_None;
     1164    return _res;
    11651165}
    11661166
    11671167static PyObject *FSSpec_FSpDirCreate(FSSpecObject *_self, PyObject *_args)
    11681168{
    1169         PyObject *_res = NULL;
    1170         OSErr _err;
    1171         ScriptCode scriptTag;
    1172         long createdDirID;
    1173         if (!PyArg_ParseTuple(_args, "h",
    1174                               &scriptTag))
    1175                 return NULL;
    1176         _err = FSpDirCreate(&_self->ob_itself,
    1177                             scriptTag,
    1178                             &createdDirID);
    1179         if (_err != noErr) return PyMac_Error(_err);
    1180         _res = Py_BuildValue("l",
    1181                              createdDirID);
    1182         return _res;
     1169    PyObject *_res = NULL;
     1170    OSErr _err;
     1171    ScriptCode scriptTag;
     1172    long createdDirID;
     1173    if (!PyArg_ParseTuple(_args, "h",
     1174                          &scriptTag))
     1175        return NULL;
     1176    _err = FSpDirCreate(&_self->ob_itself,
     1177                        scriptTag,
     1178                        &createdDirID);
     1179    if (_err != noErr) return PyMac_Error(_err);
     1180    _res = Py_BuildValue("l",
     1181                         createdDirID);
     1182    return _res;
    11831183}
    11841184
    11851185static PyObject *FSSpec_FSpDelete(FSSpecObject *_self, PyObject *_args)
    11861186{
    1187         PyObject *_res = NULL;
    1188         OSErr _err;
    1189         if (!PyArg_ParseTuple(_args, ""))
    1190                 return NULL;
    1191         _err = FSpDelete(&_self->ob_itself);
    1192         if (_err != noErr) return PyMac_Error(_err);
    1193         Py_INCREF(Py_None);
    1194         _res = Py_None;
    1195         return _res;
     1187    PyObject *_res = NULL;
     1188    OSErr _err;
     1189    if (!PyArg_ParseTuple(_args, ""))
     1190        return NULL;
     1191    _err = FSpDelete(&_self->ob_itself);
     1192    if (_err != noErr) return PyMac_Error(_err);
     1193    Py_INCREF(Py_None);
     1194    _res = Py_None;
     1195    return _res;
    11961196}
    11971197
    11981198static PyObject *FSSpec_FSpGetFInfo(FSSpecObject *_self, PyObject *_args)
    11991199{
    1200         PyObject *_res = NULL;
    1201         OSErr _err;
    1202         FInfo fndrInfo;
    1203         if (!PyArg_ParseTuple(_args, ""))
    1204                 return NULL;
    1205         _err = FSpGetFInfo(&_self->ob_itself,
    1206                            &fndrInfo);
    1207         if (_err != noErr) return PyMac_Error(_err);
    1208         _res = Py_BuildValue("O&",
    1209                              FInfo_New, &fndrInfo);
    1210         return _res;
     1200    PyObject *_res = NULL;
     1201    OSErr _err;
     1202    FInfo fndrInfo;
     1203    if (!PyArg_ParseTuple(_args, ""))
     1204        return NULL;
     1205    _err = FSpGetFInfo(&_self->ob_itself,
     1206                       &fndrInfo);
     1207    if (_err != noErr) return PyMac_Error(_err);
     1208    _res = Py_BuildValue("O&",
     1209                         FInfo_New, &fndrInfo);
     1210    return _res;
    12111211}
    12121212
    12131213static PyObject *FSSpec_FSpSetFInfo(FSSpecObject *_self, PyObject *_args)
    12141214{
    1215         PyObject *_res = NULL;
    1216         OSErr _err;
    1217         FInfo fndrInfo;
    1218         if (!PyArg_ParseTuple(_args, "O&",
    1219                               FInfo_Convert, &fndrInfo))
    1220                 return NULL;
    1221         _err = FSpSetFInfo(&_self->ob_itself,
    1222                            &fndrInfo);
    1223         if (_err != noErr) return PyMac_Error(_err);
    1224         Py_INCREF(Py_None);
    1225         _res = Py_None;
    1226         return _res;
     1215    PyObject *_res = NULL;
     1216    OSErr _err;
     1217    FInfo fndrInfo;
     1218    if (!PyArg_ParseTuple(_args, "O&",
     1219                          FInfo_Convert, &fndrInfo))
     1220        return NULL;
     1221    _err = FSpSetFInfo(&_self->ob_itself,
     1222                       &fndrInfo);
     1223    if (_err != noErr) return PyMac_Error(_err);
     1224    Py_INCREF(Py_None);
     1225    _res = Py_None;
     1226    return _res;
    12271227}
    12281228
    12291229static PyObject *FSSpec_FSpSetFLock(FSSpecObject *_self, PyObject *_args)
    12301230{
    1231         PyObject *_res = NULL;
    1232         OSErr _err;
    1233         if (!PyArg_ParseTuple(_args, ""))
    1234                 return NULL;
    1235         _err = FSpSetFLock(&_self->ob_itself);
    1236         if (_err != noErr) return PyMac_Error(_err);
    1237         Py_INCREF(Py_None);
    1238         _res = Py_None;
    1239         return _res;
     1231    PyObject *_res = NULL;
     1232    OSErr _err;
     1233    if (!PyArg_ParseTuple(_args, ""))
     1234        return NULL;
     1235    _err = FSpSetFLock(&_self->ob_itself);
     1236    if (_err != noErr) return PyMac_Error(_err);
     1237    Py_INCREF(Py_None);
     1238    _res = Py_None;
     1239    return _res;
    12401240}
    12411241
    12421242static PyObject *FSSpec_FSpRstFLock(FSSpecObject *_self, PyObject *_args)
    12431243{
    1244         PyObject *_res = NULL;
    1245         OSErr _err;
    1246         if (!PyArg_ParseTuple(_args, ""))
    1247                 return NULL;
    1248         _err = FSpRstFLock(&_self->ob_itself);
    1249         if (_err != noErr) return PyMac_Error(_err);
    1250         Py_INCREF(Py_None);
    1251         _res = Py_None;
    1252         return _res;
     1244    PyObject *_res = NULL;
     1245    OSErr _err;
     1246    if (!PyArg_ParseTuple(_args, ""))
     1247        return NULL;
     1248    _err = FSpRstFLock(&_self->ob_itself);
     1249    if (_err != noErr) return PyMac_Error(_err);
     1250    Py_INCREF(Py_None);
     1251    _res = Py_None;
     1252    return _res;
    12531253}
    12541254
    12551255static PyObject *FSSpec_FSpRename(FSSpecObject *_self, PyObject *_args)
    12561256{
    1257         PyObject *_res = NULL;
    1258         OSErr _err;
    1259         Str255 newName;
    1260         if (!PyArg_ParseTuple(_args, "O&",
    1261                               PyMac_GetStr255, newName))
    1262                 return NULL;
    1263         _err = FSpRename(&_self->ob_itself,
    1264                          newName);
    1265         if (_err != noErr) return PyMac_Error(_err);
    1266         Py_INCREF(Py_None);
    1267         _res = Py_None;
    1268         return _res;
     1257    PyObject *_res = NULL;
     1258    OSErr _err;
     1259    Str255 newName;
     1260    if (!PyArg_ParseTuple(_args, "O&",
     1261                          PyMac_GetStr255, newName))
     1262        return NULL;
     1263    _err = FSpRename(&_self->ob_itself,
     1264                     newName);
     1265    if (_err != noErr) return PyMac_Error(_err);
     1266    Py_INCREF(Py_None);
     1267    _res = Py_None;
     1268    return _res;
    12691269}
    12701270
    12711271static PyObject *FSSpec_FSpCatMove(FSSpecObject *_self, PyObject *_args)
    12721272{
    1273         PyObject *_res = NULL;
    1274         OSErr _err;
    1275         FSSpec dest;
    1276         if (!PyArg_ParseTuple(_args, "O&",
    1277                               FSSpec_Convert, &dest))
    1278                 return NULL;
    1279         _err = FSpCatMove(&_self->ob_itself,
    1280                           &dest);
    1281         if (_err != noErr) return PyMac_Error(_err);
    1282         Py_INCREF(Py_None);
    1283         _res = Py_None;
    1284         return _res;
     1273    PyObject *_res = NULL;
     1274    OSErr _err;
     1275    FSSpec dest;
     1276    if (!PyArg_ParseTuple(_args, "O&",
     1277                          FSSpec_Convert, &dest))
     1278        return NULL;
     1279    _err = FSpCatMove(&_self->ob_itself,
     1280                      &dest);
     1281    if (_err != noErr) return PyMac_Error(_err);
     1282    Py_INCREF(Py_None);
     1283    _res = Py_None;
     1284    return _res;
    12851285}
    12861286
    12871287static PyObject *FSSpec_FSpExchangeFiles(FSSpecObject *_self, PyObject *_args)
    12881288{
    1289         PyObject *_res = NULL;
    1290         OSErr _err;
    1291         FSSpec dest;
    1292         if (!PyArg_ParseTuple(_args, "O&",
    1293                               FSSpec_Convert, &dest))
    1294                 return NULL;
    1295         _err = FSpExchangeFiles(&_self->ob_itself,
    1296                                 &dest);
    1297         if (_err != noErr) return PyMac_Error(_err);
    1298         Py_INCREF(Py_None);
    1299         _res = Py_None;
    1300         return _res;
     1289    PyObject *_res = NULL;
     1290    OSErr _err;
     1291    FSSpec dest;
     1292    if (!PyArg_ParseTuple(_args, "O&",
     1293                          FSSpec_Convert, &dest))
     1294        return NULL;
     1295    _err = FSpExchangeFiles(&_self->ob_itself,
     1296                            &dest);
     1297    if (_err != noErr) return PyMac_Error(_err);
     1298    Py_INCREF(Py_None);
     1299    _res = Py_None;
     1300    return _res;
    13011301}
    13021302
    13031303static PyObject *FSSpec_FSpMakeFSRef(FSSpecObject *_self, PyObject *_args)
    13041304{
    1305         PyObject *_res = NULL;
    1306         OSErr _err;
    1307         FSRef newRef;
    1308         if (!PyArg_ParseTuple(_args, ""))
    1309                 return NULL;
    1310         _err = FSpMakeFSRef(&_self->ob_itself,
    1311                             &newRef);
    1312         if (_err != noErr) return PyMac_Error(_err);
    1313         _res = Py_BuildValue("O&",
    1314                              FSRef_New, &newRef);
    1315         return _res;
     1305    PyObject *_res = NULL;
     1306    OSErr _err;
     1307    FSRef newRef;
     1308    if (!PyArg_ParseTuple(_args, ""))
     1309        return NULL;
     1310    _err = FSpMakeFSRef(&_self->ob_itself,
     1311                        &newRef);
     1312    if (_err != noErr) return PyMac_Error(_err);
     1313    _res = Py_BuildValue("O&",
     1314                         FSRef_New, &newRef);
     1315    return _res;
    13161316}
    13171317
    13181318static PyObject *FSSpec_NewAliasMinimal(FSSpecObject *_self, PyObject *_args)
    13191319{
    1320         PyObject *_res = NULL;
    1321         OSErr _err;
    1322         AliasHandle alias;
    1323         if (!PyArg_ParseTuple(_args, ""))
    1324                 return NULL;
    1325         _err = NewAliasMinimal(&_self->ob_itself,
    1326                                &alias);
    1327         if (_err != noErr) return PyMac_Error(_err);
    1328         _res = Py_BuildValue("O&",
    1329                              Alias_New, alias);
    1330         return _res;
     1320    PyObject *_res = NULL;
     1321    OSErr _err;
     1322    AliasHandle alias;
     1323    if (!PyArg_ParseTuple(_args, ""))
     1324        return NULL;
     1325    _err = NewAliasMinimal(&_self->ob_itself,
     1326                           &alias);
     1327    if (_err != noErr) return PyMac_Error(_err);
     1328    _res = Py_BuildValue("O&",
     1329                         Alias_New, alias);
     1330    return _res;
    13311331}
    13321332
    13331333static PyObject *FSSpec_IsAliasFile(FSSpecObject *_self, PyObject *_args)
    13341334{
    1335         PyObject *_res = NULL;
    1336         OSErr _err;
    1337         Boolean aliasFileFlag;
    1338         Boolean folderFlag;
    1339         if (!PyArg_ParseTuple(_args, ""))
    1340                 return NULL;
    1341         _err = IsAliasFile(&_self->ob_itself,
    1342                            &aliasFileFlag,
    1343                            &folderFlag);
    1344         if (_err != noErr) return PyMac_Error(_err);
    1345         _res = Py_BuildValue("bb",
    1346                              aliasFileFlag,
    1347                              folderFlag);
    1348         return _res;
     1335    PyObject *_res = NULL;
     1336    OSErr _err;
     1337    Boolean aliasFileFlag;
     1338    Boolean folderFlag;
     1339    if (!PyArg_ParseTuple(_args, ""))
     1340        return NULL;
     1341    _err = IsAliasFile(&_self->ob_itself,
     1342                       &aliasFileFlag,
     1343                       &folderFlag);
     1344    if (_err != noErr) return PyMac_Error(_err);
     1345    _res = Py_BuildValue("bb",
     1346                         aliasFileFlag,
     1347                         folderFlag);
     1348    return _res;
    13491349}
    13501350
    13511351static PyObject *FSSpec_as_pathname(FSSpecObject *_self, PyObject *_args)
    13521352{
    1353         PyObject *_res = NULL;
    1354 
    1355         char strbuf[1024];
    1356         OSErr err;
    1357 
    1358         if (!PyArg_ParseTuple(_args, ""))
    1359                 return NULL;
    1360         err = _PyMac_GetFullPathname(&_self->ob_itself, strbuf, sizeof(strbuf));
    1361         if ( err ) {
    1362                 PyMac_Error(err);
    1363                 return NULL;
    1364         }
    1365         _res = PyString_FromString(strbuf);
    1366         return _res;
     1353    PyObject *_res = NULL;
     1354
     1355    char strbuf[1024];
     1356    OSErr err;
     1357
     1358    if (!PyArg_ParseTuple(_args, ""))
     1359        return NULL;
     1360    err = _PyMac_GetFullPathname(&_self->ob_itself, strbuf, sizeof(strbuf));
     1361    if ( err ) {
     1362        PyMac_Error(err);
     1363        return NULL;
     1364    }
     1365    _res = PyString_FromString(strbuf);
     1366    return _res;
    13671367
    13681368}
     
    13701370static PyObject *FSSpec_as_tuple(FSSpecObject *_self, PyObject *_args)
    13711371{
    1372         PyObject *_res = NULL;
    1373 
    1374         if (!PyArg_ParseTuple(_args, ""))
    1375                 return NULL;
    1376         _res = Py_BuildValue("(iis#)", _self->ob_itself.vRefNum, _self->ob_itself.parID,
    1377                                                 &_self->ob_itself.name[1], _self->ob_itself.name[0]);
    1378         return _res;
     1372    PyObject *_res = NULL;
     1373
     1374    if (!PyArg_ParseTuple(_args, ""))
     1375        return NULL;
     1376    _res = Py_BuildValue("(iis#)", _self->ob_itself.vRefNum, _self->ob_itself.parID,
     1377                                            &_self->ob_itself.name[1], _self->ob_itself.name[0]);
     1378    return _res;
    13791379
    13801380}
    13811381
    13821382static PyMethodDef FSSpec_methods[] = {
    1383         {"FSpOpenDF", (PyCFunction)FSSpec_FSpOpenDF, 1,
    1384         PyDoc_STR("(SInt8 permission) -> (short refNum)")},
    1385         {"FSpOpenRF", (PyCFunction)FSSpec_FSpOpenRF, 1,
    1386         PyDoc_STR("(SInt8 permission) -> (short refNum)")},
    1387         {"FSpCreate", (PyCFunction)FSSpec_FSpCreate, 1,
    1388         PyDoc_STR("(OSType creator, OSType fileType, ScriptCode scriptTag) -> None")},
    1389         {"FSpDirCreate", (PyCFunction)FSSpec_FSpDirCreate, 1,
    1390         PyDoc_STR("(ScriptCode scriptTag) -> (long createdDirID)")},
    1391         {"FSpDelete", (PyCFunction)FSSpec_FSpDelete, 1,
    1392         PyDoc_STR("() -> None")},
    1393         {"FSpGetFInfo", (PyCFunction)FSSpec_FSpGetFInfo, 1,
    1394         PyDoc_STR("() -> (FInfo fndrInfo)")},
    1395         {"FSpSetFInfo", (PyCFunction)FSSpec_FSpSetFInfo, 1,
    1396         PyDoc_STR("(FInfo fndrInfo) -> None")},
    1397         {"FSpSetFLock", (PyCFunction)FSSpec_FSpSetFLock, 1,
    1398         PyDoc_STR("() -> None")},
    1399         {"FSpRstFLock", (PyCFunction)FSSpec_FSpRstFLock, 1,
    1400         PyDoc_STR("() -> None")},
    1401         {"FSpRename", (PyCFunction)FSSpec_FSpRename, 1,
    1402         PyDoc_STR("(Str255 newName) -> None")},
    1403         {"FSpCatMove", (PyCFunction)FSSpec_FSpCatMove, 1,
    1404         PyDoc_STR("(FSSpec dest) -> None")},
    1405         {"FSpExchangeFiles", (PyCFunction)FSSpec_FSpExchangeFiles, 1,
    1406         PyDoc_STR("(FSSpec dest) -> None")},
    1407         {"FSpMakeFSRef", (PyCFunction)FSSpec_FSpMakeFSRef, 1,
    1408         PyDoc_STR("() -> (FSRef newRef)")},
    1409         {"NewAliasMinimal", (PyCFunction)FSSpec_NewAliasMinimal, 1,
    1410         PyDoc_STR("() -> (AliasHandle alias)")},
    1411         {"IsAliasFile", (PyCFunction)FSSpec_IsAliasFile, 1,
    1412         PyDoc_STR("() -> (Boolean aliasFileFlag, Boolean folderFlag)")},
    1413         {"as_pathname", (PyCFunction)FSSpec_as_pathname, 1,
    1414         PyDoc_STR("() -> string")},
    1415         {"as_tuple", (PyCFunction)FSSpec_as_tuple, 1,
    1416         PyDoc_STR("() -> (vRefNum, dirID, name)")},
    1417         {NULL, NULL, 0}
     1383    {"FSpOpenDF", (PyCFunction)FSSpec_FSpOpenDF, 1,
     1384    PyDoc_STR("(SInt8 permission) -> (short refNum)")},
     1385    {"FSpOpenRF", (PyCFunction)FSSpec_FSpOpenRF, 1,
     1386    PyDoc_STR("(SInt8 permission) -> (short refNum)")},
     1387    {"FSpCreate", (PyCFunction)FSSpec_FSpCreate, 1,
     1388    PyDoc_STR("(OSType creator, OSType fileType, ScriptCode scriptTag) -> None")},
     1389    {"FSpDirCreate", (PyCFunction)FSSpec_FSpDirCreate, 1,
     1390    PyDoc_STR("(ScriptCode scriptTag) -> (long createdDirID)")},
     1391    {"FSpDelete", (PyCFunction)FSSpec_FSpDelete, 1,
     1392    PyDoc_STR("() -> None")},
     1393    {"FSpGetFInfo", (PyCFunction)FSSpec_FSpGetFInfo, 1,
     1394    PyDoc_STR("() -> (FInfo fndrInfo)")},
     1395    {"FSpSetFInfo", (PyCFunction)FSSpec_FSpSetFInfo, 1,
     1396    PyDoc_STR("(FInfo fndrInfo) -> None")},
     1397    {"FSpSetFLock", (PyCFunction)FSSpec_FSpSetFLock, 1,
     1398    PyDoc_STR("() -> None")},
     1399    {"FSpRstFLock", (PyCFunction)FSSpec_FSpRstFLock, 1,
     1400    PyDoc_STR("() -> None")},
     1401    {"FSpRename", (PyCFunction)FSSpec_FSpRename, 1,
     1402    PyDoc_STR("(Str255 newName) -> None")},
     1403    {"FSpCatMove", (PyCFunction)FSSpec_FSpCatMove, 1,
     1404    PyDoc_STR("(FSSpec dest) -> None")},
     1405    {"FSpExchangeFiles", (PyCFunction)FSSpec_FSpExchangeFiles, 1,
     1406    PyDoc_STR("(FSSpec dest) -> None")},
     1407    {"FSpMakeFSRef", (PyCFunction)FSSpec_FSpMakeFSRef, 1,
     1408    PyDoc_STR("() -> (FSRef newRef)")},
     1409    {"NewAliasMinimal", (PyCFunction)FSSpec_NewAliasMinimal, 1,
     1410    PyDoc_STR("() -> (AliasHandle alias)")},
     1411    {"IsAliasFile", (PyCFunction)FSSpec_IsAliasFile, 1,
     1412    PyDoc_STR("() -> (Boolean aliasFileFlag, Boolean folderFlag)")},
     1413    {"as_pathname", (PyCFunction)FSSpec_as_pathname, 1,
     1414    PyDoc_STR("() -> string")},
     1415    {"as_tuple", (PyCFunction)FSSpec_as_tuple, 1,
     1416    PyDoc_STR("() -> (vRefNum, dirID, name)")},
     1417    {NULL, NULL, 0}
    14181418};
    14191419
    14201420static PyObject *FSSpec_get_data(FSSpecObject *self, void *closure)
    14211421{
    1422         return PyString_FromStringAndSize((char *)&self->ob_itself, sizeof(self->ob_itself));
     1422    return PyString_FromStringAndSize((char *)&self->ob_itself, sizeof(self->ob_itself));
    14231423}
    14241424
     
    14261426
    14271427static PyGetSetDef FSSpec_getsetlist[] = {
    1428         {"data", (getter)FSSpec_get_data, (setter)FSSpec_set_data, "Raw data of the FSSpec object"},
    1429         {NULL, NULL, NULL, NULL},
     1428    {"data", (getter)FSSpec_get_data, (setter)FSSpec_set_data, "Raw data of the FSSpec object"},
     1429    {NULL, NULL, NULL, NULL},
    14301430};
    14311431
     
    14351435static PyObject * FSSpec_repr(FSSpecObject *self)
    14361436{
    1437         char buf[512];
    1438         PyOS_snprintf(buf, sizeof(buf), "%s((%d, %ld, '%.*s'))",
    1439                 self->ob_type->tp_name,
    1440                 self->ob_itself.vRefNum,
    1441                 self->ob_itself.parID,
    1442                 self->ob_itself.name[0], self->ob_itself.name+1);
    1443         return PyString_FromString(buf);
     1437    char buf[512];
     1438    PyOS_snprintf(buf, sizeof(buf), "%s((%d, %ld, '%.*s'))",
     1439        self->ob_type->tp_name,
     1440        self->ob_itself.vRefNum,
     1441        self->ob_itself.parID,
     1442        self->ob_itself.name[0], self->ob_itself.name+1);
     1443    return PyString_FromString(buf);
    14441444}
    14451445
     
    14471447static int FSSpec_tp_init(PyObject *_self, PyObject *_args, PyObject *_kwds)
    14481448{
    1449         PyObject *v = NULL;
    1450         char *rawdata = NULL;
    1451         int rawdatalen = 0;
    1452         static char *kw[] = {"itself", "rawdata", 0};
    1453 
    1454         if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "|Os#", kw, &v, &rawdata, &rawdatalen))
    1455         return -1;
    1456         if (v && rawdata)
    1457         {
    1458                 PyErr_SetString(PyExc_TypeError, "Only one of itself or rawdata may be specified");
    1459                 return -1;
    1460         }
    1461         if (!v && !rawdata)
    1462         {
    1463                 PyErr_SetString(PyExc_TypeError, "One of itself or rawdata must be specified");
    1464                 return -1;
    1465         }
    1466         if (rawdata)
    1467         {
    1468                 if (rawdatalen != sizeof(FSSpec))
    1469                 {
    1470                         PyErr_SetString(PyExc_TypeError, "FSSpec rawdata incorrect size");
    1471                         return -1;
    1472                 }
    1473                 memcpy(&((FSSpecObject *)_self)->ob_itself, rawdata, rawdatalen);
    1474                 return 0;
    1475         }
    1476         if (PyMac_GetFSSpec(v, &((FSSpecObject *)_self)->ob_itself)) return 0;
    1477         return -1;
     1449    PyObject *v = NULL;
     1450    char *rawdata = NULL;
     1451    int rawdatalen = 0;
     1452    static char *kw[] = {"itself", "rawdata", 0};
     1453
     1454    if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "|Os#", kw, &v, &rawdata, &rawdatalen))
     1455    return -1;
     1456    if (v && rawdata)
     1457    {
     1458        PyErr_SetString(PyExc_TypeError, "Only one of itself or rawdata may be specified");
     1459        return -1;
     1460    }
     1461    if (!v && !rawdata)
     1462    {
     1463        PyErr_SetString(PyExc_TypeError, "One of itself or rawdata must be specified");
     1464        return -1;
     1465    }
     1466    if (rawdata)
     1467    {
     1468        if (rawdatalen != sizeof(FSSpec))
     1469        {
     1470            PyErr_SetString(PyExc_TypeError, "FSSpec rawdata incorrect size");
     1471            return -1;
     1472        }
     1473        memcpy(&((FSSpecObject *)_self)->ob_itself, rawdata, rawdatalen);
     1474        return 0;
     1475    }
     1476    if (PyMac_GetFSSpec(v, &((FSSpecObject *)_self)->ob_itself)) return 0;
     1477    return -1;
    14781478}
    14791479
     
    14821482static PyObject *FSSpec_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds)
    14831483{
    1484         PyObject *self;
    1485 
    1486         if ((self = type->tp_alloc(type, 0)) == NULL) return NULL;
    1487         memset(&((FSSpecObject *)self)->ob_itself, 0, sizeof(FSSpec));
    1488         return self;
     1484    PyObject *self;
     1485
     1486    if ((self = type->tp_alloc(type, 0)) == NULL) return NULL;
     1487    memset(&((FSSpecObject *)self)->ob_itself, 0, sizeof(FSSpec));
     1488    return self;
    14891489}
    14901490
     
    14931493
    14941494static PyTypeObject FSSpec_Type = {
    1495         PyObject_HEAD_INIT(NULL)
    1496         0, /*ob_size*/
    1497         "Carbon.File.FSSpec", /*tp_name*/
    1498         sizeof(FSSpecObject), /*tp_basicsize*/
    1499         0, /*tp_itemsize*/
    1500         /* methods */
    1501         (destructor) FSSpec_dealloc, /*tp_dealloc*/
    1502         0, /*tp_print*/
    1503         (getattrfunc)0, /*tp_getattr*/
    1504         (setattrfunc)0, /*tp_setattr*/
    1505         (cmpfunc) FSSpec_compare, /*tp_compare*/
    1506         (reprfunc) FSSpec_repr, /*tp_repr*/
    1507         (PyNumberMethods *)0, /* tp_as_number */
    1508         (PySequenceMethods *)0, /* tp_as_sequence */
    1509         (PyMappingMethods *)0, /* tp_as_mapping */
    1510         (hashfunc) FSSpec_hash, /*tp_hash*/
    1511         0, /*tp_call*/
    1512         0, /*tp_str*/
    1513         PyObject_GenericGetAttr, /*tp_getattro*/
    1514         PyObject_GenericSetAttr, /*tp_setattro */
    1515         0, /*tp_as_buffer*/
    1516         Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */
    1517         0, /*tp_doc*/
    1518         0, /*tp_traverse*/
    1519         0, /*tp_clear*/
    1520         0, /*tp_richcompare*/
    1521         0, /*tp_weaklistoffset*/
    1522         0, /*tp_iter*/
    1523         0, /*tp_iternext*/
    1524         FSSpec_methods, /* tp_methods */
    1525         0, /*tp_members*/
    1526         FSSpec_getsetlist, /*tp_getset*/
    1527         0, /*tp_base*/
    1528         0, /*tp_dict*/
    1529         0, /*tp_descr_get*/
    1530         0, /*tp_descr_set*/
    1531         0, /*tp_dictoffset*/
    1532         FSSpec_tp_init, /* tp_init */
    1533         FSSpec_tp_alloc, /* tp_alloc */
    1534         FSSpec_tp_new, /* tp_new */
    1535         FSSpec_tp_free, /* tp_free */
     1495    PyObject_HEAD_INIT(NULL)
     1496    0, /*ob_size*/
     1497    "Carbon.File.FSSpec", /*tp_name*/
     1498    sizeof(FSSpecObject), /*tp_basicsize*/
     1499    0, /*tp_itemsize*/
     1500    /* methods */
     1501    (destructor) FSSpec_dealloc, /*tp_dealloc*/
     1502    0, /*tp_print*/
     1503    (getattrfunc)0, /*tp_getattr*/
     1504    (setattrfunc)0, /*tp_setattr*/
     1505    (cmpfunc) FSSpec_compare, /*tp_compare*/
     1506    (reprfunc) FSSpec_repr, /*tp_repr*/
     1507    (PyNumberMethods *)0, /* tp_as_number */
     1508    (PySequenceMethods *)0, /* tp_as_sequence */
     1509    (PyMappingMethods *)0, /* tp_as_mapping */
     1510    (hashfunc) FSSpec_hash, /*tp_hash*/
     1511    0, /*tp_call*/
     1512    0, /*tp_str*/
     1513    PyObject_GenericGetAttr, /*tp_getattro*/
     1514    PyObject_GenericSetAttr, /*tp_setattro */
     1515    0, /*tp_as_buffer*/
     1516    Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */
     1517    0, /*tp_doc*/
     1518    0, /*tp_traverse*/
     1519    0, /*tp_clear*/
     1520    0, /*tp_richcompare*/
     1521    0, /*tp_weaklistoffset*/
     1522    0, /*tp_iter*/
     1523    0, /*tp_iternext*/
     1524    FSSpec_methods, /* tp_methods */
     1525    0, /*tp_members*/
     1526    FSSpec_getsetlist, /*tp_getset*/
     1527    0, /*tp_base*/
     1528    0, /*tp_dict*/
     1529    0, /*tp_descr_get*/
     1530    0, /*tp_descr_set*/
     1531    0, /*tp_dictoffset*/
     1532    FSSpec_tp_init, /* tp_init */
     1533    FSSpec_tp_alloc, /* tp_alloc */
     1534    FSSpec_tp_new, /* tp_new */
     1535    FSSpec_tp_free, /* tp_free */
    15361536};
    15371537
     
    15471547
    15481548typedef struct FSRefObject {
    1549         PyObject_HEAD
    1550         FSRef ob_itself;
     1549    PyObject_HEAD
     1550    FSRef ob_itself;
    15511551} FSRefObject;
    15521552
    15531553static PyObject *FSRef_New(FSRef *itself)
    15541554{
    1555         FSRefObject *it;
    1556         if (itself == NULL) return PyMac_Error(resNotFound);
    1557         it = PyObject_NEW(FSRefObject, &FSRef_Type);
    1558         if (it == NULL) return NULL;
    1559         it->ob_itself = *itself;
    1560         return (PyObject *)it;
     1555    FSRefObject *it;
     1556    if (itself == NULL) return PyMac_Error(resNotFound);
     1557    it = PyObject_NEW(FSRefObject, &FSRef_Type);
     1558    if (it == NULL) return NULL;
     1559    it->ob_itself = *itself;
     1560    return (PyObject *)it;
    15611561}
    15621562
    15631563static void FSRef_dealloc(FSRefObject *self)
    15641564{
    1565         /* Cleanup of self->ob_itself goes here */
    1566         self->ob_type->tp_free((PyObject *)self);
     1565    /* Cleanup of self->ob_itself goes here */
     1566    self->ob_type->tp_free((PyObject *)self);
    15671567}
    15681568
    15691569static PyObject *FSRef_FSMakeFSRefUnicode(FSRefObject *_self, PyObject *_args)
    15701570{
    1571         PyObject *_res = NULL;
    1572         OSErr _err;
    1573         UniChar *nameLength__in__;
    1574         UniCharCount nameLength__len__;
    1575         int nameLength__in_len__;
    1576         TextEncoding textEncodingHint;
    1577         FSRef newRef;
    1578         if (!PyArg_ParseTuple(_args, "u#l",
    1579                               &nameLength__in__, &nameLength__in_len__,
    1580                               &textEncodingHint))
    1581                 return NULL;
    1582         nameLength__len__ = nameLength__in_len__;
    1583         _err = FSMakeFSRefUnicode(&_self->ob_itself,
    1584                                   nameLength__len__, nameLength__in__,
    1585                                   textEncodingHint,
    1586                                   &newRef);
    1587         if (_err != noErr) return PyMac_Error(_err);
    1588         _res = Py_BuildValue("O&",
    1589                              FSRef_New, &newRef);
    1590         return _res;
     1571    PyObject *_res = NULL;
     1572    OSErr _err;
     1573    UniChar *nameLength__in__;
     1574    UniCharCount nameLength__len__;
     1575    int nameLength__in_len__;
     1576    TextEncoding textEncodingHint;
     1577    FSRef newRef;
     1578    if (!PyArg_ParseTuple(_args, "u#l",
     1579                          &nameLength__in__, &nameLength__in_len__,
     1580                          &textEncodingHint))
     1581        return NULL;
     1582    nameLength__len__ = nameLength__in_len__;
     1583    _err = FSMakeFSRefUnicode(&_self->ob_itself,
     1584                              nameLength__len__, nameLength__in__,
     1585                              textEncodingHint,
     1586                              &newRef);
     1587    if (_err != noErr) return PyMac_Error(_err);
     1588    _res = Py_BuildValue("O&",
     1589                         FSRef_New, &newRef);
     1590    return _res;
    15911591}
    15921592
    15931593static PyObject *FSRef_FSCompareFSRefs(FSRefObject *_self, PyObject *_args)
    15941594{
    1595         PyObject *_res = NULL;
    1596         OSErr _err;
    1597         FSRef ref2;
    1598         if (!PyArg_ParseTuple(_args, "O&",
    1599                               FSRef_Convert, &ref2))
    1600                 return NULL;
    1601         _err = FSCompareFSRefs(&_self->ob_itself,
    1602                                &ref2);
    1603         if (_err != noErr) return PyMac_Error(_err);
    1604         Py_INCREF(Py_None);
    1605         _res = Py_None;
    1606         return _res;
     1595    PyObject *_res = NULL;
     1596    OSErr _err;
     1597    FSRef ref2;
     1598    if (!PyArg_ParseTuple(_args, "O&",
     1599                          FSRef_Convert, &ref2))
     1600        return NULL;
     1601    _err = FSCompareFSRefs(&_self->ob_itself,
     1602                           &ref2);
     1603    if (_err != noErr) return PyMac_Error(_err);
     1604    Py_INCREF(Py_None);
     1605    _res = Py_None;
     1606    return _res;
    16071607}
    16081608
    16091609static PyObject *FSRef_FSCreateFileUnicode(FSRefObject *_self, PyObject *_args)
    16101610{
    1611         PyObject *_res = NULL;
    1612         OSErr _err;
    1613         UniChar *nameLength__in__;
    1614         UniCharCount nameLength__len__;
    1615         int nameLength__in_len__;
    1616         FSCatalogInfoBitmap whichInfo;
    1617         FSCatalogInfo catalogInfo;
    1618         FSRef newRef;
     1611    PyObject *_res = NULL;
     1612    OSErr _err;
     1613    UniChar *nameLength__in__;
     1614    UniCharCount nameLength__len__;
     1615    int nameLength__in_len__;
     1616    FSCatalogInfoBitmap whichInfo;
     1617    FSCatalogInfo catalogInfo;
     1618    FSRef newRef;
    16191619#ifndef __LP64__
    1620         FSSpec newSpec;
     1620    FSSpec newSpec;
    16211621#endif
    1622         if (!PyArg_ParseTuple(_args, "u#lO&",
    1623                               &nameLength__in__, &nameLength__in_len__,
    1624                               &whichInfo,
    1625                               FSCatalogInfo_Convert, &catalogInfo))
    1626                 return NULL;
    1627         nameLength__len__ = nameLength__in_len__;
    1628         _err = FSCreateFileUnicode(&_self->ob_itself,
    1629                                    nameLength__len__, nameLength__in__,
    1630                                    whichInfo,
    1631                                    &catalogInfo,
    1632                                    &newRef,
     1622    if (!PyArg_ParseTuple(_args, "u#lO&",
     1623                          &nameLength__in__, &nameLength__in_len__,
     1624                          &whichInfo,
     1625                          FSCatalogInfo_Convert, &catalogInfo))
     1626        return NULL;
     1627    nameLength__len__ = nameLength__in_len__;
     1628    _err = FSCreateFileUnicode(&_self->ob_itself,
     1629                               nameLength__len__, nameLength__in__,
     1630                               whichInfo,
     1631                               &catalogInfo,
     1632                               &newRef,
    16331633#ifndef __LP64__
    1634                                    &newSpec
    1635 #else   /* __LP64__ */
    1636                                    NULL
     1634                               &newSpec
     1635#else   /* __LP64__ */
     1636                               NULL
    16371637#endif /* __LP64__*/
    1638                                   );
    1639         if (_err != noErr) return PyMac_Error(_err);
     1638                              );
     1639    if (_err != noErr) return PyMac_Error(_err);
    16401640
    16411641#ifndef __LP64__
    1642         _res = Py_BuildValue("O&O&",
    1643                              FSRef_New, &newRef,
    1644                              FSSpec_New, &newSpec);
     1642    _res = Py_BuildValue("O&O&",
     1643                         FSRef_New, &newRef,
     1644                         FSSpec_New, &newSpec);
    16451645#else /* __LP64__ */
    1646         _res = Py_BuildValue("O&O", FSRef_New, &newRef, Py_None);
     1646    _res = Py_BuildValue("O&O", FSRef_New, &newRef, Py_None);
    16471647#endif /* __LP64__ */
    16481648
    1649         return _res;
     1649    return _res;
    16501650}
    16511651
    16521652static PyObject *FSRef_FSCreateDirectoryUnicode(FSRefObject *_self, PyObject *_args)
    16531653{
    1654         PyObject *_res = NULL;
    1655         OSErr _err;
    1656         UniChar *nameLength__in__;
    1657         UniCharCount nameLength__len__;
    1658         int nameLength__in_len__;
    1659         FSCatalogInfoBitmap whichInfo;
    1660         FSCatalogInfo catalogInfo;
    1661         FSRef newRef;
     1654    PyObject *_res = NULL;
     1655    OSErr _err;
     1656    UniChar *nameLength__in__;
     1657    UniCharCount nameLength__len__;
     1658    int nameLength__in_len__;
     1659    FSCatalogInfoBitmap whichInfo;
     1660    FSCatalogInfo catalogInfo;
     1661    FSRef newRef;
    16621662#ifndef __LP64__
    1663         FSSpec newSpec;
     1663    FSSpec newSpec;
    16641664#endif /* !__LP64__ */
    1665         UInt32 newDirID;
    1666         if (!PyArg_ParseTuple(_args, "u#lO&",
    1667                               &nameLength__in__, &nameLength__in_len__,
    1668                               &whichInfo,
    1669                               FSCatalogInfo_Convert, &catalogInfo))
    1670                 return NULL;
    1671         nameLength__len__ = nameLength__in_len__;
    1672         _err = FSCreateDirectoryUnicode(&_self->ob_itself,
    1673                                         nameLength__len__, nameLength__in__,
    1674                                         whichInfo,
    1675                                         &catalogInfo,
    1676                                         &newRef,
     1665    UInt32 newDirID;
     1666    if (!PyArg_ParseTuple(_args, "u#lO&",
     1667                          &nameLength__in__, &nameLength__in_len__,
     1668                          &whichInfo,
     1669                          FSCatalogInfo_Convert, &catalogInfo))
     1670        return NULL;
     1671    nameLength__len__ = nameLength__in_len__;
     1672    _err = FSCreateDirectoryUnicode(&_self->ob_itself,
     1673                                    nameLength__len__, nameLength__in__,
     1674                                    whichInfo,
     1675                                    &catalogInfo,
     1676                                    &newRef,
    16771677#ifndef __LP64__
    1678                                         &newSpec,
     1678                                    &newSpec,
    16791679#else /* !__LP64__ */
    1680                                         NULL,
     1680                                    NULL,
    16811681#endif /* !__LP64__ */
    1682                                         &newDirID);
    1683         if (_err != noErr) return PyMac_Error(_err);
     1682                                    &newDirID);
     1683    if (_err != noErr) return PyMac_Error(_err);
    16841684
    16851685#ifndef __LP64__
    1686         _res = Py_BuildValue("O&O&l",
    1687                              FSRef_New, &newRef,
    1688                              FSSpec_New, &newSpec,
    1689                              newDirID);
    1690 #else   /* __LP64__ */
    1691         _res = Py_BuildValue("O&Ol",
    1692                              FSRef_New, &newRef,
    1693                              Py_None,
    1694                              newDirID);
     1686    _res = Py_BuildValue("O&O&l",
     1687                         FSRef_New, &newRef,
     1688                         FSSpec_New, &newSpec,
     1689                         newDirID);
     1690#else   /* __LP64__ */
     1691    _res = Py_BuildValue("O&Ol",
     1692                         FSRef_New, &newRef,
     1693                         Py_None,
     1694                         newDirID);
    16951695#endif /* __LP64__ */
    1696         return _res;
     1696    return _res;
    16971697}
    16981698
    16991699static PyObject *FSRef_FSDeleteObject(FSRefObject *_self, PyObject *_args)
    17001700{
    1701         PyObject *_res = NULL;
    1702         OSErr _err;
    1703         if (!PyArg_ParseTuple(_args, ""))
    1704                 return NULL;
    1705         _err = FSDeleteObject(&_self->ob_itself);
    1706         if (_err != noErr) return PyMac_Error(_err);
    1707         Py_INCREF(Py_None);
    1708         _res = Py_None;
    1709         return _res;
     1701    PyObject *_res = NULL;
     1702    OSErr _err;
     1703    if (!PyArg_ParseTuple(_args, ""))
     1704        return NULL;
     1705    _err = FSDeleteObject(&_self->ob_itself);
     1706    if (_err != noErr) return PyMac_Error(_err);
     1707    Py_INCREF(Py_None);
     1708    _res = Py_None;
     1709    return _res;
    17101710}
    17111711
    17121712static PyObject *FSRef_FSMoveObject(FSRefObject *_self, PyObject *_args)
    17131713{
    1714         PyObject *_res = NULL;
    1715         OSErr _err;
    1716         FSRef destDirectory;
    1717         FSRef newRef;
    1718         if (!PyArg_ParseTuple(_args, "O&",
    1719                               FSRef_Convert, &destDirectory))
    1720                 return NULL;
    1721         _err = FSMoveObject(&_self->ob_itself,
    1722                             &destDirectory,
    1723                             &newRef);
    1724         if (_err != noErr) return PyMac_Error(_err);
    1725         _res = Py_BuildValue("O&",
    1726                              FSRef_New, &newRef);
    1727         return _res;
     1714    PyObject *_res = NULL;
     1715    OSErr _err;
     1716    FSRef destDirectory;
     1717    FSRef newRef;
     1718    if (!PyArg_ParseTuple(_args, "O&",
     1719                          FSRef_Convert, &destDirectory))
     1720        return NULL;
     1721    _err = FSMoveObject(&_self->ob_itself,
     1722                        &destDirectory,
     1723                        &newRef);
     1724    if (_err != noErr) return PyMac_Error(_err);
     1725    _res = Py_BuildValue("O&",
     1726                         FSRef_New, &newRef);
     1727    return _res;
    17281728}
    17291729
    17301730static PyObject *FSRef_FSExchangeObjects(FSRefObject *_self, PyObject *_args)
    17311731{
    1732         PyObject *_res = NULL;
    1733         OSErr _err;
    1734         FSRef destRef;
    1735         if (!PyArg_ParseTuple(_args, "O&",
    1736                               FSRef_Convert, &destRef))
    1737                 return NULL;
    1738         _err = FSExchangeObjects(&_self->ob_itself,
    1739                                  &destRef);
    1740         if (_err != noErr) return PyMac_Error(_err);
    1741         Py_INCREF(Py_None);
    1742         _res = Py_None;
    1743         return _res;
     1732    PyObject *_res = NULL;
     1733    OSErr _err;
     1734    FSRef destRef;
     1735    if (!PyArg_ParseTuple(_args, "O&",
     1736                          FSRef_Convert, &destRef))
     1737        return NULL;
     1738    _err = FSExchangeObjects(&_self->ob_itself,
     1739                             &destRef);
     1740    if (_err != noErr) return PyMac_Error(_err);
     1741    Py_INCREF(Py_None);
     1742    _res = Py_None;
     1743    return _res;
    17441744}
    17451745
    17461746static PyObject *FSRef_FSRenameUnicode(FSRefObject *_self, PyObject *_args)
    17471747{
    1748         PyObject *_res = NULL;
    1749         OSErr _err;
    1750         UniChar *nameLength__in__;
    1751         UniCharCount nameLength__len__;
    1752         int nameLength__in_len__;
    1753         TextEncoding textEncodingHint;
    1754         FSRef newRef;
    1755         if (!PyArg_ParseTuple(_args, "u#l",
    1756                               &nameLength__in__, &nameLength__in_len__,
    1757                               &textEncodingHint))
    1758                 return NULL;
    1759         nameLength__len__ = nameLength__in_len__;
    1760         _err = FSRenameUnicode(&_self->ob_itself,
    1761                                nameLength__len__, nameLength__in__,
    1762                                textEncodingHint,
    1763                                &newRef);
    1764         if (_err != noErr) return PyMac_Error(_err);
    1765         _res = Py_BuildValue("O&",
    1766                              FSRef_New, &newRef);
    1767         return _res;
     1748    PyObject *_res = NULL;
     1749    OSErr _err;
     1750    UniChar *nameLength__in__;
     1751    UniCharCount nameLength__len__;
     1752    int nameLength__in_len__;
     1753    TextEncoding textEncodingHint;
     1754    FSRef newRef;
     1755    if (!PyArg_ParseTuple(_args, "u#l",
     1756                          &nameLength__in__, &nameLength__in_len__,
     1757                          &textEncodingHint))
     1758        return NULL;
     1759    nameLength__len__ = nameLength__in_len__;
     1760    _err = FSRenameUnicode(&_self->ob_itself,
     1761                           nameLength__len__, nameLength__in__,
     1762                           textEncodingHint,
     1763                           &newRef);
     1764    if (_err != noErr) return PyMac_Error(_err);
     1765    _res = Py_BuildValue("O&",
     1766                         FSRef_New, &newRef);
     1767    return _res;
    17681768}
    17691769
    17701770static PyObject *FSRef_FSGetCatalogInfo(FSRefObject *_self, PyObject *_args)
    17711771{
    1772         PyObject *_res = NULL;
    1773         OSErr _err;
    1774         FSCatalogInfoBitmap whichInfo;
    1775         FSCatalogInfo catalogInfo;
    1776         HFSUniStr255 outName;
     1772    PyObject *_res = NULL;
     1773    OSErr _err;
     1774    FSCatalogInfoBitmap whichInfo;
     1775    FSCatalogInfo catalogInfo;
     1776    HFSUniStr255 outName;
    17771777#ifndef __LP64__
    1778         FSSpec fsSpec;
     1778    FSSpec fsSpec;
    17791779#endif /* !__LP64__ */
    1780         FSRef parentRef;
    1781         if (!PyArg_ParseTuple(_args, "l",
    1782                               &whichInfo))
    1783                 return NULL;
    1784         _err = FSGetCatalogInfo(&_self->ob_itself,
    1785                                 whichInfo,
    1786                                 &catalogInfo,
    1787                                 &outName,
     1780    FSRef parentRef;
     1781    if (!PyArg_ParseTuple(_args, "l",
     1782                          &whichInfo))
     1783        return NULL;
     1784    _err = FSGetCatalogInfo(&_self->ob_itself,
     1785                            whichInfo,
     1786                            &catalogInfo,
     1787                            &outName,
    17881788#ifndef __LP64__
    1789                                 &fsSpec,
    1790 #else   /* __LP64__ */
    1791                                 NULL,
     1789                            &fsSpec,
     1790#else   /* __LP64__ */
     1791                            NULL,
    17921792#endif /* __LP64__ */
    1793                                 &parentRef);
    1794         if (_err != noErr) return PyMac_Error(_err);
     1793                            &parentRef);
     1794    if (_err != noErr) return PyMac_Error(_err);
    17951795
    17961796#ifndef __LP64__
    1797         _res = Py_BuildValue("O&O&O&O&",
    1798                              FSCatalogInfo_New, &catalogInfo,
    1799                              PyMac_BuildHFSUniStr255, &outName,
    1800                              FSSpec_New, &fsSpec,
    1801                              FSRef_New, &parentRef);
    1802 #else   /* __LP64__ */
    1803         _res = Py_BuildValue("O&O&OO&",
    1804                              FSCatalogInfo_New, &catalogInfo,
    1805                              PyMac_BuildHFSUniStr255, &outName,
    1806                              Py_None,
    1807                              FSRef_New, &parentRef);
     1797    _res = Py_BuildValue("O&O&O&O&",
     1798                         FSCatalogInfo_New, &catalogInfo,
     1799                         PyMac_BuildHFSUniStr255, &outName,
     1800                         FSSpec_New, &fsSpec,
     1801                         FSRef_New, &parentRef);
     1802#else   /* __LP64__ */
     1803    _res = Py_BuildValue("O&O&OO&",
     1804                         FSCatalogInfo_New, &catalogInfo,
     1805                         PyMac_BuildHFSUniStr255, &outName,
     1806                         Py_None,
     1807                         FSRef_New, &parentRef);
    18081808#endif /* __LP64__ */
    1809         return _res;
     1809    return _res;
    18101810}
    18111811
    18121812static PyObject *FSRef_FSSetCatalogInfo(FSRefObject *_self, PyObject *_args)
    18131813{
    1814         PyObject *_res = NULL;
    1815         OSErr _err;
    1816         FSCatalogInfoBitmap whichInfo;
    1817         FSCatalogInfo catalogInfo;
    1818         if (!PyArg_ParseTuple(_args, "lO&",
    1819                               &whichInfo,
    1820                               FSCatalogInfo_Convert, &catalogInfo))
    1821                 return NULL;
    1822         _err = FSSetCatalogInfo(&_self->ob_itself,
    1823                                 whichInfo,
    1824                                 &catalogInfo);
    1825         if (_err != noErr) return PyMac_Error(_err);
    1826         Py_INCREF(Py_None);
    1827         _res = Py_None;
    1828         return _res;
     1814    PyObject *_res = NULL;
     1815    OSErr _err;
     1816    FSCatalogInfoBitmap whichInfo;
     1817    FSCatalogInfo catalogInfo;
     1818    if (!PyArg_ParseTuple(_args, "lO&",
     1819                          &whichInfo,
     1820                          FSCatalogInfo_Convert, &catalogInfo))
     1821        return NULL;
     1822    _err = FSSetCatalogInfo(&_self->ob_itself,
     1823                            whichInfo,
     1824                            &catalogInfo);
     1825    if (_err != noErr) return PyMac_Error(_err);
     1826    Py_INCREF(Py_None);
     1827    _res = Py_None;
     1828    return _res;
    18291829}
    18301830
    18311831static PyObject *FSRef_FSCreateFork(FSRefObject *_self, PyObject *_args)
    18321832{
    1833         PyObject *_res = NULL;
    1834         OSErr _err;
    1835         UniChar *forkNameLength__in__;
    1836         UniCharCount forkNameLength__len__;
    1837         int forkNameLength__in_len__;
    1838         if (!PyArg_ParseTuple(_args, "u#",
    1839                               &forkNameLength__in__, &forkNameLength__in_len__))
    1840                 return NULL;
    1841         forkNameLength__len__ = forkNameLength__in_len__;
    1842         _err = FSCreateFork(&_self->ob_itself,
    1843                             forkNameLength__len__, forkNameLength__in__);
    1844         if (_err != noErr) return PyMac_Error(_err);
    1845         Py_INCREF(Py_None);
    1846         _res = Py_None;
    1847         return _res;
     1833    PyObject *_res = NULL;
     1834    OSErr _err;
     1835    UniChar *forkNameLength__in__;
     1836    UniCharCount forkNameLength__len__;
     1837    int forkNameLength__in_len__;
     1838    if (!PyArg_ParseTuple(_args, "u#",
     1839                          &forkNameLength__in__, &forkNameLength__in_len__))
     1840        return NULL;
     1841    forkNameLength__len__ = forkNameLength__in_len__;
     1842    _err = FSCreateFork(&_self->ob_itself,
     1843                        forkNameLength__len__, forkNameLength__in__);
     1844    if (_err != noErr) return PyMac_Error(_err);
     1845    Py_INCREF(Py_None);
     1846    _res = Py_None;
     1847    return _res;
    18481848}
    18491849
    18501850static PyObject *FSRef_FSDeleteFork(FSRefObject *_self, PyObject *_args)
    18511851{
    1852         PyObject *_res = NULL;
    1853         OSErr _err;
    1854         UniChar *forkNameLength__in__;
    1855         UniCharCount forkNameLength__len__;
    1856         int forkNameLength__in_len__;
    1857         if (!PyArg_ParseTuple(_args, "u#",
    1858                               &forkNameLength__in__, &forkNameLength__in_len__))
    1859                 return NULL;
    1860         forkNameLength__len__ = forkNameLength__in_len__;
    1861         _err = FSDeleteFork(&_self->ob_itself,
    1862                             forkNameLength__len__, forkNameLength__in__);
    1863         if (_err != noErr) return PyMac_Error(_err);
    1864         Py_INCREF(Py_None);
    1865         _res = Py_None;
    1866         return _res;
     1852    PyObject *_res = NULL;
     1853    OSErr _err;
     1854    UniChar *forkNameLength__in__;
     1855    UniCharCount forkNameLength__len__;
     1856    int forkNameLength__in_len__;
     1857    if (!PyArg_ParseTuple(_args, "u#",
     1858                          &forkNameLength__in__, &forkNameLength__in_len__))
     1859        return NULL;
     1860    forkNameLength__len__ = forkNameLength__in_len__;
     1861    _err = FSDeleteFork(&_self->ob_itself,
     1862                        forkNameLength__len__, forkNameLength__in__);
     1863    if (_err != noErr) return PyMac_Error(_err);
     1864    Py_INCREF(Py_None);
     1865    _res = Py_None;
     1866    return _res;
    18671867}
    18681868
    18691869static PyObject *FSRef_FSOpenFork(FSRefObject *_self, PyObject *_args)
    18701870{
    1871         PyObject *_res = NULL;
    1872         OSErr _err;
    1873         UniChar *forkNameLength__in__;
    1874         UniCharCount forkNameLength__len__;
    1875         int forkNameLength__in_len__;
    1876         SInt8 permissions;
    1877         FSIORefNum forkRefNum;
    1878         if (!PyArg_ParseTuple(_args, "u#b",
    1879                               &forkNameLength__in__, &forkNameLength__in_len__,
    1880                               &permissions))
    1881                 return NULL;
    1882         forkNameLength__len__ = forkNameLength__in_len__;
    1883         _err = FSOpenFork(&_self->ob_itself,
    1884                           forkNameLength__len__, forkNameLength__in__,
    1885                           permissions,
    1886                           &forkRefNum);
    1887         if (_err != noErr) return PyMac_Error(_err);
    1888         _res = Py_BuildValue("h",
    1889                              forkRefNum);
    1890         return _res;
     1871    PyObject *_res = NULL;
     1872    OSErr _err;
     1873    UniChar *forkNameLength__in__;
     1874    UniCharCount forkNameLength__len__;
     1875    int forkNameLength__in_len__;
     1876    SInt8 permissions;
     1877    FSIORefNum forkRefNum;
     1878    if (!PyArg_ParseTuple(_args, "u#b",
     1879                          &forkNameLength__in__, &forkNameLength__in_len__,
     1880                          &permissions))
     1881        return NULL;
     1882    forkNameLength__len__ = forkNameLength__in_len__;
     1883    _err = FSOpenFork(&_self->ob_itself,
     1884                      forkNameLength__len__, forkNameLength__in__,
     1885                      permissions,
     1886                      &forkRefNum);
     1887    if (_err != noErr) return PyMac_Error(_err);
     1888    _res = Py_BuildValue("h",
     1889                         forkRefNum);
     1890    return _res;
    18911891}
    18921892
    18931893static PyObject *FSRef_FNNotify(FSRefObject *_self, PyObject *_args)
    18941894{
    1895         PyObject *_res = NULL;
    1896         OSStatus _err;
    1897         FNMessage message;
    1898         OptionBits flags;
    1899         if (!PyArg_ParseTuple(_args, "ll",
    1900                               &message,
    1901                               &flags))
    1902                 return NULL;
    1903         _err = FNNotify(&_self->ob_itself,
    1904                         message,
    1905                         flags);
    1906         if (_err != noErr) return PyMac_Error(_err);
    1907         Py_INCREF(Py_None);
    1908         _res = Py_None;
    1909         return _res;
     1895    PyObject *_res = NULL;
     1896    OSStatus _err;
     1897    FNMessage message;
     1898    OptionBits flags;
     1899    if (!PyArg_ParseTuple(_args, "ll",
     1900                          &message,
     1901                          &flags))
     1902        return NULL;
     1903    _err = FNNotify(&_self->ob_itself,
     1904                    message,
     1905                    flags);
     1906    if (_err != noErr) return PyMac_Error(_err);
     1907    Py_INCREF(Py_None);
     1908    _res = Py_None;
     1909    return _res;
    19101910}
    19111911
    19121912static PyObject *FSRef_FSNewAliasMinimal(FSRefObject *_self, PyObject *_args)
    19131913{
    1914         PyObject *_res = NULL;
    1915         OSErr _err;
    1916         AliasHandle inAlias;
    1917         if (!PyArg_ParseTuple(_args, ""))
    1918                 return NULL;
    1919         _err = FSNewAliasMinimal(&_self->ob_itself,
    1920                                  &inAlias);
    1921         if (_err != noErr) return PyMac_Error(_err);
    1922         _res = Py_BuildValue("O&",
    1923                              Alias_New, inAlias);
    1924         return _res;
     1914    PyObject *_res = NULL;
     1915    OSErr _err;
     1916    AliasHandle inAlias;
     1917    if (!PyArg_ParseTuple(_args, ""))
     1918        return NULL;
     1919    _err = FSNewAliasMinimal(&_self->ob_itself,
     1920                             &inAlias);
     1921    if (_err != noErr) return PyMac_Error(_err);
     1922    _res = Py_BuildValue("O&",
     1923                         Alias_New, inAlias);
     1924    return _res;
    19251925}
    19261926
    19271927static PyObject *FSRef_FSIsAliasFile(FSRefObject *_self, PyObject *_args)
    19281928{
    1929         PyObject *_res = NULL;
    1930         OSErr _err;
    1931         Boolean aliasFileFlag;
    1932         Boolean folderFlag;
    1933         if (!PyArg_ParseTuple(_args, ""))
    1934                 return NULL;
    1935         _err = FSIsAliasFile(&_self->ob_itself,
    1936                              &aliasFileFlag,
    1937                              &folderFlag);
    1938         if (_err != noErr) return PyMac_Error(_err);
    1939         _res = Py_BuildValue("bb",
    1940                              aliasFileFlag,
    1941                              folderFlag);
    1942         return _res;
     1929    PyObject *_res = NULL;
     1930    OSErr _err;
     1931    Boolean aliasFileFlag;
     1932    Boolean folderFlag;
     1933    if (!PyArg_ParseTuple(_args, ""))
     1934        return NULL;
     1935    _err = FSIsAliasFile(&_self->ob_itself,
     1936                         &aliasFileFlag,
     1937                         &folderFlag);
     1938    if (_err != noErr) return PyMac_Error(_err);
     1939    _res = Py_BuildValue("bb",
     1940                         aliasFileFlag,
     1941                         folderFlag);
     1942    return _res;
    19431943}
    19441944
    19451945static PyObject *FSRef_FSRefMakePath(FSRefObject *_self, PyObject *_args)
    19461946{
    1947         PyObject *_res = NULL;
    1948 
    1949         OSStatus _err;
     1947    PyObject *_res = NULL;
     1948
     1949    OSStatus _err;
    19501950#define MAXPATHNAME 1024
    1951         UInt8 path[MAXPATHNAME];
    1952         UInt32 maxPathSize = MAXPATHNAME;
    1953 
    1954         if (!PyArg_ParseTuple(_args, ""))
    1955                 return NULL;
    1956         _err = FSRefMakePath(&_self->ob_itself,
    1957                                                  path,
    1958                                                  maxPathSize);
    1959         if (_err != noErr) return PyMac_Error(_err);
    1960         _res = Py_BuildValue("s", path);
    1961         return _res;
     1951    UInt8 path[MAXPATHNAME];
     1952    UInt32 maxPathSize = MAXPATHNAME;
     1953
     1954    if (!PyArg_ParseTuple(_args, ""))
     1955        return NULL;
     1956    _err = FSRefMakePath(&_self->ob_itself,
     1957                                             path,
     1958                                             maxPathSize);
     1959    if (_err != noErr) return PyMac_Error(_err);
     1960    _res = Py_BuildValue("s", path);
     1961    return _res;
    19621962
    19631963}
     
    19651965static PyObject *FSRef_as_pathname(FSRefObject *_self, PyObject *_args)
    19661966{
    1967         PyObject *_res = NULL;
    1968 
    1969         if (!PyArg_ParseTuple(_args, ""))
    1970                 return NULL;
    1971         _res = FSRef_FSRefMakePath(_self, _args);
    1972         return _res;
     1967    PyObject *_res = NULL;
     1968
     1969    if (!PyArg_ParseTuple(_args, ""))
     1970        return NULL;
     1971    _res = FSRef_FSRefMakePath(_self, _args);
     1972    return _res;
    19731973
    19741974}
    19751975
    19761976static PyMethodDef FSRef_methods[] = {
    1977         {"FSMakeFSRefUnicode", (PyCFunction)FSRef_FSMakeFSRefUnicode, 1,
    1978         PyDoc_STR("(Buffer nameLength, TextEncoding textEncodingHint) -> (FSRef newRef)")},
    1979         {"FSCompareFSRefs", (PyCFunction)FSRef_FSCompareFSRefs, 1,
    1980         PyDoc_STR("(FSRef ref2) -> None")},
    1981         {"FSCreateFileUnicode", (PyCFunction)FSRef_FSCreateFileUnicode, 1,
    1982         PyDoc_STR("(Buffer nameLength, FSCatalogInfoBitmap whichInfo, FSCatalogInfo catalogInfo) -> (FSRef newRef, FSSpec newSpec)")},
    1983         {"FSCreateDirectoryUnicode", (PyCFunction)FSRef_FSCreateDirectoryUnicode, 1,
    1984         PyDoc_STR("(Buffer nameLength, FSCatalogInfoBitmap whichInfo, FSCatalogInfo catalogInfo) -> (FSRef newRef, FSSpec newSpec, UInt32 newDirID)")},
    1985         {"FSDeleteObject", (PyCFunction)FSRef_FSDeleteObject, 1,
    1986         PyDoc_STR("() -> None")},
    1987         {"FSMoveObject", (PyCFunction)FSRef_FSMoveObject, 1,
    1988         PyDoc_STR("(FSRef destDirectory) -> (FSRef newRef)")},
    1989         {"FSExchangeObjects", (PyCFunction)FSRef_FSExchangeObjects, 1,
    1990         PyDoc_STR("(FSRef destRef) -> None")},
    1991         {"FSRenameUnicode", (PyCFunction)FSRef_FSRenameUnicode, 1,
    1992         PyDoc_STR("(Buffer nameLength, TextEncoding textEncodingHint) -> (FSRef newRef)")},
    1993         {"FSGetCatalogInfo", (PyCFunction)FSRef_FSGetCatalogInfo, 1,
    1994         PyDoc_STR("(FSCatalogInfoBitmap whichInfo) -> (FSCatalogInfo catalogInfo, HFSUniStr255 outName, FSSpec fsSpec, FSRef parentRef)")},
    1995         {"FSSetCatalogInfo", (PyCFunction)FSRef_FSSetCatalogInfo, 1,
    1996         PyDoc_STR("(FSCatalogInfoBitmap whichInfo, FSCatalogInfo catalogInfo) -> None")},
    1997         {"FSCreateFork", (PyCFunction)FSRef_FSCreateFork, 1,
    1998         PyDoc_STR("(Buffer forkNameLength) -> None")},
    1999         {"FSDeleteFork", (PyCFunction)FSRef_FSDeleteFork, 1,
    2000         PyDoc_STR("(Buffer forkNameLength) -> None")},
    2001         {"FSOpenFork", (PyCFunction)FSRef_FSOpenFork, 1,
    2002         PyDoc_STR("(Buffer forkNameLength, SInt8 permissions) -> (SInt16 forkRefNum)")},
    2003         {"FNNotify", (PyCFunction)FSRef_FNNotify, 1,
    2004         PyDoc_STR("(FNMessage message, OptionBits flags) -> None")},
    2005         {"FSNewAliasMinimal", (PyCFunction)FSRef_FSNewAliasMinimal, 1,
    2006         PyDoc_STR("() -> (AliasHandle inAlias)")},
    2007         {"FSIsAliasFile", (PyCFunction)FSRef_FSIsAliasFile, 1,
    2008         PyDoc_STR("() -> (Boolean aliasFileFlag, Boolean folderFlag)")},
    2009         {"FSRefMakePath", (PyCFunction)FSRef_FSRefMakePath, 1,
    2010         PyDoc_STR("() -> string")},
    2011         {"as_pathname", (PyCFunction)FSRef_as_pathname, 1,
    2012         PyDoc_STR("() -> string")},
    2013         {NULL, NULL, 0}
     1977    {"FSMakeFSRefUnicode", (PyCFunction)FSRef_FSMakeFSRefUnicode, 1,
     1978    PyDoc_STR("(Buffer nameLength, TextEncoding textEncodingHint) -> (FSRef newRef)")},
     1979    {"FSCompareFSRefs", (PyCFunction)FSRef_FSCompareFSRefs, 1,
     1980    PyDoc_STR("(FSRef ref2) -> None")},
     1981    {"FSCreateFileUnicode", (PyCFunction)FSRef_FSCreateFileUnicode, 1,
     1982    PyDoc_STR("(Buffer nameLength, FSCatalogInfoBitmap whichInfo, FSCatalogInfo catalogInfo) -> (FSRef newRef, FSSpec newSpec)")},
     1983    {"FSCreateDirectoryUnicode", (PyCFunction)FSRef_FSCreateDirectoryUnicode, 1,
     1984    PyDoc_STR("(Buffer nameLength, FSCatalogInfoBitmap whichInfo, FSCatalogInfo catalogInfo) -> (FSRef newRef, FSSpec newSpec, UInt32 newDirID)")},
     1985    {"FSDeleteObject", (PyCFunction)FSRef_FSDeleteObject, 1,
     1986    PyDoc_STR("() -> None")},
     1987    {"FSMoveObject", (PyCFunction)FSRef_FSMoveObject, 1,
     1988    PyDoc_STR("(FSRef destDirectory) -> (FSRef newRef)")},
     1989    {"FSExchangeObjects", (PyCFunction)FSRef_FSExchangeObjects, 1,
     1990    PyDoc_STR("(FSRef destRef) -> None")},
     1991    {"FSRenameUnicode", (PyCFunction)FSRef_FSRenameUnicode, 1,
     1992    PyDoc_STR("(Buffer nameLength, TextEncoding textEncodingHint) -> (FSRef newRef)")},
     1993    {"FSGetCatalogInfo", (PyCFunction)FSRef_FSGetCatalogInfo, 1,
     1994    PyDoc_STR("(FSCatalogInfoBitmap whichInfo) -> (FSCatalogInfo catalogInfo, HFSUniStr255 outName, FSSpec fsSpec, FSRef parentRef)")},
     1995    {"FSSetCatalogInfo", (PyCFunction)FSRef_FSSetCatalogInfo, 1,
     1996    PyDoc_STR("(FSCatalogInfoBitmap whichInfo, FSCatalogInfo catalogInfo) -> None")},
     1997    {"FSCreateFork", (PyCFunction)FSRef_FSCreateFork, 1,
     1998    PyDoc_STR("(Buffer forkNameLength) -> None")},
     1999    {"FSDeleteFork", (PyCFunction)FSRef_FSDeleteFork, 1,
     2000    PyDoc_STR("(Buffer forkNameLength) -> None")},
     2001    {"FSOpenFork", (PyCFunction)FSRef_FSOpenFork, 1,
     2002    PyDoc_STR("(Buffer forkNameLength, SInt8 permissions) -> (SInt16 forkRefNum)")},
     2003    {"FNNotify", (PyCFunction)FSRef_FNNotify, 1,
     2004    PyDoc_STR("(FNMessage message, OptionBits flags) -> None")},
     2005    {"FSNewAliasMinimal", (PyCFunction)FSRef_FSNewAliasMinimal, 1,
     2006    PyDoc_STR("() -> (AliasHandle inAlias)")},
     2007    {"FSIsAliasFile", (PyCFunction)FSRef_FSIsAliasFile, 1,
     2008    PyDoc_STR("() -> (Boolean aliasFileFlag, Boolean folderFlag)")},
     2009    {"FSRefMakePath", (PyCFunction)FSRef_FSRefMakePath, 1,
     2010    PyDoc_STR("() -> string")},
     2011    {"as_pathname", (PyCFunction)FSRef_as_pathname, 1,
     2012    PyDoc_STR("() -> string")},
     2013    {NULL, NULL, 0}
    20142014};
    20152015
    20162016static PyObject *FSRef_get_data(FSRefObject *self, void *closure)
    20172017{
    2018         return PyString_FromStringAndSize((char *)&self->ob_itself, sizeof(self->ob_itself));
     2018    return PyString_FromStringAndSize((char *)&self->ob_itself, sizeof(self->ob_itself));
    20192019}
    20202020
     
    20222022
    20232023static PyGetSetDef FSRef_getsetlist[] = {
    2024         {"data", (getter)FSRef_get_data, (setter)FSRef_set_data, "Raw data of the FSRef object"},
    2025         {NULL, NULL, NULL, NULL},
     2024    {"data", (getter)FSRef_get_data, (setter)FSRef_set_data, "Raw data of the FSRef object"},
     2025    {NULL, NULL, NULL, NULL},
    20262026};
    20272027
     
    20342034static int FSRef_tp_init(PyObject *_self, PyObject *_args, PyObject *_kwds)
    20352035{
    2036         PyObject *v = NULL;
    2037         char *rawdata = NULL;
    2038         int rawdatalen = 0;
    2039         static char *kw[] = {"itself", "rawdata", 0};
    2040 
    2041         if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "|Os#", kw, &v, &rawdata, &rawdatalen))
    2042         return -1;
    2043         if (v && rawdata)
    2044         {
    2045                 PyErr_SetString(PyExc_TypeError, "Only one of itself or rawdata may be specified");
    2046                 return -1;
    2047         }
    2048         if (!v && !rawdata)
    2049         {
    2050                 PyErr_SetString(PyExc_TypeError, "One of itself or rawdata must be specified");
    2051                 return -1;
    2052         }
    2053         if (rawdata)
    2054         {
    2055                 if (rawdatalen != sizeof(FSRef))
    2056                 {
    2057                         PyErr_SetString(PyExc_TypeError, "FSRef rawdata incorrect size");
    2058                         return -1;
    2059                 }
    2060                 memcpy(&((FSRefObject *)_self)->ob_itself, rawdata, rawdatalen);
    2061                 return 0;
    2062         }
    2063         if (PyMac_GetFSRef(v, &((FSRefObject *)_self)->ob_itself)) return 0;
    2064         return -1;
     2036    PyObject *v = NULL;
     2037    char *rawdata = NULL;
     2038    int rawdatalen = 0;
     2039    static char *kw[] = {"itself", "rawdata", 0};
     2040
     2041    if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "|Os#", kw, &v, &rawdata, &rawdatalen))
     2042    return -1;
     2043    if (v && rawdata)
     2044    {
     2045        PyErr_SetString(PyExc_TypeError, "Only one of itself or rawdata may be specified");
     2046        return -1;
     2047    }
     2048    if (!v && !rawdata)
     2049    {
     2050        PyErr_SetString(PyExc_TypeError, "One of itself or rawdata must be specified");
     2051        return -1;
     2052    }
     2053    if (rawdata)
     2054    {
     2055        if (rawdatalen != sizeof(FSRef))
     2056        {
     2057            PyErr_SetString(PyExc_TypeError, "FSRef rawdata incorrect size");
     2058            return -1;
     2059        }
     2060        memcpy(&((FSRefObject *)_self)->ob_itself, rawdata, rawdatalen);
     2061        return 0;
     2062    }
     2063    if (PyMac_GetFSRef(v, &((FSRefObject *)_self)->ob_itself)) return 0;
     2064    return -1;
    20652065}
    20662066
     
    20692069static PyObject *FSRef_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds)
    20702070{
    2071         PyObject *self;
    2072 
    2073         if ((self = type->tp_alloc(type, 0)) == NULL) return NULL;
    2074         memset(&((FSRefObject *)self)->ob_itself, 0, sizeof(FSRef));
    2075         return self;
     2071    PyObject *self;
     2072
     2073    if ((self = type->tp_alloc(type, 0)) == NULL) return NULL;
     2074    memset(&((FSRefObject *)self)->ob_itself, 0, sizeof(FSRef));
     2075    return self;
    20762076}
    20772077
     
    20802080
    20812081static PyTypeObject FSRef_Type = {
    2082         PyObject_HEAD_INIT(NULL)
    2083         0, /*ob_size*/
    2084         "Carbon.File.FSRef", /*tp_name*/
    2085         sizeof(FSRefObject), /*tp_basicsize*/
    2086         0, /*tp_itemsize*/
    2087         /* methods */
    2088         (destructor) FSRef_dealloc, /*tp_dealloc*/
    2089         0, /*tp_print*/
    2090         (getattrfunc)0, /*tp_getattr*/
    2091         (setattrfunc)0, /*tp_setattr*/
    2092         (cmpfunc) FSRef_compare, /*tp_compare*/
    2093         (reprfunc) FSRef_repr, /*tp_repr*/
    2094         (PyNumberMethods *)0, /* tp_as_number */
    2095         (PySequenceMethods *)0, /* tp_as_sequence */
    2096         (PyMappingMethods *)0, /* tp_as_mapping */
    2097         (hashfunc) FSRef_hash, /*tp_hash*/
    2098         0, /*tp_call*/
    2099         0, /*tp_str*/
    2100         PyObject_GenericGetAttr, /*tp_getattro*/
    2101         PyObject_GenericSetAttr, /*tp_setattro */
    2102         0, /*tp_as_buffer*/
    2103         Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */
    2104         0, /*tp_doc*/
    2105         0, /*tp_traverse*/
    2106         0, /*tp_clear*/
    2107         0, /*tp_richcompare*/
    2108         0, /*tp_weaklistoffset*/
    2109         0, /*tp_iter*/
    2110         0, /*tp_iternext*/
    2111         FSRef_methods, /* tp_methods */
    2112         0, /*tp_members*/
    2113         FSRef_getsetlist, /*tp_getset*/
    2114         0, /*tp_base*/
    2115         0, /*tp_dict*/
    2116         0, /*tp_descr_get*/
    2117         0, /*tp_descr_set*/
    2118         0, /*tp_dictoffset*/
    2119         FSRef_tp_init, /* tp_init */
    2120         FSRef_tp_alloc, /* tp_alloc */
    2121         FSRef_tp_new, /* tp_new */
    2122         FSRef_tp_free, /* tp_free */
     2082    PyObject_HEAD_INIT(NULL)
     2083    0, /*ob_size*/
     2084    "Carbon.File.FSRef", /*tp_name*/
     2085    sizeof(FSRefObject), /*tp_basicsize*/
     2086    0, /*tp_itemsize*/
     2087    /* methods */
     2088    (destructor) FSRef_dealloc, /*tp_dealloc*/
     2089    0, /*tp_print*/
     2090    (getattrfunc)0, /*tp_getattr*/
     2091    (setattrfunc)0, /*tp_setattr*/
     2092    (cmpfunc) FSRef_compare, /*tp_compare*/
     2093    (reprfunc) FSRef_repr, /*tp_repr*/
     2094    (PyNumberMethods *)0, /* tp_as_number */
     2095    (PySequenceMethods *)0, /* tp_as_sequence */
     2096    (PyMappingMethods *)0, /* tp_as_mapping */
     2097    (hashfunc) FSRef_hash, /*tp_hash*/
     2098    0, /*tp_call*/
     2099    0, /*tp_str*/
     2100    PyObject_GenericGetAttr, /*tp_getattro*/
     2101    PyObject_GenericSetAttr, /*tp_setattro */
     2102    0, /*tp_as_buffer*/
     2103    Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */
     2104    0, /*tp_doc*/
     2105    0, /*tp_traverse*/
     2106    0, /*tp_clear*/
     2107    0, /*tp_richcompare*/
     2108    0, /*tp_weaklistoffset*/
     2109    0, /*tp_iter*/
     2110    0, /*tp_iternext*/
     2111    FSRef_methods, /* tp_methods */
     2112    0, /*tp_members*/
     2113    FSRef_getsetlist, /*tp_getset*/
     2114    0, /*tp_base*/
     2115    0, /*tp_dict*/
     2116    0, /*tp_descr_get*/
     2117    0, /*tp_descr_set*/
     2118    0, /*tp_dictoffset*/
     2119    FSRef_tp_init, /* tp_init */
     2120    FSRef_tp_alloc, /* tp_alloc */
     2121    FSRef_tp_new, /* tp_new */
     2122    FSRef_tp_free, /* tp_free */
    21232123};
    21242124
     
    21282128static PyObject *File_UnmountVol(PyObject *_self, PyObject *_args)
    21292129{
    2130         PyObject *_res = NULL;
    2131         OSErr _err;
    2132         Str63 volName;
    2133         short vRefNum;
    2134         if (!PyArg_ParseTuple(_args, "O&h",
    2135                               PyMac_GetStr255, volName,
    2136                               &vRefNum))
    2137                 return NULL;
    2138         _err = UnmountVol(volName,
    2139                           vRefNum);
    2140         if (_err != noErr) return PyMac_Error(_err);
    2141         Py_INCREF(Py_None);
    2142         _res = Py_None;
    2143         return _res;
     2130    PyObject *_res = NULL;
     2131    OSErr _err;
     2132    Str63 volName;
     2133    short vRefNum;
     2134    if (!PyArg_ParseTuple(_args, "O&h",
     2135                          PyMac_GetStr255, volName,
     2136                          &vRefNum))
     2137        return NULL;
     2138    _err = UnmountVol(volName,
     2139                      vRefNum);
     2140    if (_err != noErr) return PyMac_Error(_err);
     2141    Py_INCREF(Py_None);
     2142    _res = Py_None;
     2143    return _res;
    21442144}
    21452145
    21462146static PyObject *File_FlushVol(PyObject *_self, PyObject *_args)
    21472147{
    2148         PyObject *_res = NULL;
    2149         OSErr _err;
    2150         Str63 volName;
    2151         short vRefNum;
    2152         if (!PyArg_ParseTuple(_args, "O&h",
    2153                               PyMac_GetStr255, volName,
    2154                               &vRefNum))
    2155                 return NULL;
    2156         _err = FlushVol(volName,
    2157                         vRefNum);
    2158         if (_err != noErr) return PyMac_Error(_err);
    2159         Py_INCREF(Py_None);
    2160         _res = Py_None;
    2161         return _res;
     2148    PyObject *_res = NULL;
     2149    OSErr _err;
     2150    Str63 volName;
     2151    short vRefNum;
     2152    if (!PyArg_ParseTuple(_args, "O&h",
     2153                          PyMac_GetStr255, volName,
     2154                          &vRefNum))
     2155        return NULL;
     2156    _err = FlushVol(volName,
     2157                    vRefNum);
     2158    if (_err != noErr) return PyMac_Error(_err);
     2159    Py_INCREF(Py_None);
     2160    _res = Py_None;
     2161    return _res;
    21622162}
    21632163
    21642164static PyObject *File_HSetVol(PyObject *_self, PyObject *_args)
    21652165{
    2166         PyObject *_res = NULL;
    2167         OSErr _err;
    2168         Str63 volName;
    2169         short vRefNum;
    2170         long dirID;
    2171         if (!PyArg_ParseTuple(_args, "O&hl",
    2172                               PyMac_GetStr255, volName,
    2173                               &vRefNum,
    2174                               &dirID))
    2175                 return NULL;
    2176         _err = HSetVol(volName,
    2177                        vRefNum,
    2178                        dirID);
    2179         if (_err != noErr) return PyMac_Error(_err);
    2180         Py_INCREF(Py_None);
    2181         _res = Py_None;
    2182         return _res;
     2166    PyObject *_res = NULL;
     2167    OSErr _err;
     2168    Str63 volName;
     2169    short vRefNum;
     2170    long dirID;
     2171    if (!PyArg_ParseTuple(_args, "O&hl",
     2172                          PyMac_GetStr255, volName,
     2173                          &vRefNum,
     2174                          &dirID))
     2175        return NULL;
     2176    _err = HSetVol(volName,
     2177                   vRefNum,
     2178                   dirID);
     2179    if (_err != noErr) return PyMac_Error(_err);
     2180    Py_INCREF(Py_None);
     2181    _res = Py_None;
     2182    return _res;
    21832183}
    21842184
    21852185static PyObject *File_FSClose(PyObject *_self, PyObject *_args)
    21862186{
    2187         PyObject *_res = NULL;
    2188         OSErr _err;
    2189         short refNum;
    2190         if (!PyArg_ParseTuple(_args, "h",
    2191                               &refNum))
    2192                 return NULL;
    2193         _err = FSClose(refNum);
    2194         if (_err != noErr) return PyMac_Error(_err);
    2195         Py_INCREF(Py_None);
    2196         _res = Py_None;
    2197         return _res;
     2187    PyObject *_res = NULL;
     2188    OSErr _err;
     2189    short refNum;
     2190    if (!PyArg_ParseTuple(_args, "h",
     2191                          &refNum))
     2192        return NULL;
     2193    _err = FSClose(refNum);
     2194    if (_err != noErr) return PyMac_Error(_err);
     2195    Py_INCREF(Py_None);
     2196    _res = Py_None;
     2197    return _res;
    21982198}
    21992199
    22002200static PyObject *File_Allocate(PyObject *_self, PyObject *_args)
    22012201{
    2202         PyObject *_res = NULL;
    2203         OSErr _err;
    2204         short refNum;
    2205         long count;
    2206         if (!PyArg_ParseTuple(_args, "h",
    2207                               &refNum))
    2208                 return NULL;
    2209         _err = Allocate(refNum,
    2210                         &count);
    2211         if (_err != noErr) return PyMac_Error(_err);
    2212         _res = Py_BuildValue("l",
    2213                              count);
    2214         return _res;
     2202    PyObject *_res = NULL;
     2203    OSErr _err;
     2204    short refNum;
     2205    long count;
     2206    if (!PyArg_ParseTuple(_args, "h",
     2207                          &refNum))
     2208        return NULL;
     2209    _err = Allocate(refNum,
     2210                    &count);
     2211    if (_err != noErr) return PyMac_Error(_err);
     2212    _res = Py_BuildValue("l",
     2213                         count);
     2214    return _res;
    22152215}
    22162216
    22172217static PyObject *File_GetEOF(PyObject *_self, PyObject *_args)
    22182218{
    2219         PyObject *_res = NULL;
    2220         OSErr _err;
    2221         short refNum;
    2222         long logEOF;
    2223         if (!PyArg_ParseTuple(_args, "h",
    2224                               &refNum))
    2225                 return NULL;
    2226         _err = GetEOF(refNum,
    2227                       &logEOF);
    2228         if (_err != noErr) return PyMac_Error(_err);
    2229         _res = Py_BuildValue("l",
    2230                              logEOF);
    2231         return _res;
     2219    PyObject *_res = NULL;
     2220    OSErr _err;
     2221    short refNum;
     2222    long logEOF;
     2223    if (!PyArg_ParseTuple(_args, "h",
     2224                          &refNum))
     2225        return NULL;
     2226    _err = GetEOF(refNum,
     2227                  &logEOF);
     2228    if (_err != noErr) return PyMac_Error(_err);
     2229    _res = Py_BuildValue("l",
     2230                         logEOF);
     2231    return _res;
    22322232}
    22332233
    22342234static PyObject *File_SetEOF(PyObject *_self, PyObject *_args)
    22352235{
    2236         PyObject *_res = NULL;
    2237         OSErr _err;
    2238         short refNum;
    2239         long logEOF;
    2240         if (!PyArg_ParseTuple(_args, "hl",
    2241                               &refNum,
    2242                               &logEOF))
    2243                 return NULL;
    2244         _err = SetEOF(refNum,
    2245                       logEOF);
    2246         if (_err != noErr) return PyMac_Error(_err);
    2247         Py_INCREF(Py_None);
    2248         _res = Py_None;
    2249         return _res;
     2236    PyObject *_res = NULL;
     2237    OSErr _err;
     2238    short refNum;
     2239    long logEOF;
     2240    if (!PyArg_ParseTuple(_args, "hl",
     2241                          &refNum,
     2242                          &logEOF))
     2243        return NULL;
     2244    _err = SetEOF(refNum,
     2245                  logEOF);
     2246    if (_err != noErr) return PyMac_Error(_err);
     2247    Py_INCREF(Py_None);
     2248    _res = Py_None;
     2249    return _res;
    22502250}
    22512251
    22522252static PyObject *File_GetFPos(PyObject *_self, PyObject *_args)
    22532253{
    2254         PyObject *_res = NULL;
    2255         OSErr _err;
    2256         short refNum;
    2257         long filePos;
    2258         if (!PyArg_ParseTuple(_args, "h",
    2259                               &refNum))
    2260                 return NULL;
    2261         _err = GetFPos(refNum,
    2262                        &filePos);
    2263         if (_err != noErr) return PyMac_Error(_err);
    2264         _res = Py_BuildValue("l",
    2265                              filePos);
    2266         return _res;
     2254    PyObject *_res = NULL;
     2255    OSErr _err;
     2256    short refNum;
     2257    long filePos;
     2258    if (!PyArg_ParseTuple(_args, "h",
     2259                          &refNum))
     2260        return NULL;
     2261    _err = GetFPos(refNum,
     2262                   &filePos);
     2263    if (_err != noErr) return PyMac_Error(_err);
     2264    _res = Py_BuildValue("l",
     2265                         filePos);
     2266    return _res;
    22672267}
    22682268
    22692269static PyObject *File_SetFPos(PyObject *_self, PyObject *_args)
    22702270{
    2271         PyObject *_res = NULL;
    2272         OSErr _err;
    2273         short refNum;
    2274         short posMode;
    2275         long posOff;
    2276         if (!PyArg_ParseTuple(_args, "hhl",
    2277                               &refNum,
    2278                               &posMode,
    2279                               &posOff))
    2280                 return NULL;
    2281         _err = SetFPos(refNum,
    2282                        posMode,
    2283                        posOff);
    2284         if (_err != noErr) return PyMac_Error(_err);
    2285         Py_INCREF(Py_None);
    2286         _res = Py_None;
    2287         return _res;
     2271    PyObject *_res = NULL;
     2272    OSErr _err;
     2273    short refNum;
     2274    short posMode;
     2275    long posOff;
     2276    if (!PyArg_ParseTuple(_args, "hhl",
     2277                          &refNum,
     2278                          &posMode,
     2279                          &posOff))
     2280        return NULL;
     2281    _err = SetFPos(refNum,
     2282                   posMode,
     2283                   posOff);
     2284    if (_err != noErr) return PyMac_Error(_err);
     2285    Py_INCREF(Py_None);
     2286    _res = Py_None;
     2287    return _res;
    22882288}
    22892289
    22902290static PyObject *File_GetVRefNum(PyObject *_self, PyObject *_args)
    22912291{
    2292         PyObject *_res = NULL;
    2293         OSErr _err;
    2294         short fileRefNum;
    2295         short vRefNum;
    2296         if (!PyArg_ParseTuple(_args, "h",
    2297                               &fileRefNum))
    2298                 return NULL;
    2299         _err = GetVRefNum(fileRefNum,
    2300                           &vRefNum);
    2301         if (_err != noErr) return PyMac_Error(_err);
    2302         _res = Py_BuildValue("h",
    2303                              vRefNum);
    2304         return _res;
     2292    PyObject *_res = NULL;
     2293    OSErr _err;
     2294    short fileRefNum;
     2295    short vRefNum;
     2296    if (!PyArg_ParseTuple(_args, "h",
     2297                          &fileRefNum))
     2298        return NULL;
     2299    _err = GetVRefNum(fileRefNum,
     2300                      &vRefNum);
     2301    if (_err != noErr) return PyMac_Error(_err);
     2302    _res = Py_BuildValue("h",
     2303                         vRefNum);
     2304    return _res;
    23052305}
    23062306
    23072307static PyObject *File_HGetVol(PyObject *_self, PyObject *_args)
    23082308{
    2309         PyObject *_res = NULL;
    2310         OSErr _err;
    2311         StringPtr volName;
    2312         short vRefNum;
    2313         long dirID;
    2314         if (!PyArg_ParseTuple(_args, "O&",
    2315                               PyMac_GetStr255, &volName))
    2316                 return NULL;
    2317         _err = HGetVol(volName,
    2318                        &vRefNum,
    2319                        &dirID);
    2320         if (_err != noErr) return PyMac_Error(_err);
    2321         _res = Py_BuildValue("hl",
    2322                              vRefNum,
    2323                              dirID);
    2324         return _res;
     2309    PyObject *_res = NULL;
     2310    OSErr _err;
     2311    StringPtr volName;
     2312    short vRefNum;
     2313    long dirID;
     2314    if (!PyArg_ParseTuple(_args, "O&",
     2315                          PyMac_GetStr255, &volName))
     2316        return NULL;
     2317    _err = HGetVol(volName,
     2318                   &vRefNum,
     2319                   &dirID);
     2320    if (_err != noErr) return PyMac_Error(_err);
     2321    _res = Py_BuildValue("hl",
     2322                         vRefNum,
     2323                         dirID);
     2324    return _res;
    23252325}
    23262326
    23272327static PyObject *File_HOpen(PyObject *_self, PyObject *_args)
    23282328{
    2329         PyObject *_res = NULL;
    2330         OSErr _err;
    2331         short vRefNum;
    2332         long dirID;
    2333         Str255 fileName;
    2334         SInt8 permission;
    2335         short refNum;
    2336         if (!PyArg_ParseTuple(_args, "hlO&b",
    2337                               &vRefNum,
    2338                               &dirID,
    2339                               PyMac_GetStr255, fileName,
    2340                               &permission))
    2341                 return NULL;
    2342         _err = HOpen(vRefNum,
    2343                      dirID,
    2344                      fileName,
    2345                      permission,
    2346                      &refNum);
    2347         if (_err != noErr) return PyMac_Error(_err);
    2348         _res = Py_BuildValue("h",
    2349                              refNum);
    2350         return _res;
     2329    PyObject *_res = NULL;
     2330    OSErr _err;
     2331    short vRefNum;
     2332    long dirID;
     2333    Str255 fileName;
     2334    SInt8 permission;
     2335    short refNum;
     2336    if (!PyArg_ParseTuple(_args, "hlO&b",
     2337                          &vRefNum,
     2338                          &dirID,
     2339                          PyMac_GetStr255, fileName,
     2340                          &permission))
     2341        return NULL;
     2342    _err = HOpen(vRefNum,
     2343                 dirID,
     2344                 fileName,
     2345                 permission,
     2346                 &refNum);
     2347    if (_err != noErr) return PyMac_Error(_err);
     2348    _res = Py_BuildValue("h",
     2349                         refNum);
     2350    return _res;
    23512351}
    23522352
    23532353static PyObject *File_HOpenDF(PyObject *_self, PyObject *_args)
    23542354{
    2355         PyObject *_res = NULL;
    2356         OSErr _err;
    2357         short vRefNum;
    2358         long dirID;
    2359         Str255 fileName;
    2360         SInt8 permission;
    2361         short refNum;
    2362         if (!PyArg_ParseTuple(_args, "hlO&b",
    2363                               &vRefNum,
    2364                               &dirID,
    2365                               PyMac_GetStr255, fileName,
    2366                               &permission))
    2367                 return NULL;
    2368         _err = HOpenDF(vRefNum,
    2369                        dirID,
    2370                        fileName,
    2371                        permission,
    2372                        &refNum);
    2373         if (_err != noErr) return PyMac_Error(_err);
    2374         _res = Py_BuildValue("h",
    2375                              refNum);
    2376         return _res;
     2355    PyObject *_res = NULL;
     2356    OSErr _err;
     2357    short vRefNum;
     2358    long dirID;
     2359    Str255 fileName;
     2360    SInt8 permission;
     2361    short refNum;
     2362    if (!PyArg_ParseTuple(_args, "hlO&b",
     2363                          &vRefNum,
     2364                          &dirID,
     2365                          PyMac_GetStr255, fileName,
     2366                          &permission))
     2367        return NULL;
     2368    _err = HOpenDF(vRefNum,
     2369                   dirID,
     2370                   fileName,
     2371                   permission,
     2372                   &refNum);
     2373    if (_err != noErr) return PyMac_Error(_err);
     2374    _res = Py_BuildValue("h",
     2375                         refNum);
     2376    return _res;
    23772377}
    23782378
    23792379static PyObject *File_HOpenRF(PyObject *_self, PyObject *_args)
    23802380{
    2381         PyObject *_res = NULL;
    2382         OSErr _err;
    2383         short vRefNum;
    2384         long dirID;
    2385         Str255 fileName;
    2386         SInt8 permission;
    2387         short refNum;
    2388         if (!PyArg_ParseTuple(_args, "hlO&b",
    2389                               &vRefNum,
    2390                               &dirID,
    2391                               PyMac_GetStr255, fileName,
    2392                               &permission))
    2393                 return NULL;
    2394         _err = HOpenRF(vRefNum,
    2395                        dirID,
    2396                        fileName,
    2397                        permission,
    2398                        &refNum);
    2399         if (_err != noErr) return PyMac_Error(_err);
    2400         _res = Py_BuildValue("h",
    2401                              refNum);
    2402         return _res;
     2381    PyObject *_res = NULL;
     2382    OSErr _err;
     2383    short vRefNum;
     2384    long dirID;
     2385    Str255 fileName;
     2386    SInt8 permission;
     2387    short refNum;
     2388    if (!PyArg_ParseTuple(_args, "hlO&b",
     2389                          &vRefNum,
     2390                          &dirID,
     2391                          PyMac_GetStr255, fileName,
     2392                          &permission))
     2393        return NULL;
     2394    _err = HOpenRF(vRefNum,
     2395                   dirID,
     2396                   fileName,
     2397                   permission,
     2398                   &refNum);
     2399    if (_err != noErr) return PyMac_Error(_err);
     2400    _res = Py_BuildValue("h",
     2401                         refNum);
     2402    return _res;
    24032403}
    24042404
    24052405static PyObject *File_AllocContig(PyObject *_self, PyObject *_args)
    24062406{
    2407         PyObject *_res = NULL;
    2408         OSErr _err;
    2409         short refNum;
    2410         long count;
    2411         if (!PyArg_ParseTuple(_args, "h",
    2412                               &refNum))
    2413                 return NULL;
    2414         _err = AllocContig(refNum,
    2415                            &count);
    2416         if (_err != noErr) return PyMac_Error(_err);
    2417         _res = Py_BuildValue("l",
    2418                              count);
    2419         return _res;
     2407    PyObject *_res = NULL;
     2408    OSErr _err;
     2409    short refNum;
     2410    long count;
     2411    if (!PyArg_ParseTuple(_args, "h",
     2412                          &refNum))
     2413        return NULL;
     2414    _err = AllocContig(refNum,
     2415                       &count);
     2416    if (_err != noErr) return PyMac_Error(_err);
     2417    _res = Py_BuildValue("l",
     2418                         count);
     2419    return _res;
    24202420}
    24212421
    24222422static PyObject *File_HCreate(PyObject *_self, PyObject *_args)
    24232423{
    2424         PyObject *_res = NULL;
    2425         OSErr _err;
    2426         short vRefNum;
    2427         long dirID;
    2428         Str255 fileName;
    2429         OSType creator;
    2430         OSType fileType;
    2431         if (!PyArg_ParseTuple(_args, "hlO&O&O&",
    2432                               &vRefNum,
    2433                               &dirID,
    2434                               PyMac_GetStr255, fileName,
    2435                               PyMac_GetOSType, &creator,
    2436                               PyMac_GetOSType, &fileType))
    2437                 return NULL;
    2438         _err = HCreate(vRefNum,
    2439                        dirID,
    2440                        fileName,
    2441                        creator,
    2442                        fileType);
    2443         if (_err != noErr) return PyMac_Error(_err);
    2444         Py_INCREF(Py_None);
    2445         _res = Py_None;
    2446         return _res;
     2424    PyObject *_res = NULL;
     2425    OSErr _err;
     2426    short vRefNum;
     2427    long dirID;
     2428    Str255 fileName;
     2429    OSType creator;
     2430    OSType fileType;
     2431    if (!PyArg_ParseTuple(_args, "hlO&O&O&",
     2432                          &vRefNum,
     2433                          &dirID,
     2434                          PyMac_GetStr255, fileName,
     2435                          PyMac_GetOSType, &creator,
     2436                          PyMac_GetOSType, &fileType))
     2437        return NULL;
     2438    _err = HCreate(vRefNum,
     2439                   dirID,
     2440                   fileName,
     2441                   creator,
     2442                   fileType);
     2443    if (_err != noErr) return PyMac_Error(_err);
     2444    Py_INCREF(Py_None);
     2445    _res = Py_None;
     2446    return _res;
    24472447}
    24482448
    24492449static PyObject *File_DirCreate(PyObject *_self, PyObject *_args)
    24502450{
    2451         PyObject *_res = NULL;
    2452         OSErr _err;
    2453         short vRefNum;
    2454         long parentDirID;
    2455         Str255 directoryName;
    2456         long createdDirID;
    2457         if (!PyArg_ParseTuple(_args, "hlO&",
    2458                               &vRefNum,
    2459                               &parentDirID,
    2460                               PyMac_GetStr255, directoryName))
    2461                 return NULL;
    2462         _err = DirCreate(vRefNum,
    2463                          parentDirID,
    2464                          directoryName,
    2465                          &createdDirID);
    2466         if (_err != noErr) return PyMac_Error(_err);
    2467         _res = Py_BuildValue("l",
    2468                              createdDirID);
    2469         return _res;
     2451    PyObject *_res = NULL;
     2452    OSErr _err;
     2453    short vRefNum;
     2454    long parentDirID;
     2455    Str255 directoryName;
     2456    long createdDirID;
     2457    if (!PyArg_ParseTuple(_args, "hlO&",
     2458                          &vRefNum,
     2459                          &parentDirID,
     2460                          PyMac_GetStr255, directoryName))
     2461        return NULL;
     2462    _err = DirCreate(vRefNum,
     2463                     parentDirID,
     2464                     directoryName,
     2465                     &createdDirID);
     2466    if (_err != noErr) return PyMac_Error(_err);
     2467    _res = Py_BuildValue("l",
     2468                         createdDirID);
     2469    return _res;
    24702470}
    24712471
    24722472static PyObject *File_HDelete(PyObject *_self, PyObject *_args)
    24732473{
    2474         PyObject *_res = NULL;
    2475         OSErr _err;
    2476         short vRefNum;
    2477         long dirID;
    2478         Str255 fileName;
    2479         if (!PyArg_ParseTuple(_args, "hlO&",
    2480                               &vRefNum,
    2481                               &dirID,
    2482                               PyMac_GetStr255, fileName))
    2483                 return NULL;
    2484         _err = HDelete(vRefNum,
    2485                        dirID,
    2486                        fileName);
    2487         if (_err != noErr) return PyMac_Error(_err);
    2488         Py_INCREF(Py_None);
    2489         _res = Py_None;
    2490         return _res;
     2474    PyObject *_res = NULL;
     2475    OSErr _err;
     2476    short vRefNum;
     2477    long dirID;
     2478    Str255 fileName;
     2479    if (!PyArg_ParseTuple(_args, "hlO&",
     2480                          &vRefNum,
     2481                          &dirID,
     2482                          PyMac_GetStr255, fileName))
     2483        return NULL;
     2484    _err = HDelete(vRefNum,
     2485                   dirID,
     2486                   fileName);
     2487    if (_err != noErr) return PyMac_Error(_err);
     2488    Py_INCREF(Py_None);
     2489    _res = Py_None;
     2490    return _res;
    24912491}
    24922492
    24932493static PyObject *File_HGetFInfo(PyObject *_self, PyObject *_args)
    24942494{
    2495         PyObject *_res = NULL;
    2496         OSErr _err;
    2497         short vRefNum;
    2498         long dirID;
    2499         Str255 fileName;
    2500         FInfo fndrInfo;
    2501         if (!PyArg_ParseTuple(_args, "hlO&",
    2502                               &vRefNum,
    2503                               &dirID,
    2504                               PyMac_GetStr255, fileName))
    2505                 return NULL;
    2506         _err = HGetFInfo(vRefNum,
    2507                          dirID,
    2508                          fileName,
    2509                          &fndrInfo);
    2510         if (_err != noErr) return PyMac_Error(_err);
    2511         _res = Py_BuildValue("O&",
    2512                              FInfo_New, &fndrInfo);
    2513         return _res;
     2495    PyObject *_res = NULL;
     2496    OSErr _err;
     2497    short vRefNum;
     2498    long dirID;
     2499    Str255 fileName;
     2500    FInfo fndrInfo;
     2501    if (!PyArg_ParseTuple(_args, "hlO&",
     2502                          &vRefNum,
     2503                          &dirID,
     2504                          PyMac_GetStr255, fileName))
     2505        return NULL;
     2506    _err = HGetFInfo(vRefNum,
     2507                     dirID,
     2508                     fileName,
     2509                     &fndrInfo);
     2510    if (_err != noErr) return PyMac_Error(_err);
     2511    _res = Py_BuildValue("O&",
     2512                         FInfo_New, &fndrInfo);
     2513    return _res;
    25142514}
    25152515
    25162516static PyObject *File_HSetFInfo(PyObject *_self, PyObject *_args)
    25172517{
    2518         PyObject *_res = NULL;
    2519         OSErr _err;
    2520         short vRefNum;
    2521         long dirID;
    2522         Str255 fileName;
    2523         FInfo fndrInfo;
    2524         if (!PyArg_ParseTuple(_args, "hlO&O&",
    2525                               &vRefNum,
    2526                               &dirID,
    2527                               PyMac_GetStr255, fileName,
    2528                               FInfo_Convert, &fndrInfo))
    2529                 return NULL;
    2530         _err = HSetFInfo(vRefNum,
    2531                          dirID,
    2532                          fileName,
    2533                          &fndrInfo);
    2534         if (_err != noErr) return PyMac_Error(_err);
    2535         Py_INCREF(Py_None);
    2536         _res = Py_None;
    2537         return _res;
     2518    PyObject *_res = NULL;
     2519    OSErr _err;
     2520    short vRefNum;
     2521    long dirID;
     2522    Str255 fileName;
     2523    FInfo fndrInfo;
     2524    if (!PyArg_ParseTuple(_args, "hlO&O&",
     2525                          &vRefNum,
     2526                          &dirID,
     2527                          PyMac_GetStr255, fileName,
     2528                          FInfo_Convert, &fndrInfo))
     2529        return NULL;
     2530    _err = HSetFInfo(vRefNum,
     2531                     dirID,
     2532                     fileName,
     2533                     &fndrInfo);
     2534    if (_err != noErr) return PyMac_Error(_err);
     2535    Py_INCREF(Py_None);
     2536    _res = Py_None;
     2537    return _res;
    25382538}
    25392539
    25402540static PyObject *File_HSetFLock(PyObject *_self, PyObject *_args)
    25412541{
    2542         PyObject *_res = NULL;
    2543         OSErr _err;
    2544         short vRefNum;
    2545         long dirID;
    2546         Str255 fileName;
    2547         if (!PyArg_ParseTuple(_args, "hlO&",
    2548                               &vRefNum,
    2549                               &dirID,
    2550                               PyMac_GetStr255, fileName))
    2551                 return NULL;
    2552         _err = HSetFLock(vRefNum,
    2553                          dirID,
    2554                          fileName);
    2555         if (_err != noErr) return PyMac_Error(_err);
    2556         Py_INCREF(Py_None);
    2557         _res = Py_None;
    2558         return _res;
     2542    PyObject *_res = NULL;
     2543    OSErr _err;
     2544    short vRefNum;
     2545    long dirID;
     2546    Str255 fileName;
     2547    if (!PyArg_ParseTuple(_args, "hlO&",
     2548                          &vRefNum,
     2549                          &dirID,
     2550                          PyMac_GetStr255, fileName))
     2551        return NULL;
     2552    _err = HSetFLock(vRefNum,
     2553                     dirID,
     2554                     fileName);
     2555    if (_err != noErr) return PyMac_Error(_err);
     2556    Py_INCREF(Py_None);
     2557    _res = Py_None;
     2558    return _res;
    25592559}
    25602560
    25612561static PyObject *File_HRstFLock(PyObject *_self, PyObject *_args)
    25622562{
    2563         PyObject *_res = NULL;
    2564         OSErr _err;
    2565         short vRefNum;
    2566         long dirID;
    2567         Str255 fileName;
    2568         if (!PyArg_ParseTuple(_args, "hlO&",
    2569                               &vRefNum,
    2570                               &dirID,
    2571                               PyMac_GetStr255, fileName))
    2572                 return NULL;
    2573         _err = HRstFLock(vRefNum,
    2574                          dirID,
    2575                          fileName);
    2576         if (_err != noErr) return PyMac_Error(_err);
    2577         Py_INCREF(Py_None);
    2578         _res = Py_None;
    2579         return _res;
     2563    PyObject *_res = NULL;
     2564    OSErr _err;
     2565    short vRefNum;
     2566    long dirID;
     2567    Str255 fileName;
     2568    if (!PyArg_ParseTuple(_args, "hlO&",
     2569                          &vRefNum,
     2570                          &dirID,
     2571                          PyMac_GetStr255, fileName))
     2572        return NULL;
     2573    _err = HRstFLock(vRefNum,
     2574                     dirID,
     2575                     fileName);
     2576    if (_err != noErr) return PyMac_Error(_err);
     2577    Py_INCREF(Py_None);
     2578    _res = Py_None;
     2579    return _res;
    25802580}
    25812581
    25822582static PyObject *File_HRename(PyObject *_self, PyObject *_args)
    25832583{
    2584         PyObject *_res = NULL;
    2585         OSErr _err;
    2586         short vRefNum;
    2587         long dirID;
    2588         Str255 oldName;
    2589         Str255 newName;
    2590         if (!PyArg_ParseTuple(_args, "hlO&O&",
    2591                               &vRefNum,
    2592                               &dirID,
    2593                               PyMac_GetStr255, oldName,
    2594                               PyMac_GetStr255, newName))
    2595                 return NULL;
    2596         _err = HRename(vRefNum,
    2597                        dirID,
    2598                        oldName,
    2599                        newName);
    2600         if (_err != noErr) return PyMac_Error(_err);
    2601         Py_INCREF(Py_None);
    2602         _res = Py_None;
    2603         return _res;
     2584    PyObject *_res = NULL;
     2585    OSErr _err;
     2586    short vRefNum;
     2587    long dirID;
     2588    Str255 oldName;
     2589    Str255 newName;
     2590    if (!PyArg_ParseTuple(_args, "hlO&O&",
     2591                          &vRefNum,
     2592                          &dirID,
     2593                          PyMac_GetStr255, oldName,
     2594                          PyMac_GetStr255, newName))
     2595        return NULL;
     2596    _err = HRename(vRefNum,
     2597                   dirID,
     2598                   oldName,
     2599                   newName);
     2600    if (_err != noErr) return PyMac_Error(_err);
     2601    Py_INCREF(Py_None);
     2602    _res = Py_None;
     2603    return _res;
    26042604}
    26052605
    26062606static PyObject *File_CatMove(PyObject *_self, PyObject *_args)
    26072607{
    2608         PyObject *_res = NULL;
    2609         OSErr _err;
    2610         short vRefNum;
    2611         long dirID;
    2612         Str255 oldName;
    2613         long newDirID;
    2614         Str255 newName;
    2615         if (!PyArg_ParseTuple(_args, "hlO&lO&",
    2616                               &vRefNum,
    2617                               &dirID,
    2618                               PyMac_GetStr255, oldName,
    2619                               &newDirID,
    2620                               PyMac_GetStr255, newName))
    2621                 return NULL;
    2622         _err = CatMove(vRefNum,
    2623                        dirID,
    2624                        oldName,
    2625                        newDirID,
    2626                        newName);
    2627         if (_err != noErr) return PyMac_Error(_err);
    2628         Py_INCREF(Py_None);
    2629         _res = Py_None;
    2630         return _res;
     2608    PyObject *_res = NULL;
     2609    OSErr _err;
     2610    short vRefNum;
     2611    long dirID;
     2612    Str255 oldName;
     2613    long newDirID;
     2614    Str255 newName;
     2615    if (!PyArg_ParseTuple(_args, "hlO&lO&",
     2616                          &vRefNum,
     2617                          &dirID,
     2618                          PyMac_GetStr255, oldName,
     2619                          &newDirID,
     2620                          PyMac_GetStr255, newName))
     2621        return NULL;
     2622    _err = CatMove(vRefNum,
     2623                   dirID,
     2624                   oldName,
     2625                   newDirID,
     2626                   newName);
     2627    if (_err != noErr) return PyMac_Error(_err);
     2628    Py_INCREF(Py_None);
     2629    _res = Py_None;
     2630    return _res;
    26312631}
    26322632
    26332633static PyObject *File_FSMakeFSSpec(PyObject *_self, PyObject *_args)
    26342634{
    2635         PyObject *_res = NULL;
    2636         OSErr _err;
    2637         short vRefNum;
    2638         long dirID;
    2639         Str255 fileName;
    2640         FSSpec spec;
    2641         if (!PyArg_ParseTuple(_args, "hlO&",
    2642                               &vRefNum,
    2643                               &dirID,
    2644                               PyMac_GetStr255, fileName))
    2645                 return NULL;
    2646         _err = FSMakeFSSpec(vRefNum,
    2647                             dirID,
    2648                             fileName,
    2649                             &spec);
    2650         if (_err != noErr) return PyMac_Error(_err);
    2651         _res = Py_BuildValue("O&",
    2652                              FSSpec_New, &spec);
    2653         return _res;
     2635    PyObject *_res = NULL;
     2636    OSErr _err;
     2637    short vRefNum;
     2638    long dirID;
     2639    Str255 fileName;
     2640    FSSpec spec;
     2641    if (!PyArg_ParseTuple(_args, "hlO&",
     2642                          &vRefNum,
     2643                          &dirID,
     2644                          PyMac_GetStr255, fileName))
     2645        return NULL;
     2646    _err = FSMakeFSSpec(vRefNum,
     2647                        dirID,
     2648                        fileName,
     2649                        &spec);
     2650    if (_err != noErr) return PyMac_Error(_err);
     2651    _res = Py_BuildValue("O&",
     2652                         FSSpec_New, &spec);
     2653    return _res;
    26542654}
    26552655#endif /* !__LP64__ */
     
    26572657static PyObject *File_FSGetForkPosition(PyObject *_self, PyObject *_args)
    26582658{
    2659         PyObject *_res = NULL;
    2660         OSErr _err;
    2661         SInt16 forkRefNum;
    2662         SInt64 position;
    2663         if (!PyArg_ParseTuple(_args, "h",
    2664                               &forkRefNum))
    2665                 return NULL;
    2666         _err = FSGetForkPosition(forkRefNum,
    2667                                  &position);
    2668         if (_err != noErr) return PyMac_Error(_err);
    2669         _res = Py_BuildValue("L",
    2670                              position);
    2671         return _res;
     2659    PyObject *_res = NULL;
     2660    OSErr _err;
     2661    SInt16 forkRefNum;
     2662    SInt64 position;
     2663    if (!PyArg_ParseTuple(_args, "h",
     2664                          &forkRefNum))
     2665        return NULL;
     2666    _err = FSGetForkPosition(forkRefNum,
     2667                             &position);
     2668    if (_err != noErr) return PyMac_Error(_err);
     2669    _res = Py_BuildValue("L",
     2670                         position);
     2671    return _res;
    26722672}
    26732673
    26742674static PyObject *File_FSSetForkPosition(PyObject *_self, PyObject *_args)
    26752675{
    2676         PyObject *_res = NULL;
    2677         OSErr _err;
    2678         SInt16 forkRefNum;
    2679         UInt16 positionMode;
    2680         SInt64 positionOffset;
    2681         if (!PyArg_ParseTuple(_args, "hHL",
    2682                               &forkRefNum,
    2683                               &positionMode,
    2684                               &positionOffset))
    2685                 return NULL;
    2686         _err = FSSetForkPosition(forkRefNum,
    2687                                  positionMode,
    2688                                  positionOffset);
    2689         if (_err != noErr) return PyMac_Error(_err);
    2690         Py_INCREF(Py_None);
    2691         _res = Py_None;
    2692         return _res;
     2676    PyObject *_res = NULL;
     2677    OSErr _err;
     2678    SInt16 forkRefNum;
     2679    UInt16 positionMode;
     2680    SInt64 positionOffset;
     2681    if (!PyArg_ParseTuple(_args, "hHL",
     2682                          &forkRefNum,
     2683                          &positionMode,
     2684                          &positionOffset))
     2685        return NULL;
     2686    _err = FSSetForkPosition(forkRefNum,
     2687                             positionMode,
     2688                             positionOffset);
     2689    if (_err != noErr) return PyMac_Error(_err);
     2690    Py_INCREF(Py_None);
     2691    _res = Py_None;
     2692    return _res;
    26932693}
    26942694
    26952695static PyObject *File_FSGetForkSize(PyObject *_self, PyObject *_args)
    26962696{
    2697         PyObject *_res = NULL;
    2698         OSErr _err;
    2699         SInt16 forkRefNum;
    2700         SInt64 forkSize;
    2701         if (!PyArg_ParseTuple(_args, "h",
    2702                               &forkRefNum))
    2703                 return NULL;
    2704         _err = FSGetForkSize(forkRefNum,
    2705                              &forkSize);
    2706         if (_err != noErr) return PyMac_Error(_err);
    2707         _res = Py_BuildValue("L",
    2708                              forkSize);
    2709         return _res;
     2697    PyObject *_res = NULL;
     2698    OSErr _err;
     2699    SInt16 forkRefNum;
     2700    SInt64 forkSize;
     2701    if (!PyArg_ParseTuple(_args, "h",
     2702                          &forkRefNum))
     2703        return NULL;
     2704    _err = FSGetForkSize(forkRefNum,
     2705                         &forkSize);
     2706    if (_err != noErr) return PyMac_Error(_err);
     2707    _res = Py_BuildValue("L",
     2708                         forkSize);
     2709    return _res;
    27102710}
    27112711
    27122712static PyObject *File_FSSetForkSize(PyObject *_self, PyObject *_args)
    27132713{
    2714         PyObject *_res = NULL;
    2715         OSErr _err;
    2716         SInt16 forkRefNum;
    2717         UInt16 positionMode;
    2718         SInt64 positionOffset;
    2719         if (!PyArg_ParseTuple(_args, "hHL",
    2720                               &forkRefNum,
    2721                               &positionMode,
    2722                               &positionOffset))
    2723                 return NULL;
    2724         _err = FSSetForkSize(forkRefNum,
    2725                              positionMode,
    2726                              positionOffset);
    2727         if (_err != noErr) return PyMac_Error(_err);
    2728         Py_INCREF(Py_None);
    2729         _res = Py_None;
    2730         return _res;
     2714    PyObject *_res = NULL;
     2715    OSErr _err;
     2716    SInt16 forkRefNum;
     2717    UInt16 positionMode;
     2718    SInt64 positionOffset;
     2719    if (!PyArg_ParseTuple(_args, "hHL",
     2720                          &forkRefNum,
     2721                          &positionMode,
     2722                          &positionOffset))
     2723        return NULL;
     2724    _err = FSSetForkSize(forkRefNum,
     2725                         positionMode,
     2726                         positionOffset);
     2727    if (_err != noErr) return PyMac_Error(_err);
     2728    Py_INCREF(Py_None);
     2729    _res = Py_None;
     2730    return _res;
    27312731}
    27322732
    27332733static PyObject *File_FSAllocateFork(PyObject *_self, PyObject *_args)
    27342734{
    2735         PyObject *_res = NULL;
    2736         OSErr _err;
    2737         SInt16 forkRefNum;
    2738         FSAllocationFlags flags;
    2739         UInt16 positionMode;
    2740         SInt64 positionOffset;
    2741         UInt64 requestCount;
    2742         UInt64 actualCount;
    2743         if (!PyArg_ParseTuple(_args, "hHHLL",
    2744                               &forkRefNum,
    2745                               &flags,
    2746                               &positionMode,
    2747                               &positionOffset,
    2748                               &requestCount))
    2749                 return NULL;
    2750         _err = FSAllocateFork(forkRefNum,
    2751                               flags,
    2752                               positionMode,
    2753                               positionOffset,
    2754                               requestCount,
    2755                               &actualCount);
    2756         if (_err != noErr) return PyMac_Error(_err);
    2757         _res = Py_BuildValue("L",
    2758                              actualCount);
    2759         return _res;
     2735    PyObject *_res = NULL;
     2736    OSErr _err;
     2737    SInt16 forkRefNum;
     2738    FSAllocationFlags flags;
     2739    UInt16 positionMode;
     2740    SInt64 positionOffset;
     2741    UInt64 requestCount;
     2742    UInt64 actualCount;
     2743    if (!PyArg_ParseTuple(_args, "hHHLL",
     2744                          &forkRefNum,
     2745                          &flags,
     2746                          &positionMode,
     2747                          &positionOffset,
     2748                          &requestCount))
     2749        return NULL;
     2750    _err = FSAllocateFork(forkRefNum,
     2751                          flags,
     2752                          positionMode,
     2753                          positionOffset,
     2754                          requestCount,
     2755                          &actualCount);
     2756    if (_err != noErr) return PyMac_Error(_err);
     2757    _res = Py_BuildValue("L",
     2758                         actualCount);
     2759    return _res;
    27602760}
    27612761
    27622762static PyObject *File_FSFlushFork(PyObject *_self, PyObject *_args)
    27632763{
    2764         PyObject *_res = NULL;
    2765         OSErr _err;
    2766         SInt16 forkRefNum;
    2767         if (!PyArg_ParseTuple(_args, "h",
    2768                               &forkRefNum))
    2769                 return NULL;
    2770         _err = FSFlushFork(forkRefNum);
    2771         if (_err != noErr) return PyMac_Error(_err);
    2772         Py_INCREF(Py_None);
    2773         _res = Py_None;
    2774         return _res;
     2764    PyObject *_res = NULL;
     2765    OSErr _err;
     2766    SInt16 forkRefNum;
     2767    if (!PyArg_ParseTuple(_args, "h",
     2768                          &forkRefNum))
     2769        return NULL;
     2770    _err = FSFlushFork(forkRefNum);
     2771    if (_err != noErr) return PyMac_Error(_err);
     2772    Py_INCREF(Py_None);
     2773    _res = Py_None;
     2774    return _res;
    27752775}
    27762776
    27772777static PyObject *File_FSCloseFork(PyObject *_self, PyObject *_args)
    27782778{
    2779         PyObject *_res = NULL;
    2780         OSErr _err;
    2781         SInt16 forkRefNum;
    2782         if (!PyArg_ParseTuple(_args, "h",
    2783                               &forkRefNum))
    2784                 return NULL;
    2785         _err = FSCloseFork(forkRefNum);
    2786         if (_err != noErr) return PyMac_Error(_err);
    2787         Py_INCREF(Py_None);
    2788         _res = Py_None;
    2789         return _res;
     2779    PyObject *_res = NULL;
     2780    OSErr _err;
     2781    SInt16 forkRefNum;
     2782    if (!PyArg_ParseTuple(_args, "h",
     2783                          &forkRefNum))
     2784        return NULL;
     2785    _err = FSCloseFork(forkRefNum);
     2786    if (_err != noErr) return PyMac_Error(_err);
     2787    Py_INCREF(Py_None);
     2788    _res = Py_None;
     2789    return _res;
    27902790}
    27912791
    27922792static PyObject *File_FSGetDataForkName(PyObject *_self, PyObject *_args)
    27932793{
    2794         PyObject *_res = NULL;
    2795         OSErr _err;
    2796         HFSUniStr255 dataForkName;
    2797         if (!PyArg_ParseTuple(_args, ""))
    2798                 return NULL;
    2799         _err = FSGetDataForkName(&dataForkName);
    2800         if (_err != noErr) return PyMac_Error(_err);
    2801         _res = Py_BuildValue("O&",
    2802                              PyMac_BuildHFSUniStr255, &dataForkName);
    2803         return _res;
     2794    PyObject *_res = NULL;
     2795    OSErr _err;
     2796    HFSUniStr255 dataForkName;
     2797    if (!PyArg_ParseTuple(_args, ""))
     2798        return NULL;
     2799    _err = FSGetDataForkName(&dataForkName);
     2800    if (_err != noErr) return PyMac_Error(_err);
     2801    _res = Py_BuildValue("O&",
     2802                         PyMac_BuildHFSUniStr255, &dataForkName);
     2803    return _res;
    28042804}
    28052805
    28062806static PyObject *File_FSGetResourceForkName(PyObject *_self, PyObject *_args)
    28072807{
    2808         PyObject *_res = NULL;
    2809         OSErr _err;
    2810         HFSUniStr255 resourceForkName;
    2811         if (!PyArg_ParseTuple(_args, ""))
    2812                 return NULL;
    2813         _err = FSGetResourceForkName(&resourceForkName);
    2814         if (_err != noErr) return PyMac_Error(_err);
    2815         _res = Py_BuildValue("O&",
    2816                              PyMac_BuildHFSUniStr255, &resourceForkName);
    2817         return _res;
     2808    PyObject *_res = NULL;
     2809    OSErr _err;
     2810    HFSUniStr255 resourceForkName;
     2811    if (!PyArg_ParseTuple(_args, ""))
     2812        return NULL;
     2813    _err = FSGetResourceForkName(&resourceForkName);
     2814    if (_err != noErr) return PyMac_Error(_err);
     2815    _res = Py_BuildValue("O&",
     2816                         PyMac_BuildHFSUniStr255, &resourceForkName);
     2817    return _res;
    28182818}
    28192819
    28202820static PyObject *File_FSPathMakeRef(PyObject *_self, PyObject *_args)
    28212821{
    2822         PyObject *_res = NULL;
    2823         OSStatus _err;
    2824         UInt8 * path;
    2825         FSRef ref;
    2826         Boolean isDirectory;
    2827         if (!PyArg_ParseTuple(_args, "s",
    2828                               &path))
    2829                 return NULL;
    2830         _err = FSPathMakeRef(path,
    2831                              &ref,
    2832                              &isDirectory);
    2833         if (_err != noErr) return PyMac_Error(_err);
    2834         _res = Py_BuildValue("O&b",
    2835                              FSRef_New, &ref,
    2836                              isDirectory);
    2837         return _res;
     2822    PyObject *_res = NULL;
     2823    OSStatus _err;
     2824    UInt8 * path;
     2825    FSRef ref;
     2826    Boolean isDirectory;
     2827    if (!PyArg_ParseTuple(_args, "s",
     2828                          &path))
     2829        return NULL;
     2830    _err = FSPathMakeRef(path,
     2831                         &ref,
     2832                         &isDirectory);
     2833    if (_err != noErr) return PyMac_Error(_err);
     2834    _res = Py_BuildValue("O&b",
     2835                         FSRef_New, &ref,
     2836                         isDirectory);
     2837    return _res;
    28382838}
    28392839
    28402840static PyObject *File_FNNotifyByPath(PyObject *_self, PyObject *_args)
    28412841{
    2842         PyObject *_res = NULL;
    2843         OSStatus _err;
    2844         UInt8 * path;
    2845         FNMessage message;
    2846         OptionBits flags;
    2847         if (!PyArg_ParseTuple(_args, "sll",
    2848                               &path,
    2849                               &message,
    2850                               &flags))
    2851                 return NULL;
    2852         _err = FNNotifyByPath(path,
    2853                               message,
    2854                               flags);
    2855         if (_err != noErr) return PyMac_Error(_err);
    2856         Py_INCREF(Py_None);
    2857         _res = Py_None;
    2858         return _res;
     2842    PyObject *_res = NULL;
     2843    OSStatus _err;
     2844    UInt8 * path;
     2845    FNMessage message;
     2846    OptionBits flags;
     2847    if (!PyArg_ParseTuple(_args, "sll",
     2848                          &path,
     2849                          &message,
     2850                          &flags))
     2851        return NULL;
     2852    _err = FNNotifyByPath(path,
     2853                          message,
     2854                          flags);
     2855    if (_err != noErr) return PyMac_Error(_err);
     2856    Py_INCREF(Py_None);
     2857    _res = Py_None;
     2858    return _res;
    28592859}
    28602860
    28612861static PyObject *File_FNNotifyAll(PyObject *_self, PyObject *_args)
    28622862{
    2863         PyObject *_res = NULL;
    2864         OSStatus _err;
    2865         FNMessage message;
    2866         OptionBits flags;
    2867         if (!PyArg_ParseTuple(_args, "ll",
    2868                               &message,
    2869                               &flags))
    2870                 return NULL;
    2871         _err = FNNotifyAll(message,
    2872                            flags);
    2873         if (_err != noErr) return PyMac_Error(_err);
    2874         Py_INCREF(Py_None);
    2875         _res = Py_None;
    2876         return _res;
     2863    PyObject *_res = NULL;
     2864    OSStatus _err;
     2865    FNMessage message;
     2866    OptionBits flags;
     2867    if (!PyArg_ParseTuple(_args, "ll",
     2868                          &message,
     2869                          &flags))
     2870        return NULL;
     2871    _err = FNNotifyAll(message,
     2872                       flags);
     2873    if (_err != noErr) return PyMac_Error(_err);
     2874    Py_INCREF(Py_None);
     2875    _res = Py_None;
     2876    return _res;
    28772877}
    28782878
     
    28802880static PyObject *File_NewAlias(PyObject *_self, PyObject *_args)
    28812881{
    2882         PyObject *_res = NULL;
    2883         OSErr _err;
    2884         FSSpec fromFile__buf__;
    2885         FSSpec *fromFile = &fromFile__buf__;
    2886         FSSpec target;
    2887         AliasHandle alias;
    2888         if (!PyArg_ParseTuple(_args, "O&O&",
    2889                               myPyMac_GetOptFSSpecPtr, &fromFile,
    2890                               FSSpec_Convert, &target))
    2891                 return NULL;
    2892         _err = NewAlias(fromFile,
    2893                         &target,
    2894                         &alias);
    2895         if (_err != noErr) return PyMac_Error(_err);
    2896         _res = Py_BuildValue("O&",
    2897                              Alias_New, alias);
    2898         return _res;
     2882    PyObject *_res = NULL;
     2883    OSErr _err;
     2884    FSSpec fromFile__buf__;
     2885    FSSpec *fromFile = &fromFile__buf__;
     2886    FSSpec target;
     2887    AliasHandle alias;
     2888    if (!PyArg_ParseTuple(_args, "O&O&",
     2889                          myPyMac_GetOptFSSpecPtr, &fromFile,
     2890                          FSSpec_Convert, &target))
     2891        return NULL;
     2892    _err = NewAlias(fromFile,
     2893                    &target,
     2894                    &alias);
     2895    if (_err != noErr) return PyMac_Error(_err);
     2896    _res = Py_BuildValue("O&",
     2897                         Alias_New, alias);
     2898    return _res;
    28992899}
    29002900
    29012901static PyObject *File_NewAliasMinimalFromFullPath(PyObject *_self, PyObject *_args)
    29022902{
    2903         PyObject *_res = NULL;
    2904         OSErr _err;
    2905         char *fullPath__in__;
    2906         int fullPath__len__;
    2907         int fullPath__in_len__;
    2908         Str32 zoneName;
    2909         Str31 serverName;
    2910         AliasHandle alias;
    2911         if (!PyArg_ParseTuple(_args, "s#O&O&",
    2912                               &fullPath__in__, &fullPath__in_len__,
    2913                               PyMac_GetStr255, zoneName,
    2914                               PyMac_GetStr255, serverName))
    2915                 return NULL;
    2916         fullPath__len__ = fullPath__in_len__;
    2917         _err = NewAliasMinimalFromFullPath(fullPath__len__, fullPath__in__,
    2918                                            zoneName,
    2919                                            serverName,
    2920                                            &alias);
    2921         if (_err != noErr) return PyMac_Error(_err);
    2922         _res = Py_BuildValue("O&",
    2923                              Alias_New, alias);
    2924         return _res;
     2903    PyObject *_res = NULL;
     2904    OSErr _err;
     2905    char *fullPath__in__;
     2906    int fullPath__len__;
     2907    int fullPath__in_len__;
     2908    Str32 zoneName;
     2909    Str31 serverName;
     2910    AliasHandle alias;
     2911    if (!PyArg_ParseTuple(_args, "s#O&O&",
     2912                          &fullPath__in__, &fullPath__in_len__,
     2913                          PyMac_GetStr255, zoneName,
     2914                          PyMac_GetStr255, serverName))
     2915        return NULL;
     2916    fullPath__len__ = fullPath__in_len__;
     2917    _err = NewAliasMinimalFromFullPath(fullPath__len__, fullPath__in__,
     2918                                       zoneName,
     2919                                       serverName,
     2920                                       &alias);
     2921    if (_err != noErr) return PyMac_Error(_err);
     2922    _res = Py_BuildValue("O&",
     2923                         Alias_New, alias);
     2924    return _res;
    29252925}
    29262926
    29272927static PyObject *File_ResolveAliasFile(PyObject *_self, PyObject *_args)
    29282928{
    2929         PyObject *_res = NULL;
    2930         OSErr _err;
    2931         FSSpec theSpec;
    2932         Boolean resolveAliasChains;
    2933         Boolean targetIsFolder;
    2934         Boolean wasAliased;
    2935         if (!PyArg_ParseTuple(_args, "O&b",
    2936                               FSSpec_Convert, &theSpec,
    2937                               &resolveAliasChains))
    2938                 return NULL;
    2939         _err = ResolveAliasFile(&theSpec,
    2940                                 resolveAliasChains,
    2941                                 &targetIsFolder,
    2942                                 &wasAliased);
    2943         if (_err != noErr) return PyMac_Error(_err);
    2944         _res = Py_BuildValue("O&bb",
    2945                              FSSpec_New, &theSpec,
    2946                              targetIsFolder,
    2947                              wasAliased);
    2948         return _res;
     2929    PyObject *_res = NULL;
     2930    OSErr _err;
     2931    FSSpec theSpec;
     2932    Boolean resolveAliasChains;
     2933    Boolean targetIsFolder;
     2934    Boolean wasAliased;
     2935    if (!PyArg_ParseTuple(_args, "O&b",
     2936                          FSSpec_Convert, &theSpec,
     2937                          &resolveAliasChains))
     2938        return NULL;
     2939    _err = ResolveAliasFile(&theSpec,
     2940                            resolveAliasChains,
     2941                            &targetIsFolder,
     2942                            &wasAliased);
     2943    if (_err != noErr) return PyMac_Error(_err);
     2944    _res = Py_BuildValue("O&bb",
     2945                         FSSpec_New, &theSpec,
     2946                         targetIsFolder,
     2947                         wasAliased);
     2948    return _res;
    29492949}
    29502950
    29512951static PyObject *File_ResolveAliasFileWithMountFlags(PyObject *_self, PyObject *_args)
    29522952{
    2953         PyObject *_res = NULL;
    2954         OSErr _err;
    2955         FSSpec theSpec;
    2956         Boolean resolveAliasChains;
    2957         Boolean targetIsFolder;
    2958         Boolean wasAliased;
    2959         unsigned long mountFlags;
    2960         if (!PyArg_ParseTuple(_args, "O&bl",
    2961                               FSSpec_Convert, &theSpec,
    2962                               &resolveAliasChains,
    2963                               &mountFlags))
    2964                 return NULL;
    2965         _err = ResolveAliasFileWithMountFlags(&theSpec,
    2966                                               resolveAliasChains,
    2967                                               &targetIsFolder,
    2968                                               &wasAliased,
    2969                                               mountFlags);
    2970         if (_err != noErr) return PyMac_Error(_err);
    2971         _res = Py_BuildValue("O&bb",
    2972                              FSSpec_New, &theSpec,
    2973                              targetIsFolder,
    2974                              wasAliased);
    2975         return _res;
     2953    PyObject *_res = NULL;
     2954    OSErr _err;
     2955    FSSpec theSpec;
     2956    Boolean resolveAliasChains;
     2957    Boolean targetIsFolder;
     2958    Boolean wasAliased;
     2959    unsigned long mountFlags;
     2960    if (!PyArg_ParseTuple(_args, "O&bl",
     2961                          FSSpec_Convert, &theSpec,
     2962                          &resolveAliasChains,
     2963                          &mountFlags))
     2964        return NULL;
     2965    _err = ResolveAliasFileWithMountFlags(&theSpec,
     2966                                          resolveAliasChains,
     2967                                          &targetIsFolder,
     2968                                          &wasAliased,
     2969                                          mountFlags);
     2970    if (_err != noErr) return PyMac_Error(_err);
     2971    _res = Py_BuildValue("O&bb",
     2972                         FSSpec_New, &theSpec,
     2973                         targetIsFolder,
     2974                         wasAliased);
     2975    return _res;
    29762976}
    29772977
    29782978static PyObject *File_UpdateAlias(PyObject *_self, PyObject *_args)
    29792979{
    2980         PyObject *_res = NULL;
    2981         OSErr _err;
    2982         FSSpec fromFile__buf__;
    2983         FSSpec *fromFile = &fromFile__buf__;
    2984         FSSpec target;
    2985         AliasHandle alias;
    2986         Boolean wasChanged;
    2987         if (!PyArg_ParseTuple(_args, "O&O&O&",
    2988                               myPyMac_GetOptFSSpecPtr, &fromFile,
    2989                               FSSpec_Convert, &target,
    2990                               Alias_Convert, &alias))
    2991                 return NULL;
    2992         _err = UpdateAlias(fromFile,
    2993                            &target,
    2994                            alias,
    2995                            &wasChanged);
    2996         if (_err != noErr) return PyMac_Error(_err);
    2997         _res = Py_BuildValue("b",
    2998                              wasChanged);
    2999         return _res;
     2980    PyObject *_res = NULL;
     2981    OSErr _err;
     2982    FSSpec fromFile__buf__;
     2983    FSSpec *fromFile = &fromFile__buf__;
     2984    FSSpec target;
     2985    AliasHandle alias;
     2986    Boolean wasChanged;
     2987    if (!PyArg_ParseTuple(_args, "O&O&O&",
     2988                          myPyMac_GetOptFSSpecPtr, &fromFile,
     2989                          FSSpec_Convert, &target,
     2990                          Alias_Convert, &alias))
     2991        return NULL;
     2992    _err = UpdateAlias(fromFile,
     2993                       &target,
     2994                       alias,
     2995                       &wasChanged);
     2996    if (_err != noErr) return PyMac_Error(_err);
     2997    _res = Py_BuildValue("b",
     2998                         wasChanged);
     2999    return _res;
    30003000}
    30013001
    30023002static PyObject *File_ResolveAliasFileWithMountFlagsNoUI(PyObject *_self, PyObject *_args)
    30033003{
    3004         PyObject *_res = NULL;
    3005         OSErr _err;
    3006         FSSpec theSpec;
    3007         Boolean resolveAliasChains;
    3008         Boolean targetIsFolder;
    3009         Boolean wasAliased;
    3010         unsigned long mountFlags;
    3011         if (!PyArg_ParseTuple(_args, "O&bl",
    3012                               FSSpec_Convert, &theSpec,
    3013                               &resolveAliasChains,
    3014                               &mountFlags))
    3015                 return NULL;
    3016         _err = ResolveAliasFileWithMountFlagsNoUI(&theSpec,
    3017                                                   resolveAliasChains,
    3018                                                   &targetIsFolder,
    3019                                                   &wasAliased,
    3020                                                   mountFlags);
    3021         if (_err != noErr) return PyMac_Error(_err);
    3022         _res = Py_BuildValue("O&bb",
    3023                              FSSpec_New, &theSpec,
    3024                              targetIsFolder,
    3025                              wasAliased);
    3026         return _res;
     3004    PyObject *_res = NULL;
     3005    OSErr _err;
     3006    FSSpec theSpec;
     3007    Boolean resolveAliasChains;
     3008    Boolean targetIsFolder;
     3009    Boolean wasAliased;
     3010    unsigned long mountFlags;
     3011    if (!PyArg_ParseTuple(_args, "O&bl",
     3012                          FSSpec_Convert, &theSpec,
     3013                          &resolveAliasChains,
     3014                          &mountFlags))
     3015        return NULL;
     3016    _err = ResolveAliasFileWithMountFlagsNoUI(&theSpec,
     3017                                              resolveAliasChains,
     3018                                              &targetIsFolder,
     3019                                              &wasAliased,
     3020                                              mountFlags);
     3021    if (_err != noErr) return PyMac_Error(_err);
     3022    _res = Py_BuildValue("O&bb",
     3023                         FSSpec_New, &theSpec,
     3024                         targetIsFolder,
     3025                         wasAliased);
     3026    return _res;
    30273027}
    30283028#endif /* !__LP64__ */
     
    30303030static PyObject *File_FSNewAlias(PyObject *_self, PyObject *_args)
    30313031{
    3032         PyObject *_res = NULL;
    3033         OSErr _err;
    3034         FSRef fromFile__buf__;
    3035         FSRef *fromFile = &fromFile__buf__;
    3036         FSRef target;
    3037         AliasHandle inAlias;
    3038         if (!PyArg_ParseTuple(_args, "O&O&",
    3039                               myPyMac_GetOptFSRefPtr, &fromFile,
    3040                               FSRef_Convert, &target))
    3041                 return NULL;
    3042         _err = FSNewAlias(fromFile,
    3043                           &target,
    3044                           &inAlias);
    3045         if (_err != noErr) return PyMac_Error(_err);
    3046         _res = Py_BuildValue("O&",
    3047                              Alias_New, inAlias);
    3048         return _res;
     3032    PyObject *_res = NULL;
     3033    OSErr _err;
     3034    FSRef fromFile__buf__;
     3035    FSRef *fromFile = &fromFile__buf__;
     3036    FSRef target;
     3037    AliasHandle inAlias;
     3038    if (!PyArg_ParseTuple(_args, "O&O&",
     3039                          myPyMac_GetOptFSRefPtr, &fromFile,
     3040                          FSRef_Convert, &target))
     3041        return NULL;
     3042    _err = FSNewAlias(fromFile,
     3043                      &target,
     3044                      &inAlias);
     3045    if (_err != noErr) return PyMac_Error(_err);
     3046    _res = Py_BuildValue("O&",
     3047                         Alias_New, inAlias);
     3048    return _res;
    30493049}
    30503050
    30513051static PyObject *File_FSResolveAliasFileWithMountFlags(PyObject *_self, PyObject *_args)
    30523052{
    3053         PyObject *_res = NULL;
    3054         OSErr _err;
    3055         FSRef theRef;
    3056         Boolean resolveAliasChains;
    3057         Boolean targetIsFolder;
    3058         Boolean wasAliased;
    3059         unsigned long mountFlags;
    3060         if (!PyArg_ParseTuple(_args, "O&bl",
    3061                               FSRef_Convert, &theRef,
    3062                               &resolveAliasChains,
    3063                               &mountFlags))
    3064                 return NULL;
    3065         _err = FSResolveAliasFileWithMountFlags(&theRef,
    3066                                                 resolveAliasChains,
    3067                                                 &targetIsFolder,
    3068                                                 &wasAliased,
    3069                                                 mountFlags);
    3070         if (_err != noErr) return PyMac_Error(_err);
    3071         _res = Py_BuildValue("O&bb",
    3072                              FSRef_New, &theRef,
    3073                              targetIsFolder,
    3074                              wasAliased);
    3075         return _res;
     3053    PyObject *_res = NULL;
     3054    OSErr _err;
     3055    FSRef theRef;
     3056    Boolean resolveAliasChains;
     3057    Boolean targetIsFolder;
     3058    Boolean wasAliased;
     3059    unsigned long mountFlags;
     3060    if (!PyArg_ParseTuple(_args, "O&bl",
     3061                          FSRef_Convert, &theRef,
     3062                          &resolveAliasChains,
     3063                          &mountFlags))
     3064        return NULL;
     3065    _err = FSResolveAliasFileWithMountFlags(&theRef,
     3066                                            resolveAliasChains,
     3067                                            &targetIsFolder,
     3068                                            &wasAliased,
     3069                                            mountFlags);
     3070    if (_err != noErr) return PyMac_Error(_err);
     3071    _res = Py_BuildValue("O&bb",
     3072                         FSRef_New, &theRef,
     3073                         targetIsFolder,
     3074                         wasAliased);
     3075    return _res;
    30763076}
    30773077
    30783078static PyObject *File_FSResolveAliasFile(PyObject *_self, PyObject *_args)
    30793079{
    3080         PyObject *_res = NULL;
    3081         OSErr _err;
    3082         FSRef theRef;
    3083         Boolean resolveAliasChains;
    3084         Boolean targetIsFolder;
    3085         Boolean wasAliased;
    3086         if (!PyArg_ParseTuple(_args, "O&b",
    3087                               FSRef_Convert, &theRef,
    3088                               &resolveAliasChains))
    3089                 return NULL;
    3090         _err = FSResolveAliasFile(&theRef,
    3091                                   resolveAliasChains,
    3092                                   &targetIsFolder,
    3093                                   &wasAliased);
    3094         if (_err != noErr) return PyMac_Error(_err);
    3095         _res = Py_BuildValue("O&bb",
    3096                              FSRef_New, &theRef,
    3097                              targetIsFolder,
    3098                              wasAliased);
    3099         return _res;
     3080    PyObject *_res = NULL;
     3081    OSErr _err;
     3082    FSRef theRef;
     3083    Boolean resolveAliasChains;
     3084    Boolean targetIsFolder;
     3085    Boolean wasAliased;
     3086    if (!PyArg_ParseTuple(_args, "O&b",
     3087                          FSRef_Convert, &theRef,
     3088                          &resolveAliasChains))
     3089        return NULL;
     3090    _err = FSResolveAliasFile(&theRef,
     3091                              resolveAliasChains,
     3092                              &targetIsFolder,
     3093                              &wasAliased);
     3094    if (_err != noErr) return PyMac_Error(_err);
     3095    _res = Py_BuildValue("O&bb",
     3096                         FSRef_New, &theRef,
     3097                         targetIsFolder,
     3098                         wasAliased);
     3099    return _res;
    31003100}
    31013101
    31023102static PyObject *File_FSUpdateAlias(PyObject *_self, PyObject *_args)
    31033103{
    3104         PyObject *_res = NULL;
    3105         OSErr _err;
    3106         FSRef fromFile__buf__;
    3107         FSRef *fromFile = &fromFile__buf__;
    3108         FSRef target;
    3109         AliasHandle alias;
    3110         Boolean wasChanged;
    3111         if (!PyArg_ParseTuple(_args, "O&O&O&",
    3112                               myPyMac_GetOptFSRefPtr, &fromFile,
    3113                               FSRef_Convert, &target,
    3114                               Alias_Convert, &alias))
    3115                 return NULL;
    3116         _err = FSUpdateAlias(fromFile,
    3117                              &target,
    3118                              alias,
    3119                              &wasChanged);
    3120         if (_err != noErr) return PyMac_Error(_err);
    3121         _res = Py_BuildValue("b",
    3122                              wasChanged);
    3123         return _res;
     3104    PyObject *_res = NULL;
     3105    OSErr _err;
     3106    FSRef fromFile__buf__;
     3107    FSRef *fromFile = &fromFile__buf__;
     3108    FSRef target;
     3109    AliasHandle alias;
     3110    Boolean wasChanged;
     3111    if (!PyArg_ParseTuple(_args, "O&O&O&",
     3112                          myPyMac_GetOptFSRefPtr, &fromFile,
     3113                          FSRef_Convert, &target,
     3114                          Alias_Convert, &alias))
     3115        return NULL;
     3116    _err = FSUpdateAlias(fromFile,
     3117                         &target,
     3118                         alias,
     3119                         &wasChanged);
     3120    if (_err != noErr) return PyMac_Error(_err);
     3121    _res = Py_BuildValue("b",
     3122                         wasChanged);
     3123    return _res;
    31243124}
    31253125
    31263126static PyObject *File_pathname(PyObject *_self, PyObject *_args)
    31273127{
    3128         PyObject *_res = NULL;
    3129 
    3130         PyObject *obj;
    3131 
    3132         if (!PyArg_ParseTuple(_args, "O", &obj))
    3133                 return NULL;
    3134         if (PyString_Check(obj)) {
    3135                 Py_INCREF(obj);
    3136                 return obj;
    3137         }
    3138         if (PyUnicode_Check(obj))
    3139                 return PyUnicode_AsEncodedString(obj, "utf8", "strict");
    3140         _res = PyObject_CallMethod(obj, "as_pathname", NULL);
    3141         return _res;
     3128    PyObject *_res = NULL;
     3129
     3130    PyObject *obj;
     3131
     3132    if (!PyArg_ParseTuple(_args, "O", &obj))
     3133        return NULL;
     3134    if (PyString_Check(obj)) {
     3135        Py_INCREF(obj);
     3136        return obj;
     3137    }
     3138    if (PyUnicode_Check(obj))
     3139        return PyUnicode_AsEncodedString(obj, "utf8", "strict");
     3140    _res = PyObject_CallMethod(obj, "as_pathname", NULL);
     3141    return _res;
    31423142
    31433143}
     
    31453145static PyMethodDef File_methods[] = {
    31463146#ifndef __LP64__
    3147         {"UnmountVol", (PyCFunction)File_UnmountVol, 1,
    3148         PyDoc_STR("(Str63 volName, short vRefNum) -> None")},
    3149         {"FlushVol", (PyCFunction)File_FlushVol, 1,
    3150         PyDoc_STR("(Str63 volName, short vRefNum) -> None")},
    3151         {"HSetVol", (PyCFunction)File_HSetVol, 1,
    3152         PyDoc_STR("(Str63 volName, short vRefNum, long dirID) -> None")},
    3153         {"FSClose", (PyCFunction)File_FSClose, 1,
    3154         PyDoc_STR("(short refNum) -> None")},
    3155         {"Allocate", (PyCFunction)File_Allocate, 1,
    3156         PyDoc_STR("(short refNum) -> (long count)")},
    3157         {"GetEOF", (PyCFunction)File_GetEOF, 1,
    3158         PyDoc_STR("(short refNum) -> (long logEOF)")},
    3159         {"SetEOF", (PyCFunction)File_SetEOF, 1,
    3160         PyDoc_STR("(short refNum, long logEOF) -> None")},
    3161         {"GetFPos", (PyCFunction)File_GetFPos, 1,
    3162         PyDoc_STR("(short refNum) -> (long filePos)")},
    3163         {"SetFPos", (PyCFunction)File_SetFPos, 1,
    3164         PyDoc_STR("(short refNum, short posMode, long posOff) -> None")},
    3165         {"GetVRefNum", (PyCFunction)File_GetVRefNum, 1,
    3166         PyDoc_STR("(short fileRefNum) -> (short vRefNum)")},
    3167         {"HGetVol", (PyCFunction)File_HGetVol, 1,
    3168         PyDoc_STR("(StringPtr volName) -> (short vRefNum, long dirID)")},
    3169         {"HOpen", (PyCFunction)File_HOpen, 1,
    3170         PyDoc_STR("(short vRefNum, long dirID, Str255 fileName, SInt8 permission) -> (short refNum)")},
    3171         {"HOpenDF", (PyCFunction)File_HOpenDF, 1,
    3172         PyDoc_STR("(short vRefNum, long dirID, Str255 fileName, SInt8 permission) -> (short refNum)")},
    3173         {"HOpenRF", (PyCFunction)File_HOpenRF, 1,
    3174         PyDoc_STR("(short vRefNum, long dirID, Str255 fileName, SInt8 permission) -> (short refNum)")},
    3175         {"AllocContig", (PyCFunction)File_AllocContig, 1,
    3176         PyDoc_STR("(short refNum) -> (long count)")},
    3177         {"HCreate", (PyCFunction)File_HCreate, 1,
    3178         PyDoc_STR("(short vRefNum, long dirID, Str255 fileName, OSType creator, OSType fileType) -> None")},
    3179         {"DirCreate", (PyCFunction)File_DirCreate, 1,
    3180         PyDoc_STR("(short vRefNum, long parentDirID, Str255 directoryName) -> (long createdDirID)")},
    3181         {"HDelete", (PyCFunction)File_HDelete, 1,
    3182         PyDoc_STR("(short vRefNum, long dirID, Str255 fileName) -> None")},
    3183         {"HGetFInfo", (PyCFunction)File_HGetFInfo, 1,
    3184         PyDoc_STR("(short vRefNum, long dirID, Str255 fileName) -> (FInfo fndrInfo)")},
    3185         {"HSetFInfo", (PyCFunction)File_HSetFInfo, 1,
    3186         PyDoc_STR("(short vRefNum, long dirID, Str255 fileName, FInfo fndrInfo) -> None")},
    3187         {"HSetFLock", (PyCFunction)File_HSetFLock, 1,
    3188         PyDoc_STR("(short vRefNum, long dirID, Str255 fileName) -> None")},
    3189         {"HRstFLock", (PyCFunction)File_HRstFLock, 1,
    3190         PyDoc_STR("(short vRefNum, long dirID, Str255 fileName) -> None")},
    3191         {"HRename", (PyCFunction)File_HRename, 1,
    3192         PyDoc_STR("(short vRefNum, long dirID, Str255 oldName, Str255 newName) -> None")},
    3193         {"CatMove", (PyCFunction)File_CatMove, 1,
    3194         PyDoc_STR("(short vRefNum, long dirID, Str255 oldName, long newDirID, Str255 newName) -> None")},
    3195         {"FSMakeFSSpec", (PyCFunction)File_FSMakeFSSpec, 1,
    3196         PyDoc_STR("(short vRefNum, long dirID, Str255 fileName) -> (FSSpec spec)")},
     3147    {"UnmountVol", (PyCFunction)File_UnmountVol, 1,
     3148    PyDoc_STR("(Str63 volName, short vRefNum) -> None")},
     3149    {"FlushVol", (PyCFunction)File_FlushVol, 1,
     3150    PyDoc_STR("(Str63 volName, short vRefNum) -> None")},
     3151    {"HSetVol", (PyCFunction)File_HSetVol, 1,
     3152    PyDoc_STR("(Str63 volName, short vRefNum, long dirID) -> None")},
     3153    {"FSClose", (PyCFunction)File_FSClose, 1,
     3154    PyDoc_STR("(short refNum) -> None")},
     3155    {"Allocate", (PyCFunction)File_Allocate, 1,
     3156    PyDoc_STR("(short refNum) -> (long count)")},
     3157    {"GetEOF", (PyCFunction)File_GetEOF, 1,
     3158    PyDoc_STR("(short refNum) -> (long logEOF)")},
     3159    {"SetEOF", (PyCFunction)File_SetEOF, 1,
     3160    PyDoc_STR("(short refNum, long logEOF) -> None")},
     3161    {"GetFPos", (PyCFunction)File_GetFPos, 1,
     3162    PyDoc_STR("(short refNum) -> (long filePos)")},
     3163    {"SetFPos", (PyCFunction)File_SetFPos, 1,
     3164    PyDoc_STR("(short refNum, short posMode, long posOff) -> None")},
     3165    {"GetVRefNum", (PyCFunction)File_GetVRefNum, 1,
     3166    PyDoc_STR("(short fileRefNum) -> (short vRefNum)")},
     3167    {"HGetVol", (PyCFunction)File_HGetVol, 1,
     3168    PyDoc_STR("(StringPtr volName) -> (short vRefNum, long dirID)")},
     3169    {"HOpen", (PyCFunction)File_HOpen, 1,
     3170    PyDoc_STR("(short vRefNum, long dirID, Str255 fileName, SInt8 permission) -> (short refNum)")},
     3171    {"HOpenDF", (PyCFunction)File_HOpenDF, 1,
     3172    PyDoc_STR("(short vRefNum, long dirID, Str255 fileName, SInt8 permission) -> (short refNum)")},
     3173    {"HOpenRF", (PyCFunction)File_HOpenRF, 1,
     3174    PyDoc_STR("(short vRefNum, long dirID, Str255 fileName, SInt8 permission) -> (short refNum)")},
     3175    {"AllocContig", (PyCFunction)File_AllocContig, 1,
     3176    PyDoc_STR("(short refNum) -> (long count)")},
     3177    {"HCreate", (PyCFunction)File_HCreate, 1,
     3178    PyDoc_STR("(short vRefNum, long dirID, Str255 fileName, OSType creator, OSType fileType) -> None")},
     3179    {"DirCreate", (PyCFunction)File_DirCreate, 1,
     3180    PyDoc_STR("(short vRefNum, long parentDirID, Str255 directoryName) -> (long createdDirID)")},
     3181    {"HDelete", (PyCFunction)File_HDelete, 1,
     3182    PyDoc_STR("(short vRefNum, long dirID, Str255 fileName) -> None")},
     3183    {"HGetFInfo", (PyCFunction)File_HGetFInfo, 1,
     3184    PyDoc_STR("(short vRefNum, long dirID, Str255 fileName) -> (FInfo fndrInfo)")},
     3185    {"HSetFInfo", (PyCFunction)File_HSetFInfo, 1,
     3186    PyDoc_STR("(short vRefNum, long dirID, Str255 fileName, FInfo fndrInfo) -> None")},
     3187    {"HSetFLock", (PyCFunction)File_HSetFLock, 1,
     3188    PyDoc_STR("(short vRefNum, long dirID, Str255 fileName) -> None")},
     3189    {"HRstFLock", (PyCFunction)File_HRstFLock, 1,
     3190    PyDoc_STR("(short vRefNum, long dirID, Str255 fileName) -> None")},
     3191    {"HRename", (PyCFunction)File_HRename, 1,
     3192    PyDoc_STR("(short vRefNum, long dirID, Str255 oldName, Str255 newName) -> None")},
     3193    {"CatMove", (PyCFunction)File_CatMove, 1,
     3194    PyDoc_STR("(short vRefNum, long dirID, Str255 oldName, long newDirID, Str255 newName) -> None")},
     3195    {"FSMakeFSSpec", (PyCFunction)File_FSMakeFSSpec, 1,
     3196    PyDoc_STR("(short vRefNum, long dirID, Str255 fileName) -> (FSSpec spec)")},
    31973197#endif /* !__LP64__*/
    3198         {"FSGetForkPosition", (PyCFunction)File_FSGetForkPosition, 1,
    3199         PyDoc_STR("(SInt16 forkRefNum) -> (SInt64 position)")},
    3200         {"FSSetForkPosition", (PyCFunction)File_FSSetForkPosition, 1,
    3201         PyDoc_STR("(SInt16 forkRefNum, UInt16 positionMode, SInt64 positionOffset) -> None")},
    3202         {"FSGetForkSize", (PyCFunction)File_FSGetForkSize, 1,
    3203         PyDoc_STR("(SInt16 forkRefNum) -> (SInt64 forkSize)")},
    3204         {"FSSetForkSize", (PyCFunction)File_FSSetForkSize, 1,
    3205         PyDoc_STR("(SInt16 forkRefNum, UInt16 positionMode, SInt64 positionOffset) -> None")},
    3206         {"FSAllocateFork", (PyCFunction)File_FSAllocateFork, 1,
    3207         PyDoc_STR("(SInt16 forkRefNum, FSAllocationFlags flags, UInt16 positionMode, SInt64 positionOffset, UInt64 requestCount) -> (UInt64 actualCount)")},
    3208         {"FSFlushFork", (PyCFunction)File_FSFlushFork, 1,
    3209         PyDoc_STR("(SInt16 forkRefNum) -> None")},
    3210         {"FSCloseFork", (PyCFunction)File_FSCloseFork, 1,
    3211         PyDoc_STR("(SInt16 forkRefNum) -> None")},
    3212         {"FSGetDataForkName", (PyCFunction)File_FSGetDataForkName, 1,
    3213         PyDoc_STR("() -> (HFSUniStr255 dataForkName)")},
    3214         {"FSGetResourceForkName", (PyCFunction)File_FSGetResourceForkName, 1,
    3215         PyDoc_STR("() -> (HFSUniStr255 resourceForkName)")},
    3216         {"FSPathMakeRef", (PyCFunction)File_FSPathMakeRef, 1,
    3217         PyDoc_STR("(UInt8 * path) -> (FSRef ref, Boolean isDirectory)")},
    3218         {"FNNotifyByPath", (PyCFunction)File_FNNotifyByPath, 1,
    3219         PyDoc_STR("(UInt8 * path, FNMessage message, OptionBits flags) -> None")},
    3220         {"FNNotifyAll", (PyCFunction)File_FNNotifyAll, 1,
    3221         PyDoc_STR("(FNMessage message, OptionBits flags) -> None")},
     3198    {"FSGetForkPosition", (PyCFunction)File_FSGetForkPosition, 1,
     3199    PyDoc_STR("(SInt16 forkRefNum) -> (SInt64 position)")},
     3200    {"FSSetForkPosition", (PyCFunction)File_FSSetForkPosition, 1,
     3201    PyDoc_STR("(SInt16 forkRefNum, UInt16 positionMode, SInt64 positionOffset) -> None")},
     3202    {"FSGetForkSize", (PyCFunction)File_FSGetForkSize, 1,
     3203    PyDoc_STR("(SInt16 forkRefNum) -> (SInt64 forkSize)")},
     3204    {"FSSetForkSize", (PyCFunction)File_FSSetForkSize, 1,
     3205    PyDoc_STR("(SInt16 forkRefNum, UInt16 positionMode, SInt64 positionOffset) -> None")},
     3206    {"FSAllocateFork", (PyCFunction)File_FSAllocateFork, 1,
     3207    PyDoc_STR("(SInt16 forkRefNum, FSAllocationFlags flags, UInt16 positionMode, SInt64 positionOffset, UInt64 requestCount) -> (UInt64 actualCount)")},
     3208    {"FSFlushFork", (PyCFunction)File_FSFlushFork, 1,
     3209    PyDoc_STR("(SInt16 forkRefNum) -> None")},
     3210    {"FSCloseFork", (PyCFunction)File_FSCloseFork, 1,
     3211    PyDoc_STR("(SInt16 forkRefNum) -> None")},
     3212    {"FSGetDataForkName", (PyCFunction)File_FSGetDataForkName, 1,
     3213    PyDoc_STR("() -> (HFSUniStr255 dataForkName)")},
     3214    {"FSGetResourceForkName", (PyCFunction)File_FSGetResourceForkName, 1,
     3215    PyDoc_STR("() -> (HFSUniStr255 resourceForkName)")},
     3216    {"FSPathMakeRef", (PyCFunction)File_FSPathMakeRef, 1,
     3217    PyDoc_STR("(UInt8 * path) -> (FSRef ref, Boolean isDirectory)")},
     3218    {"FNNotifyByPath", (PyCFunction)File_FNNotifyByPath, 1,
     3219    PyDoc_STR("(UInt8 * path, FNMessage message, OptionBits flags) -> None")},
     3220    {"FNNotifyAll", (PyCFunction)File_FNNotifyAll, 1,
     3221    PyDoc_STR("(FNMessage message, OptionBits flags) -> None")},
    32223222#ifndef  __LP64__
    3223         {"NewAlias", (PyCFunction)File_NewAlias, 1,
    3224         PyDoc_STR("(FSSpec fromFile, FSSpec target) -> (AliasHandle alias)")},
    3225         {"NewAliasMinimalFromFullPath", (PyCFunction)File_NewAliasMinimalFromFullPath, 1,
    3226         PyDoc_STR("(Buffer fullPath, Str32 zoneName, Str31 serverName) -> (AliasHandle alias)")},
    3227         {"ResolveAliasFile", (PyCFunction)File_ResolveAliasFile, 1,
    3228         PyDoc_STR("(FSSpec theSpec, Boolean resolveAliasChains) -> (FSSpec theSpec, Boolean targetIsFolder, Boolean wasAliased)")},
    3229         {"ResolveAliasFileWithMountFlags", (PyCFunction)File_ResolveAliasFileWithMountFlags, 1,
    3230         PyDoc_STR("(FSSpec theSpec, Boolean resolveAliasChains, unsigned long mountFlags) -> (FSSpec theSpec, Boolean targetIsFolder, Boolean wasAliased)")},
    3231         {"UpdateAlias", (PyCFunction)File_UpdateAlias, 1,
    3232         PyDoc_STR("(FSSpec fromFile, FSSpec target, AliasHandle alias) -> (Boolean wasChanged)")},
    3233         {"ResolveAliasFileWithMountFlagsNoUI", (PyCFunction)File_ResolveAliasFileWithMountFlagsNoUI, 1,
    3234         PyDoc_STR("(FSSpec theSpec, Boolean resolveAliasChains, unsigned long mountFlags) -> (FSSpec theSpec, Boolean targetIsFolder, Boolean wasAliased)")},
     3223    {"NewAlias", (PyCFunction)File_NewAlias, 1,
     3224    PyDoc_STR("(FSSpec fromFile, FSSpec target) -> (AliasHandle alias)")},
     3225    {"NewAliasMinimalFromFullPath", (PyCFunction)File_NewAliasMinimalFromFullPath, 1,
     3226    PyDoc_STR("(Buffer fullPath, Str32 zoneName, Str31 serverName) -> (AliasHandle alias)")},
     3227    {"ResolveAliasFile", (PyCFunction)File_ResolveAliasFile, 1,
     3228    PyDoc_STR("(FSSpec theSpec, Boolean resolveAliasChains) -> (FSSpec theSpec, Boolean targetIsFolder, Boolean wasAliased)")},
     3229    {"ResolveAliasFileWithMountFlags", (PyCFunction)File_ResolveAliasFileWithMountFlags, 1,
     3230    PyDoc_STR("(FSSpec theSpec, Boolean resolveAliasChains, unsigned long mountFlags) -> (FSSpec theSpec, Boolean targetIsFolder, Boolean wasAliased)")},
     3231    {"UpdateAlias", (PyCFunction)File_UpdateAlias, 1,
     3232    PyDoc_STR("(FSSpec fromFile, FSSpec target, AliasHandle alias) -> (Boolean wasChanged)")},
     3233    {"ResolveAliasFileWithMountFlagsNoUI", (PyCFunction)File_ResolveAliasFileWithMountFlagsNoUI, 1,
     3234    PyDoc_STR("(FSSpec theSpec, Boolean resolveAliasChains, unsigned long mountFlags) -> (FSSpec theSpec, Boolean targetIsFolder, Boolean wasAliased)")},
    32353235#endif /* !__LP64__ */
    3236         {"FSNewAlias", (PyCFunction)File_FSNewAlias, 1,
    3237         PyDoc_STR("(FSRef fromFile, FSRef target) -> (AliasHandle inAlias)")},
    3238         {"FSResolveAliasFileWithMountFlags", (PyCFunction)File_FSResolveAliasFileWithMountFlags, 1,
    3239         PyDoc_STR("(FSRef theRef, Boolean resolveAliasChains, unsigned long mountFlags) -> (FSRef theRef, Boolean targetIsFolder, Boolean wasAliased)")},
    3240         {"FSResolveAliasFile", (PyCFunction)File_FSResolveAliasFile, 1,
    3241         PyDoc_STR("(FSRef theRef, Boolean resolveAliasChains) -> (FSRef theRef, Boolean targetIsFolder, Boolean wasAliased)")},
    3242         {"FSUpdateAlias", (PyCFunction)File_FSUpdateAlias, 1,
    3243         PyDoc_STR("(FSRef fromFile, FSRef target, AliasHandle alias) -> (Boolean wasChanged)")},
    3244         {"pathname", (PyCFunction)File_pathname, 1,
    3245         PyDoc_STR("(str|unicode|FSSpec|FSref) -> pathname")},
    3246         {NULL, NULL, 0}
     3236    {"FSNewAlias", (PyCFunction)File_FSNewAlias, 1,
     3237    PyDoc_STR("(FSRef fromFile, FSRef target) -> (AliasHandle inAlias)")},
     3238    {"FSResolveAliasFileWithMountFlags", (PyCFunction)File_FSResolveAliasFileWithMountFlags, 1,
     3239    PyDoc_STR("(FSRef theRef, Boolean resolveAliasChains, unsigned long mountFlags) -> (FSRef theRef, Boolean targetIsFolder, Boolean wasAliased)")},
     3240    {"FSResolveAliasFile", (PyCFunction)File_FSResolveAliasFile, 1,
     3241    PyDoc_STR("(FSRef theRef, Boolean resolveAliasChains) -> (FSRef theRef, Boolean targetIsFolder, Boolean wasAliased)")},
     3242    {"FSUpdateAlias", (PyCFunction)File_FSUpdateAlias, 1,
     3243    PyDoc_STR("(FSRef fromFile, FSRef target, AliasHandle alias) -> (Boolean wasChanged)")},
     3244    {"pathname", (PyCFunction)File_pathname, 1,
     3245    PyDoc_STR("(str|unicode|FSSpec|FSref) -> pathname")},
     3246    {NULL, NULL, 0}
    32473247};
    32483248
     
    32523252PyMac_GetFSSpec(PyObject *v, FSSpec *spec)
    32533253{
    3254         Str255 path;
    3255         short refnum;
    3256         long parid;
    3257         OSErr err;
    3258         FSRef fsr;
    3259 
    3260         if (FSSpec_Check(v)) {
    3261                 *spec = ((FSSpecObject *)v)->ob_itself;
    3262                 return 1;
     3254    Str255 path;
     3255    short refnum;
     3256    long parid;
     3257    OSErr err;
     3258    FSRef fsr;
     3259
     3260    if (FSSpec_Check(v)) {
     3261        *spec = ((FSSpecObject *)v)->ob_itself;
     3262        return 1;
     3263    }
     3264
     3265    if (PyArg_Parse(v, "(hlO&)",
     3266                                            &refnum, &parid, PyMac_GetStr255, &path)) {
     3267        err = FSMakeFSSpec(refnum, parid, path, spec);
     3268        if ( err && err != fnfErr ) {
     3269            PyMac_Error(err);
     3270            return 0;
    32633271        }
    3264 
    3265         if (PyArg_Parse(v, "(hlO&)",
    3266                                                 &refnum, &parid, PyMac_GetStr255, &path)) {
    3267                 err = FSMakeFSSpec(refnum, parid, path, spec);
    3268                 if ( err && err != fnfErr ) {
    3269                         PyMac_Error(err);
    3270                         return 0;
    3271                 }
    3272                 return 1;
     3272        return 1;
     3273    }
     3274    PyErr_Clear();
     3275    /* Otherwise we try to go via an FSRef. On OSX we go all the way,
     3276    ** on OS9 we accept only a real FSRef object
     3277    */
     3278    if ( PyMac_GetFSRef(v, &fsr) ) {
     3279        err = FSGetCatalogInfo(&fsr, kFSCatInfoNone, NULL, NULL, spec, NULL);
     3280        if (err != noErr) {
     3281            PyMac_Error(err);
     3282            return 0;
    32733283        }
    3274         PyErr_Clear();
    3275         /* Otherwise we try to go via an FSRef. On OSX we go all the way,
    3276         ** on OS9 we accept only a real FSRef object
    3277         */
    3278         if ( PyMac_GetFSRef(v, &fsr) ) {
    3279                 err = FSGetCatalogInfo(&fsr, kFSCatInfoNone, NULL, NULL, spec, NULL);
    3280                 if (err != noErr) {
    3281                         PyMac_Error(err);
    3282                         return 0;
    3283                 }
    3284                 return 1;
    3285         }
    3286         return 0;
     3284        return 1;
     3285    }
     3286    return 0;
    32873287}
    32883288#endif /* !__LP64__ */
     
    32913291PyMac_GetFSRef(PyObject *v, FSRef *fsr)
    32923292{
    3293         OSStatus err;
     3293    OSStatus err;
    32943294#ifndef __LP64__
    3295         FSSpec fss;
     3295    FSSpec fss;
    32963296#endif /* !__LP64__ */
    32973297
    3298         if (FSRef_Check(v)) {
    3299                 *fsr = ((FSRefObject *)v)->ob_itself;
    3300                 return 1;
    3301         }
    3302 
    3303         /* On OSX we now try a pathname */
    3304         if ( PyString_Check(v) || PyUnicode_Check(v)) {
    3305                 char *path = NULL;
    3306                 if (!PyArg_Parse(v, "et", Py_FileSystemDefaultEncoding, &path))
    3307                         return 0;
    3308                 if ( (err=FSPathMakeRef((unsigned char*)path, fsr, NULL)) )
    3309                         PyMac_Error(err);
    3310                 PyMem_Free(path);
    3311                 return !err;
    3312         }
    3313         /* XXXX Should try unicode here too */
     3298    if (FSRef_Check(v)) {
     3299        *fsr = ((FSRefObject *)v)->ob_itself;
     3300        return 1;
     3301    }
     3302
     3303    /* On OSX we now try a pathname */
     3304    if ( PyString_Check(v) || PyUnicode_Check(v)) {
     3305        char *path = NULL;
     3306        if (!PyArg_Parse(v, "et", Py_FileSystemDefaultEncoding, &path))
     3307            return 0;
     3308        if ( (err=FSPathMakeRef((unsigned char*)path, fsr, NULL)) )
     3309            PyMac_Error(err);
     3310        PyMem_Free(path);
     3311        return !err;
     3312    }
     3313    /* XXXX Should try unicode here too */
    33143314
    33153315#ifndef __LP64__
    3316         /* Otherwise we try to go via an FSSpec */
    3317         if (FSSpec_Check(v)) {
    3318                 fss = ((FSSpecObject *)v)->ob_itself;
    3319                 if ((err=FSpMakeFSRef(&fss, fsr)) == 0)
    3320                         return 1;
    3321                 PyMac_Error(err);
    3322                 return 0;
    3323         }
     3316    /* Otherwise we try to go via an FSSpec */
     3317    if (FSSpec_Check(v)) {
     3318        fss = ((FSSpecObject *)v)->ob_itself;
     3319        if ((err=FSpMakeFSRef(&fss, fsr)) == 0)
     3320            return 1;
     3321        PyMac_Error(err);
     3322        return 0;
     3323    }
    33243324#endif /* !__LP64__ */
    33253325
    3326         PyErr_SetString(PyExc_TypeError, "FSRef, FSSpec or pathname required");
    3327         return 0;
     3326    PyErr_SetString(PyExc_TypeError, "FSRef, FSSpec or pathname required");
     3327    return 0;
    33283328}
    33293329
     
    33323332PyMac_BuildFSSpec(FSSpec *spec)
    33333333{
    3334         return FSSpec_New(spec);
     3334    return FSSpec_New(spec);
    33353335}
    33363336#endif /* !__LP64__ */
     
    33393339PyMac_BuildFSRef(FSRef *spec)
    33403340{
    3341         return FSRef_New(spec);
     3341    return FSRef_New(spec);
    33423342}
    33433343
     
    33453345void init_File(void)
    33463346{
    3347         PyObject *m;
    3348         PyObject *d;
     3347    PyObject *m;
     3348    PyObject *d;
    33493349
    33503350
    33513351#ifndef __LP64__
    3352         PyMac_INIT_TOOLBOX_OBJECT_NEW(FSSpec *, PyMac_BuildFSSpec);
    3353         PyMac_INIT_TOOLBOX_OBJECT_CONVERT(FSSpec, PyMac_GetFSSpec);
     3352    PyMac_INIT_TOOLBOX_OBJECT_NEW(FSSpec *, PyMac_BuildFSSpec);
     3353    PyMac_INIT_TOOLBOX_OBJECT_CONVERT(FSSpec, PyMac_GetFSSpec);
    33543354#endif /* !__LP64__ */
    33553355
    3356         PyMac_INIT_TOOLBOX_OBJECT_NEW(FSRef *, PyMac_BuildFSRef);
    3357         PyMac_INIT_TOOLBOX_OBJECT_CONVERT(FSRef, PyMac_GetFSRef);
    3358 
    3359 
    3360         m = Py_InitModule("_File", File_methods);
    3361         d = PyModule_GetDict(m);
    3362         File_Error = PyMac_GetOSErrException();
    3363         if (File_Error == NULL ||
    3364             PyDict_SetItemString(d, "Error", File_Error) != 0)
    3365                 return;
    3366         FSCatalogInfo_Type.ob_type = &PyType_Type;
    3367         if (PyType_Ready(&FSCatalogInfo_Type) < 0) return;
    3368         Py_INCREF(&FSCatalogInfo_Type);
    3369         PyModule_AddObject(m, "FSCatalogInfo", (PyObject *)&FSCatalogInfo_Type);
    3370         /* Backward-compatible name */
    3371         Py_INCREF(&FSCatalogInfo_Type);
    3372         PyModule_AddObject(m, "FSCatalogInfoType", (PyObject *)&FSCatalogInfo_Type);
     3356    PyMac_INIT_TOOLBOX_OBJECT_NEW(FSRef *, PyMac_BuildFSRef);
     3357    PyMac_INIT_TOOLBOX_OBJECT_CONVERT(FSRef, PyMac_GetFSRef);
     3358
     3359
     3360    m = Py_InitModule("_File", File_methods);
     3361    d = PyModule_GetDict(m);
     3362    File_Error = PyMac_GetOSErrException();
     3363    if (File_Error == NULL ||
     3364        PyDict_SetItemString(d, "Error", File_Error) != 0)
     3365        return;
     3366    FSCatalogInfo_Type.ob_type = &PyType_Type;
     3367    if (PyType_Ready(&FSCatalogInfo_Type) < 0) return;
     3368    Py_INCREF(&FSCatalogInfo_Type);
     3369    PyModule_AddObject(m, "FSCatalogInfo", (PyObject *)&FSCatalogInfo_Type);
     3370    /* Backward-compatible name */
     3371    Py_INCREF(&FSCatalogInfo_Type);
     3372    PyModule_AddObject(m, "FSCatalogInfoType", (PyObject *)&FSCatalogInfo_Type);
    33733373
    33743374#ifndef __LP64__
    3375         FInfo_Type.ob_type = &PyType_Type;
    3376         if (PyType_Ready(&FInfo_Type) < 0) return;
    3377         Py_INCREF(&FInfo_Type);
    3378         PyModule_AddObject(m, "FInfo", (PyObject *)&FInfo_Type);
    3379         /* Backward-compatible name */
    3380         Py_INCREF(&FInfo_Type);
    3381         PyModule_AddObject(m, "FInfoType", (PyObject *)&FInfo_Type);
     3375    FInfo_Type.ob_type = &PyType_Type;
     3376    if (PyType_Ready(&FInfo_Type) < 0) return;
     3377    Py_INCREF(&FInfo_Type);
     3378    PyModule_AddObject(m, "FInfo", (PyObject *)&FInfo_Type);
     3379    /* Backward-compatible name */
     3380    Py_INCREF(&FInfo_Type);
     3381    PyModule_AddObject(m, "FInfoType", (PyObject *)&FInfo_Type);
    33823382#endif /* !__LP64__ */
    3383         Alias_Type.ob_type = &PyType_Type;
    3384         if (PyType_Ready(&Alias_Type) < 0) return;
    3385         Py_INCREF(&Alias_Type);
    3386         PyModule_AddObject(m, "Alias", (PyObject *)&Alias_Type);
    3387         /* Backward-compatible name */
    3388         Py_INCREF(&Alias_Type);
    3389         PyModule_AddObject(m, "AliasType", (PyObject *)&Alias_Type);
     3383    Alias_Type.ob_type = &PyType_Type;
     3384    if (PyType_Ready(&Alias_Type) < 0) return;
     3385    Py_INCREF(&Alias_Type);
     3386    PyModule_AddObject(m, "Alias", (PyObject *)&Alias_Type);
     3387    /* Backward-compatible name */
     3388    Py_INCREF(&Alias_Type);
     3389    PyModule_AddObject(m, "AliasType", (PyObject *)&Alias_Type);
    33903390
    33913391#ifndef __LP64__
    3392         FSSpec_Type.ob_type = &PyType_Type;
    3393         if (PyType_Ready(&FSSpec_Type) < 0) return;
    3394         Py_INCREF(&FSSpec_Type);
    3395         PyModule_AddObject(m, "FSSpec", (PyObject *)&FSSpec_Type);
    3396         /* Backward-compatible name */
    3397         Py_INCREF(&FSSpec_Type);
    3398         PyModule_AddObject(m, "FSSpecType", (PyObject *)&FSSpec_Type);
     3392    FSSpec_Type.ob_type = &PyType_Type;
     3393    if (PyType_Ready(&FSSpec_Type) < 0) return;
     3394    Py_INCREF(&FSSpec_Type);
     3395    PyModule_AddObject(m, "FSSpec", (PyObject *)&FSSpec_Type);
     3396    /* Backward-compatible name */
     3397    Py_INCREF(&FSSpec_Type);
     3398    PyModule_AddObject(m, "FSSpecType", (PyObject *)&FSSpec_Type);
    33993399#endif /* !__LP64__ */
    3400         FSRef_Type.ob_type = &PyType_Type;
    3401         if (PyType_Ready(&FSRef_Type) < 0) return;
    3402         Py_INCREF(&FSRef_Type);
    3403         PyModule_AddObject(m, "FSRef", (PyObject *)&FSRef_Type);
    3404         /* Backward-compatible name */
    3405         Py_INCREF(&FSRef_Type);
    3406         PyModule_AddObject(m, "FSRefType", (PyObject *)&FSRef_Type);
     3400    FSRef_Type.ob_type = &PyType_Type;
     3401    if (PyType_Ready(&FSRef_Type) < 0) return;
     3402    Py_INCREF(&FSRef_Type);
     3403    PyModule_AddObject(m, "FSRef", (PyObject *)&FSRef_Type);
     3404    /* Backward-compatible name */
     3405    Py_INCREF(&FSRef_Type);
     3406    PyModule_AddObject(m, "FSRefType", (PyObject *)&FSRef_Type);
    34073407}
    34083408
Note: See TracChangeset for help on using the changeset viewer.