short openappres (ControlHandle c) { /* TODO: check error conditions */ WDPBRec wdpb; short refnum; short resloadval; wdpb.ioVRefNum = (*(item **) (*c)->contrlData)->vrefnum; wdpb.ioWDDirID = (*(item **) (*c)->contrlData)->ioparid; wdpb.ioWDProcID = 0; wdpb.ioNamePtr = 0; PBOpenWD (&wdpb, false); #ifdef THINK_C resloadval = ResLoad; #else resloadval = LMGetResLoad (); #endif SetResLoad (false); refnum = OpenRFPerm ((*c)->contrlTitle, wdpb.ioVRefNum, fsRdPerm); SetResLoad (resloadval); PBCloseWD (&wdpb, false); if (refnum == -1) { /* todo: alert */ } return refnum; }
static PyObject *Res_OpenRFPerm(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; short _rv; Str255 fileName; short vRefNum; SignedByte permission; #ifndef OpenRFPerm PyMac_PRECHECK(OpenRFPerm); #endif if (!PyArg_ParseTuple(_args, "O&hb", PyMac_GetStr255, fileName, &vRefNum, &permission)) return NULL; _rv = OpenRFPerm(fileName, vRefNum, permission); { OSErr _err = ResError(); if (_err != noErr) return PyMac_Error(_err); } _res = Py_BuildValue("h", _rv); return _res; }