| 1 | n/a | |
|---|
| 2 | n/a | /* ========================== Module _File ========================== */ |
|---|
| 3 | n/a | |
|---|
| 4 | n/a | #include "Python.h" |
|---|
| 5 | n/a | |
|---|
| 6 | n/a | |
|---|
| 7 | n/a | |
|---|
| 8 | n/a | #include "pymactoolbox.h" |
|---|
| 9 | n/a | |
|---|
| 10 | n/a | #ifndef HAVE_OSX105_SDK |
|---|
| 11 | n/a | typedef SInt16 FSIORefNum; |
|---|
| 12 | n/a | #endif |
|---|
| 13 | n/a | |
|---|
| 14 | n/a | /* Macro to test whether a weak-loaded CFM function exists */ |
|---|
| 15 | n/a | #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\ |
|---|
| 16 | n/a | PyErr_SetString(PyExc_NotImplementedError, \ |
|---|
| 17 | n/a | "Not available in this shared library/OS version"); \ |
|---|
| 18 | n/a | return NULL; \ |
|---|
| 19 | n/a | }} while(0) |
|---|
| 20 | n/a | |
|---|
| 21 | n/a | |
|---|
| 22 | n/a | #include <Carbon/Carbon.h> |
|---|
| 23 | n/a | |
|---|
| 24 | n/a | #ifdef USE_TOOLBOX_OBJECT_GLUE |
|---|
| 25 | n/a | |
|---|
| 26 | n/a | #ifndef __LP64__ |
|---|
| 27 | n/a | extern int _PyMac_GetFSSpec(PyObject *v, FSSpec *spec); |
|---|
| 28 | n/a | extern PyObject *_PyMac_BuildFSSpec(FSSpec *spec); |
|---|
| 29 | n/a | #define PyMac_BuildFSSpec _PyMac_BuildFSSpec |
|---|
| 30 | n/a | #endif /* __LP64__*/ |
|---|
| 31 | n/a | |
|---|
| 32 | n/a | extern int _PyMac_GetFSRef(PyObject *v, FSRef *fsr); |
|---|
| 33 | n/a | extern PyObject *_PyMac_BuildFSRef(FSRef *spec); |
|---|
| 34 | n/a | #define PyMac_BuildFSRef _PyMac_BuildFSRef |
|---|
| 35 | n/a | #define PyMac_GetFSSpec _PyMac_GetFSSpec |
|---|
| 36 | n/a | #define PyMac_GetFSRef _PyMac_GetFSRef |
|---|
| 37 | n/a | |
|---|
| 38 | n/a | #else /* !USE_TOOLBOX_OBJECT_GLUE */ |
|---|
| 39 | n/a | |
|---|
| 40 | n/a | #ifndef __LP64__ |
|---|
| 41 | n/a | extern int PyMac_GetFSSpec(PyObject *v, FSSpec *spec); |
|---|
| 42 | n/a | extern PyObject *PyMac_BuildFSSpec(FSSpec *spec); |
|---|
| 43 | n/a | #endif /* !__LP64__*/ |
|---|
| 44 | n/a | |
|---|
| 45 | n/a | extern int PyMac_GetFSRef(PyObject *v, FSRef *fsr); |
|---|
| 46 | n/a | extern PyObject *PyMac_BuildFSRef(FSRef *spec); |
|---|
| 47 | n/a | |
|---|
| 48 | n/a | #endif /* !USE_TOOLBOX_OBJECT_GLUE */ |
|---|
| 49 | n/a | |
|---|
| 50 | n/a | /* Forward declarations */ |
|---|
| 51 | n/a | static PyObject *FSRef_New(FSRef *itself); |
|---|
| 52 | n/a | #ifndef __LP64__ |
|---|
| 53 | n/a | static PyObject *FInfo_New(FInfo *itself); |
|---|
| 54 | n/a | |
|---|
| 55 | n/a | static PyObject *FSSpec_New(FSSpec *itself); |
|---|
| 56 | n/a | #define FSSpec_Convert PyMac_GetFSSpec |
|---|
| 57 | n/a | #endif /* !__LP64__ */ |
|---|
| 58 | n/a | |
|---|
| 59 | n/a | static PyObject *Alias_New(AliasHandle itself); |
|---|
| 60 | n/a | #ifndef __LP64__ |
|---|
| 61 | n/a | static int FInfo_Convert(PyObject *v, FInfo *p_itself); |
|---|
| 62 | n/a | #endif /* !__LP64__ */ |
|---|
| 63 | n/a | #define FSRef_Convert PyMac_GetFSRef |
|---|
| 64 | n/a | static int Alias_Convert(PyObject *v, AliasHandle *p_itself); |
|---|
| 65 | n/a | |
|---|
| 66 | n/a | /* |
|---|
| 67 | n/a | ** UTCDateTime records |
|---|
| 68 | n/a | */ |
|---|
| 69 | n/a | static int |
|---|
| 70 | n/a | UTCDateTime_Convert(PyObject *v, UTCDateTime *ptr) |
|---|
| 71 | n/a | { |
|---|
| 72 | n/a | return PyArg_Parse(v, "(HlH)", &ptr->highSeconds, &ptr->lowSeconds, &ptr->fraction); |
|---|
| 73 | n/a | } |
|---|
| 74 | n/a | |
|---|
| 75 | n/a | static PyObject * |
|---|
| 76 | n/a | UTCDateTime_New(UTCDateTime *ptr) |
|---|
| 77 | n/a | { |
|---|
| 78 | n/a | return Py_BuildValue("(HlH)", ptr->highSeconds, ptr->lowSeconds, ptr->fraction); |
|---|
| 79 | n/a | } |
|---|
| 80 | n/a | |
|---|
| 81 | n/a | /* |
|---|
| 82 | n/a | ** Optional fsspec and fsref pointers. None will pass NULL |
|---|
| 83 | n/a | */ |
|---|
| 84 | n/a | #ifndef __LP64__ |
|---|
| 85 | n/a | static int |
|---|
| 86 | n/a | myPyMac_GetOptFSSpecPtr(PyObject *v, FSSpec **spec) |
|---|
| 87 | n/a | { |
|---|
| 88 | n/a | if (v == Py_None) { |
|---|
| 89 | n/a | *spec = NULL; |
|---|
| 90 | n/a | return 1; |
|---|
| 91 | n/a | } |
|---|
| 92 | n/a | return PyMac_GetFSSpec(v, *spec); |
|---|
| 93 | n/a | } |
|---|
| 94 | n/a | #endif /* !__LP64__ */ |
|---|
| 95 | n/a | |
|---|
| 96 | n/a | static int |
|---|
| 97 | n/a | myPyMac_GetOptFSRefPtr(PyObject *v, FSRef **ref) |
|---|
| 98 | n/a | { |
|---|
| 99 | n/a | if (v == Py_None) { |
|---|
| 100 | n/a | *ref = NULL; |
|---|
| 101 | n/a | return 1; |
|---|
| 102 | n/a | } |
|---|
| 103 | n/a | return PyMac_GetFSRef(v, *ref); |
|---|
| 104 | n/a | } |
|---|
| 105 | n/a | |
|---|
| 106 | n/a | /* |
|---|
| 107 | n/a | ** Parse/generate objsect |
|---|
| 108 | n/a | */ |
|---|
| 109 | n/a | static PyObject * |
|---|
| 110 | n/a | PyMac_BuildHFSUniStr255(HFSUniStr255 *itself) |
|---|
| 111 | n/a | { |
|---|
| 112 | n/a | |
|---|
| 113 | n/a | return Py_BuildValue("u#", itself->unicode, itself->length); |
|---|
| 114 | n/a | } |
|---|
| 115 | n/a | |
|---|
| 116 | n/a | #ifndef __LP64__ |
|---|
| 117 | n/a | static OSErr |
|---|
| 118 | n/a | _PyMac_GetFullPathname(FSSpec *fss, char *path, int len) |
|---|
| 119 | n/a | { |
|---|
| 120 | n/a | FSRef fsr; |
|---|
| 121 | n/a | OSErr err; |
|---|
| 122 | n/a | |
|---|
| 123 | n/a | *path = '\0'; |
|---|
| 124 | n/a | err = FSpMakeFSRef(fss, &fsr); |
|---|
| 125 | n/a | if (err == fnfErr) { |
|---|
| 126 | n/a | /* FSSpecs can point to non-existing files, fsrefs can't. */ |
|---|
| 127 | n/a | FSSpec fss2; |
|---|
| 128 | n/a | int tocopy; |
|---|
| 129 | n/a | |
|---|
| 130 | n/a | err = FSMakeFSSpec(fss->vRefNum, fss->parID, |
|---|
| 131 | n/a | (unsigned char*)"", &fss2); |
|---|
| 132 | n/a | if (err) |
|---|
| 133 | n/a | return err; |
|---|
| 134 | n/a | err = FSpMakeFSRef(&fss2, &fsr); |
|---|
| 135 | n/a | if (err) |
|---|
| 136 | n/a | return err; |
|---|
| 137 | n/a | err = (OSErr)FSRefMakePath(&fsr, (unsigned char*)path, len-1); |
|---|
| 138 | n/a | if (err) |
|---|
| 139 | n/a | return err; |
|---|
| 140 | n/a | /* This part is not 100% safe: we append the filename part, but |
|---|
| 141 | n/a | ** I'm not sure that we don't run afoul of the various 8bit |
|---|
| 142 | n/a | ** encodings here. Will have to look this up at some point... |
|---|
| 143 | n/a | */ |
|---|
| 144 | n/a | strcat(path, "/"); |
|---|
| 145 | n/a | tocopy = fss->name[0]; |
|---|
| 146 | n/a | if ((strlen(path) + tocopy) >= len) |
|---|
| 147 | n/a | tocopy = len - strlen(path) - 1; |
|---|
| 148 | n/a | if (tocopy > 0) |
|---|
| 149 | n/a | strncat(path, (char*)fss->name+1, tocopy); |
|---|
| 150 | n/a | } |
|---|
| 151 | n/a | else { |
|---|
| 152 | n/a | if (err) |
|---|
| 153 | n/a | return err; |
|---|
| 154 | n/a | err = (OSErr)FSRefMakePath(&fsr, (unsigned char*)path, len); |
|---|
| 155 | n/a | if (err) |
|---|
| 156 | n/a | return err; |
|---|
| 157 | n/a | } |
|---|
| 158 | n/a | return 0; |
|---|
| 159 | n/a | } |
|---|
| 160 | n/a | #endif /* !__LP64__ */ |
|---|
| 161 | n/a | |
|---|
| 162 | n/a | |
|---|
| 163 | n/a | static PyObject *File_Error; |
|---|
| 164 | n/a | |
|---|
| 165 | n/a | /* ------------------- Object type FSCatalogInfo -------------------- */ |
|---|
| 166 | n/a | |
|---|
| 167 | n/a | static PyTypeObject FSCatalogInfo_Type; |
|---|
| 168 | n/a | |
|---|
| 169 | n/a | #define FSCatalogInfo_Check(x) ((x)->ob_type == &FSCatalogInfo_Type || PyObject_TypeCheck((x), &FSCatalogInfo_Type)) |
|---|
| 170 | n/a | |
|---|
| 171 | n/a | typedef struct FSCatalogInfoObject { |
|---|
| 172 | n/a | PyObject_HEAD |
|---|
| 173 | n/a | FSCatalogInfo ob_itself; |
|---|
| 174 | n/a | } FSCatalogInfoObject; |
|---|
| 175 | n/a | |
|---|
| 176 | n/a | static PyObject *FSCatalogInfo_New(FSCatalogInfo *itself) |
|---|
| 177 | n/a | { |
|---|
| 178 | n/a | FSCatalogInfoObject *it; |
|---|
| 179 | n/a | if (itself == NULL) { Py_INCREF(Py_None); return Py_None; } |
|---|
| 180 | n/a | it = PyObject_NEW(FSCatalogInfoObject, &FSCatalogInfo_Type); |
|---|
| 181 | n/a | if (it == NULL) return NULL; |
|---|
| 182 | n/a | it->ob_itself = *itself; |
|---|
| 183 | n/a | return (PyObject *)it; |
|---|
| 184 | n/a | } |
|---|
| 185 | n/a | |
|---|
| 186 | n/a | static int FSCatalogInfo_Convert(PyObject *v, FSCatalogInfo *p_itself) |
|---|
| 187 | n/a | { |
|---|
| 188 | n/a | if (!FSCatalogInfo_Check(v)) |
|---|
| 189 | n/a | { |
|---|
| 190 | n/a | PyErr_SetString(PyExc_TypeError, "FSCatalogInfo required"); |
|---|
| 191 | n/a | return 0; |
|---|
| 192 | n/a | } |
|---|
| 193 | n/a | *p_itself = ((FSCatalogInfoObject *)v)->ob_itself; |
|---|
| 194 | n/a | return 1; |
|---|
| 195 | n/a | } |
|---|
| 196 | n/a | |
|---|
| 197 | n/a | static void FSCatalogInfo_dealloc(FSCatalogInfoObject *self) |
|---|
| 198 | n/a | { |
|---|
| 199 | n/a | /* Cleanup of self->ob_itself goes here */ |
|---|
| 200 | n/a | self->ob_type->tp_free((PyObject *)self); |
|---|
| 201 | n/a | } |
|---|
| 202 | n/a | |
|---|
| 203 | n/a | static PyMethodDef FSCatalogInfo_methods[] = { |
|---|
| 204 | n/a | {NULL, NULL, 0} |
|---|
| 205 | n/a | }; |
|---|
| 206 | n/a | |
|---|
| 207 | n/a | static PyObject *FSCatalogInfo_get_nodeFlags(FSCatalogInfoObject *self, void *closure) |
|---|
| 208 | n/a | { |
|---|
| 209 | n/a | return Py_BuildValue("H", self->ob_itself.nodeFlags); |
|---|
| 210 | n/a | } |
|---|
| 211 | n/a | |
|---|
| 212 | n/a | static int FSCatalogInfo_set_nodeFlags(FSCatalogInfoObject *self, PyObject *v, void *closure) |
|---|
| 213 | n/a | { |
|---|
| 214 | n/a | return PyArg_Parse(v, "H", &self->ob_itself.nodeFlags)-1; |
|---|
| 215 | n/a | return 0; |
|---|
| 216 | n/a | } |
|---|
| 217 | n/a | |
|---|
| 218 | n/a | static PyObject *FSCatalogInfo_get_volume(FSCatalogInfoObject *self, void *closure) |
|---|
| 219 | n/a | { |
|---|
| 220 | n/a | return Py_BuildValue("h", self->ob_itself.volume); |
|---|
| 221 | n/a | } |
|---|
| 222 | n/a | |
|---|
| 223 | n/a | static int FSCatalogInfo_set_volume(FSCatalogInfoObject *self, PyObject *v, void *closure) |
|---|
| 224 | n/a | { |
|---|
| 225 | n/a | return PyArg_Parse(v, "h", &self->ob_itself.volume)-1; |
|---|
| 226 | n/a | return 0; |
|---|
| 227 | n/a | } |
|---|
| 228 | n/a | |
|---|
| 229 | n/a | static PyObject *FSCatalogInfo_get_parentDirID(FSCatalogInfoObject *self, void *closure) |
|---|
| 230 | n/a | { |
|---|
| 231 | n/a | return Py_BuildValue("l", self->ob_itself.parentDirID); |
|---|
| 232 | n/a | } |
|---|
| 233 | n/a | |
|---|
| 234 | n/a | static int FSCatalogInfo_set_parentDirID(FSCatalogInfoObject *self, PyObject *v, void *closure) |
|---|
| 235 | n/a | { |
|---|
| 236 | n/a | return PyArg_Parse(v, "l", &self->ob_itself.parentDirID)-1; |
|---|
| 237 | n/a | return 0; |
|---|
| 238 | n/a | } |
|---|
| 239 | n/a | |
|---|
| 240 | n/a | static PyObject *FSCatalogInfo_get_nodeID(FSCatalogInfoObject *self, void *closure) |
|---|
| 241 | n/a | { |
|---|
| 242 | n/a | return Py_BuildValue("l", self->ob_itself.nodeID); |
|---|
| 243 | n/a | } |
|---|
| 244 | n/a | |
|---|
| 245 | n/a | static int FSCatalogInfo_set_nodeID(FSCatalogInfoObject *self, PyObject *v, void *closure) |
|---|
| 246 | n/a | { |
|---|
| 247 | n/a | return PyArg_Parse(v, "l", &self->ob_itself.nodeID)-1; |
|---|
| 248 | n/a | return 0; |
|---|
| 249 | n/a | } |
|---|
| 250 | n/a | |
|---|
| 251 | n/a | static PyObject *FSCatalogInfo_get_createDate(FSCatalogInfoObject *self, void *closure) |
|---|
| 252 | n/a | { |
|---|
| 253 | n/a | return Py_BuildValue("O&", UTCDateTime_New, &self->ob_itself.createDate); |
|---|
| 254 | n/a | } |
|---|
| 255 | n/a | |
|---|
| 256 | n/a | static int FSCatalogInfo_set_createDate(FSCatalogInfoObject *self, PyObject *v, void *closure) |
|---|
| 257 | n/a | { |
|---|
| 258 | n/a | return PyArg_Parse(v, "O&", UTCDateTime_Convert, &self->ob_itself.createDate)-1; |
|---|
| 259 | n/a | return 0; |
|---|
| 260 | n/a | } |
|---|
| 261 | n/a | |
|---|
| 262 | n/a | static PyObject *FSCatalogInfo_get_contentModDate(FSCatalogInfoObject *self, void *closure) |
|---|
| 263 | n/a | { |
|---|
| 264 | n/a | return Py_BuildValue("O&", UTCDateTime_New, &self->ob_itself.contentModDate); |
|---|
| 265 | n/a | } |
|---|
| 266 | n/a | |
|---|
| 267 | n/a | static int FSCatalogInfo_set_contentModDate(FSCatalogInfoObject *self, PyObject *v, void *closure) |
|---|
| 268 | n/a | { |
|---|
| 269 | n/a | return PyArg_Parse(v, "O&", UTCDateTime_Convert, &self->ob_itself.contentModDate)-1; |
|---|
| 270 | n/a | return 0; |
|---|
| 271 | n/a | } |
|---|
| 272 | n/a | |
|---|
| 273 | n/a | static PyObject *FSCatalogInfo_get_attributeModDate(FSCatalogInfoObject *self, void *closure) |
|---|
| 274 | n/a | { |
|---|
| 275 | n/a | return Py_BuildValue("O&", UTCDateTime_New, &self->ob_itself.attributeModDate); |
|---|
| 276 | n/a | } |
|---|
| 277 | n/a | |
|---|
| 278 | n/a | static int FSCatalogInfo_set_attributeModDate(FSCatalogInfoObject *self, PyObject *v, void *closure) |
|---|
| 279 | n/a | { |
|---|
| 280 | n/a | return PyArg_Parse(v, "O&", UTCDateTime_Convert, &self->ob_itself.attributeModDate)-1; |
|---|
| 281 | n/a | return 0; |
|---|
| 282 | n/a | } |
|---|
| 283 | n/a | |
|---|
| 284 | n/a | static PyObject *FSCatalogInfo_get_accessDate(FSCatalogInfoObject *self, void *closure) |
|---|
| 285 | n/a | { |
|---|
| 286 | n/a | return Py_BuildValue("O&", UTCDateTime_New, &self->ob_itself.accessDate); |
|---|
| 287 | n/a | } |
|---|
| 288 | n/a | |
|---|
| 289 | n/a | static int FSCatalogInfo_set_accessDate(FSCatalogInfoObject *self, PyObject *v, void *closure) |
|---|
| 290 | n/a | { |
|---|
| 291 | n/a | return PyArg_Parse(v, "O&", UTCDateTime_Convert, &self->ob_itself.accessDate)-1; |
|---|
| 292 | n/a | return 0; |
|---|
| 293 | n/a | } |
|---|
| 294 | n/a | |
|---|
| 295 | n/a | static PyObject *FSCatalogInfo_get_backupDate(FSCatalogInfoObject *self, void *closure) |
|---|
| 296 | n/a | { |
|---|
| 297 | n/a | return Py_BuildValue("O&", UTCDateTime_New, &self->ob_itself.backupDate); |
|---|
| 298 | n/a | } |
|---|
| 299 | n/a | |
|---|
| 300 | n/a | static int FSCatalogInfo_set_backupDate(FSCatalogInfoObject *self, PyObject *v, void *closure) |
|---|
| 301 | n/a | { |
|---|
| 302 | n/a | return PyArg_Parse(v, "O&", UTCDateTime_Convert, &self->ob_itself.backupDate)-1; |
|---|
| 303 | n/a | return 0; |
|---|
| 304 | n/a | } |
|---|
| 305 | n/a | |
|---|
| 306 | n/a | static PyObject *FSCatalogInfo_get_permissions(FSCatalogInfoObject *self, void *closure) |
|---|
| 307 | n/a | { |
|---|
| 308 | n/a | FSPermissionInfo* info = (FSPermissionInfo*)&(self->ob_itself.permissions); |
|---|
| 309 | n/a | return Py_BuildValue("(llll)", info->userID, info->groupID, info->userAccess, info->mode); |
|---|
| 310 | n/a | } |
|---|
| 311 | n/a | |
|---|
| 312 | n/a | static int FSCatalogInfo_set_permissions(FSCatalogInfoObject *self, PyObject *v, void *closure) |
|---|
| 313 | n/a | { |
|---|
| 314 | n/a | long userID; |
|---|
| 315 | n/a | long groupID; |
|---|
| 316 | n/a | long userAccess; |
|---|
| 317 | n/a | long mode; |
|---|
| 318 | n/a | int r; |
|---|
| 319 | n/a | |
|---|
| 320 | n/a | FSPermissionInfo* info = (FSPermissionInfo*)&(self->ob_itself.permissions); |
|---|
| 321 | n/a | |
|---|
| 322 | n/a | r = PyArg_Parse(v, "(llll)", &userID, &groupID, &userAccess, &mode); |
|---|
| 323 | n/a | if (!r) { |
|---|
| 324 | n/a | return -1; |
|---|
| 325 | n/a | } |
|---|
| 326 | n/a | info->userID = userID; |
|---|
| 327 | n/a | info->groupID = groupID; |
|---|
| 328 | n/a | info->userAccess = userAccess; |
|---|
| 329 | n/a | info->mode = mode; |
|---|
| 330 | n/a | return 0; |
|---|
| 331 | n/a | } |
|---|
| 332 | n/a | |
|---|
| 333 | n/a | static PyObject *FSCatalogInfo_get_valence(FSCatalogInfoObject *self, void *closure) |
|---|
| 334 | n/a | { |
|---|
| 335 | n/a | return Py_BuildValue("l", self->ob_itself.valence); |
|---|
| 336 | n/a | } |
|---|
| 337 | n/a | |
|---|
| 338 | n/a | static int FSCatalogInfo_set_valence(FSCatalogInfoObject *self, PyObject *v, void *closure) |
|---|
| 339 | n/a | { |
|---|
| 340 | n/a | return PyArg_Parse(v, "l", &self->ob_itself.valence)-1; |
|---|
| 341 | n/a | return 0; |
|---|
| 342 | n/a | } |
|---|
| 343 | n/a | |
|---|
| 344 | n/a | static PyObject *FSCatalogInfo_get_dataLogicalSize(FSCatalogInfoObject *self, void *closure) |
|---|
| 345 | n/a | { |
|---|
| 346 | n/a | return Py_BuildValue("l", self->ob_itself.dataLogicalSize); |
|---|
| 347 | n/a | } |
|---|
| 348 | n/a | |
|---|
| 349 | n/a | static int FSCatalogInfo_set_dataLogicalSize(FSCatalogInfoObject *self, PyObject *v, void *closure) |
|---|
| 350 | n/a | { |
|---|
| 351 | n/a | return PyArg_Parse(v, "l", &self->ob_itself.dataLogicalSize)-1; |
|---|
| 352 | n/a | return 0; |
|---|
| 353 | n/a | } |
|---|
| 354 | n/a | |
|---|
| 355 | n/a | static PyObject *FSCatalogInfo_get_dataPhysicalSize(FSCatalogInfoObject *self, void *closure) |
|---|
| 356 | n/a | { |
|---|
| 357 | n/a | return Py_BuildValue("l", self->ob_itself.dataPhysicalSize); |
|---|
| 358 | n/a | } |
|---|
| 359 | n/a | |
|---|
| 360 | n/a | static int FSCatalogInfo_set_dataPhysicalSize(FSCatalogInfoObject *self, PyObject *v, void *closure) |
|---|
| 361 | n/a | { |
|---|
| 362 | n/a | return PyArg_Parse(v, "l", &self->ob_itself.dataPhysicalSize)-1; |
|---|
| 363 | n/a | return 0; |
|---|
| 364 | n/a | } |
|---|
| 365 | n/a | |
|---|
| 366 | n/a | static PyObject *FSCatalogInfo_get_rsrcLogicalSize(FSCatalogInfoObject *self, void *closure) |
|---|
| 367 | n/a | { |
|---|
| 368 | n/a | return Py_BuildValue("l", self->ob_itself.rsrcLogicalSize); |
|---|
| 369 | n/a | } |
|---|
| 370 | n/a | |
|---|
| 371 | n/a | static int FSCatalogInfo_set_rsrcLogicalSize(FSCatalogInfoObject *self, PyObject *v, void *closure) |
|---|
| 372 | n/a | { |
|---|
| 373 | n/a | return PyArg_Parse(v, "l", &self->ob_itself.rsrcLogicalSize)-1; |
|---|
| 374 | n/a | return 0; |
|---|
| 375 | n/a | } |
|---|
| 376 | n/a | |
|---|
| 377 | n/a | static PyObject *FSCatalogInfo_get_rsrcPhysicalSize(FSCatalogInfoObject *self, void *closure) |
|---|
| 378 | n/a | { |
|---|
| 379 | n/a | return Py_BuildValue("l", self->ob_itself.rsrcPhysicalSize); |
|---|
| 380 | n/a | } |
|---|
| 381 | n/a | |
|---|
| 382 | n/a | static int FSCatalogInfo_set_rsrcPhysicalSize(FSCatalogInfoObject *self, PyObject *v, void *closure) |
|---|
| 383 | n/a | { |
|---|
| 384 | n/a | return PyArg_Parse(v, "l", &self->ob_itself.rsrcPhysicalSize)-1; |
|---|
| 385 | n/a | return 0; |
|---|
| 386 | n/a | } |
|---|
| 387 | n/a | |
|---|
| 388 | n/a | static PyObject *FSCatalogInfo_get_sharingFlags(FSCatalogInfoObject *self, void *closure) |
|---|
| 389 | n/a | { |
|---|
| 390 | n/a | return Py_BuildValue("l", self->ob_itself.sharingFlags); |
|---|
| 391 | n/a | } |
|---|
| 392 | n/a | |
|---|
| 393 | n/a | static int FSCatalogInfo_set_sharingFlags(FSCatalogInfoObject *self, PyObject *v, void *closure) |
|---|
| 394 | n/a | { |
|---|
| 395 | n/a | return PyArg_Parse(v, "l", &self->ob_itself.sharingFlags)-1; |
|---|
| 396 | n/a | return 0; |
|---|
| 397 | n/a | } |
|---|
| 398 | n/a | |
|---|
| 399 | n/a | static PyObject *FSCatalogInfo_get_userPrivileges(FSCatalogInfoObject *self, void *closure) |
|---|
| 400 | n/a | { |
|---|
| 401 | n/a | return Py_BuildValue("b", self->ob_itself.userPrivileges); |
|---|
| 402 | n/a | } |
|---|
| 403 | n/a | |
|---|
| 404 | n/a | static int FSCatalogInfo_set_userPrivileges(FSCatalogInfoObject *self, PyObject *v, void *closure) |
|---|
| 405 | n/a | { |
|---|
| 406 | n/a | return PyArg_Parse(v, "b", &self->ob_itself.userPrivileges)-1; |
|---|
| 407 | n/a | return 0; |
|---|
| 408 | n/a | } |
|---|
| 409 | n/a | |
|---|
| 410 | n/a | static PyGetSetDef FSCatalogInfo_getsetlist[] = { |
|---|
| 411 | n/a | {"nodeFlags", (getter)FSCatalogInfo_get_nodeFlags, (setter)FSCatalogInfo_set_nodeFlags, NULL}, |
|---|
| 412 | n/a | {"volume", (getter)FSCatalogInfo_get_volume, (setter)FSCatalogInfo_set_volume, NULL}, |
|---|
| 413 | n/a | {"parentDirID", (getter)FSCatalogInfo_get_parentDirID, (setter)FSCatalogInfo_set_parentDirID, NULL}, |
|---|
| 414 | n/a | {"nodeID", (getter)FSCatalogInfo_get_nodeID, (setter)FSCatalogInfo_set_nodeID, NULL}, |
|---|
| 415 | n/a | {"createDate", (getter)FSCatalogInfo_get_createDate, (setter)FSCatalogInfo_set_createDate, NULL}, |
|---|
| 416 | n/a | {"contentModDate", (getter)FSCatalogInfo_get_contentModDate, (setter)FSCatalogInfo_set_contentModDate, NULL}, |
|---|
| 417 | n/a | {"attributeModDate", (getter)FSCatalogInfo_get_attributeModDate, (setter)FSCatalogInfo_set_attributeModDate, NULL}, |
|---|
| 418 | n/a | {"accessDate", (getter)FSCatalogInfo_get_accessDate, (setter)FSCatalogInfo_set_accessDate, NULL}, |
|---|
| 419 | n/a | {"backupDate", (getter)FSCatalogInfo_get_backupDate, (setter)FSCatalogInfo_set_backupDate, NULL}, |
|---|
| 420 | n/a | {"permissions", (getter)FSCatalogInfo_get_permissions, (setter)FSCatalogInfo_set_permissions, NULL}, |
|---|
| 421 | n/a | {"valence", (getter)FSCatalogInfo_get_valence, (setter)FSCatalogInfo_set_valence, NULL}, |
|---|
| 422 | n/a | {"dataLogicalSize", (getter)FSCatalogInfo_get_dataLogicalSize, (setter)FSCatalogInfo_set_dataLogicalSize, NULL}, |
|---|
| 423 | n/a | {"dataPhysicalSize", (getter)FSCatalogInfo_get_dataPhysicalSize, (setter)FSCatalogInfo_set_dataPhysicalSize, NULL}, |
|---|
| 424 | n/a | {"rsrcLogicalSize", (getter)FSCatalogInfo_get_rsrcLogicalSize, (setter)FSCatalogInfo_set_rsrcLogicalSize, NULL}, |
|---|
| 425 | n/a | {"rsrcPhysicalSize", (getter)FSCatalogInfo_get_rsrcPhysicalSize, (setter)FSCatalogInfo_set_rsrcPhysicalSize, NULL}, |
|---|
| 426 | n/a | {"sharingFlags", (getter)FSCatalogInfo_get_sharingFlags, (setter)FSCatalogInfo_set_sharingFlags, NULL}, |
|---|
| 427 | n/a | {"userPrivileges", (getter)FSCatalogInfo_get_userPrivileges, (setter)FSCatalogInfo_set_userPrivileges, NULL}, |
|---|
| 428 | n/a | {NULL, NULL, NULL, NULL}, |
|---|
| 429 | n/a | }; |
|---|
| 430 | n/a | |
|---|
| 431 | n/a | |
|---|
| 432 | n/a | #define FSCatalogInfo_compare NULL |
|---|
| 433 | n/a | |
|---|
| 434 | n/a | #define FSCatalogInfo_repr NULL |
|---|
| 435 | n/a | |
|---|
| 436 | n/a | #define FSCatalogInfo_hash NULL |
|---|
| 437 | n/a | static int FSCatalogInfo_tp_init(PyObject *_self, PyObject *_args, PyObject *_kwds) |
|---|
| 438 | n/a | { |
|---|
| 439 | n/a | static char *kw[] = { |
|---|
| 440 | n/a | "nodeFlags", |
|---|
| 441 | n/a | "volume", |
|---|
| 442 | n/a | "parentDirID", |
|---|
| 443 | n/a | "nodeID", |
|---|
| 444 | n/a | "createDate", |
|---|
| 445 | n/a | "contentModDate", |
|---|
| 446 | n/a | "atributeModDate", |
|---|
| 447 | n/a | "accessDate", |
|---|
| 448 | n/a | "backupDate", |
|---|
| 449 | n/a | "valence", |
|---|
| 450 | n/a | "dataLogicalSize", |
|---|
| 451 | n/a | "dataPhysicalSize", |
|---|
| 452 | n/a | "rsrcLogicalSize", |
|---|
| 453 | n/a | "rsrcPhysicalSize", |
|---|
| 454 | n/a | "sharingFlags", |
|---|
| 455 | n/a | "userPrivileges" |
|---|
| 456 | n/a | , 0}; |
|---|
| 457 | n/a | |
|---|
| 458 | n/a | if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "|HhllO&O&O&O&O&llllllb", kw, &((FSCatalogInfoObject *)_self)->ob_itself.nodeFlags, |
|---|
| 459 | n/a | &((FSCatalogInfoObject *)_self)->ob_itself.volume, |
|---|
| 460 | n/a | &((FSCatalogInfoObject *)_self)->ob_itself.parentDirID, |
|---|
| 461 | n/a | &((FSCatalogInfoObject *)_self)->ob_itself.nodeID, |
|---|
| 462 | n/a | UTCDateTime_Convert, &((FSCatalogInfoObject *)_self)->ob_itself.createDate, |
|---|
| 463 | n/a | UTCDateTime_Convert, &((FSCatalogInfoObject *)_self)->ob_itself.contentModDate, |
|---|
| 464 | n/a | UTCDateTime_Convert, &((FSCatalogInfoObject *)_self)->ob_itself.attributeModDate, |
|---|
| 465 | n/a | UTCDateTime_Convert, &((FSCatalogInfoObject *)_self)->ob_itself.accessDate, |
|---|
| 466 | n/a | UTCDateTime_Convert, &((FSCatalogInfoObject *)_self)->ob_itself.backupDate, |
|---|
| 467 | n/a | &((FSCatalogInfoObject *)_self)->ob_itself.valence, |
|---|
| 468 | n/a | &((FSCatalogInfoObject *)_self)->ob_itself.dataLogicalSize, |
|---|
| 469 | n/a | &((FSCatalogInfoObject *)_self)->ob_itself.dataPhysicalSize, |
|---|
| 470 | n/a | &((FSCatalogInfoObject *)_self)->ob_itself.rsrcLogicalSize, |
|---|
| 471 | n/a | &((FSCatalogInfoObject *)_self)->ob_itself.rsrcPhysicalSize, |
|---|
| 472 | n/a | &((FSCatalogInfoObject *)_self)->ob_itself.sharingFlags, |
|---|
| 473 | n/a | &((FSCatalogInfoObject *)_self)->ob_itself.userPrivileges)) |
|---|
| 474 | n/a | { |
|---|
| 475 | n/a | return -1; |
|---|
| 476 | n/a | } |
|---|
| 477 | n/a | return 0; |
|---|
| 478 | n/a | } |
|---|
| 479 | n/a | |
|---|
| 480 | n/a | #define FSCatalogInfo_tp_alloc PyType_GenericAlloc |
|---|
| 481 | n/a | |
|---|
| 482 | n/a | static PyObject *FSCatalogInfo_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) |
|---|
| 483 | n/a | { |
|---|
| 484 | n/a | PyObject *self; |
|---|
| 485 | n/a | |
|---|
| 486 | n/a | if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; |
|---|
| 487 | n/a | memset(&((FSCatalogInfoObject *)self)->ob_itself, 0, sizeof(FSCatalogInfo)); |
|---|
| 488 | n/a | return self; |
|---|
| 489 | n/a | } |
|---|
| 490 | n/a | |
|---|
| 491 | n/a | #define FSCatalogInfo_tp_free PyObject_Del |
|---|
| 492 | n/a | |
|---|
| 493 | n/a | |
|---|
| 494 | n/a | static PyTypeObject FSCatalogInfo_Type = { |
|---|
| 495 | n/a | PyObject_HEAD_INIT(NULL) |
|---|
| 496 | n/a | 0, /*ob_size*/ |
|---|
| 497 | n/a | "Carbon.File.FSCatalogInfo", /*tp_name*/ |
|---|
| 498 | n/a | sizeof(FSCatalogInfoObject), /*tp_basicsize*/ |
|---|
| 499 | n/a | 0, /*tp_itemsize*/ |
|---|
| 500 | n/a | /* methods */ |
|---|
| 501 | n/a | (destructor) FSCatalogInfo_dealloc, /*tp_dealloc*/ |
|---|
| 502 | n/a | 0, /*tp_print*/ |
|---|
| 503 | n/a | (getattrfunc)0, /*tp_getattr*/ |
|---|
| 504 | n/a | (setattrfunc)0, /*tp_setattr*/ |
|---|
| 505 | n/a | (cmpfunc) FSCatalogInfo_compare, /*tp_compare*/ |
|---|
| 506 | n/a | (reprfunc) FSCatalogInfo_repr, /*tp_repr*/ |
|---|
| 507 | n/a | (PyNumberMethods *)0, /* tp_as_number */ |
|---|
| 508 | n/a | (PySequenceMethods *)0, /* tp_as_sequence */ |
|---|
| 509 | n/a | (PyMappingMethods *)0, /* tp_as_mapping */ |
|---|
| 510 | n/a | (hashfunc) FSCatalogInfo_hash, /*tp_hash*/ |
|---|
| 511 | n/a | 0, /*tp_call*/ |
|---|
| 512 | n/a | 0, /*tp_str*/ |
|---|
| 513 | n/a | PyObject_GenericGetAttr, /*tp_getattro*/ |
|---|
| 514 | n/a | PyObject_GenericSetAttr, /*tp_setattro */ |
|---|
| 515 | n/a | 0, /*tp_as_buffer*/ |
|---|
| 516 | n/a | Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */ |
|---|
| 517 | n/a | 0, /*tp_doc*/ |
|---|
| 518 | n/a | 0, /*tp_traverse*/ |
|---|
| 519 | n/a | 0, /*tp_clear*/ |
|---|
| 520 | n/a | 0, /*tp_richcompare*/ |
|---|
| 521 | n/a | 0, /*tp_weaklistoffset*/ |
|---|
| 522 | n/a | 0, /*tp_iter*/ |
|---|
| 523 | n/a | 0, /*tp_iternext*/ |
|---|
| 524 | n/a | FSCatalogInfo_methods, /* tp_methods */ |
|---|
| 525 | n/a | 0, /*tp_members*/ |
|---|
| 526 | n/a | FSCatalogInfo_getsetlist, /*tp_getset*/ |
|---|
| 527 | n/a | 0, /*tp_base*/ |
|---|
| 528 | n/a | 0, /*tp_dict*/ |
|---|
| 529 | n/a | 0, /*tp_descr_get*/ |
|---|
| 530 | n/a | 0, /*tp_descr_set*/ |
|---|
| 531 | n/a | 0, /*tp_dictoffset*/ |
|---|
| 532 | n/a | FSCatalogInfo_tp_init, /* tp_init */ |
|---|
| 533 | n/a | FSCatalogInfo_tp_alloc, /* tp_alloc */ |
|---|
| 534 | n/a | FSCatalogInfo_tp_new, /* tp_new */ |
|---|
| 535 | n/a | FSCatalogInfo_tp_free, /* tp_free */ |
|---|
| 536 | n/a | }; |
|---|
| 537 | n/a | |
|---|
| 538 | n/a | /* ----------------- End object type FSCatalogInfo ------------------ */ |
|---|
| 539 | n/a | |
|---|
| 540 | n/a | |
|---|
| 541 | n/a | /* ----------------------- Object type FInfo ------------------------ */ |
|---|
| 542 | n/a | |
|---|
| 543 | n/a | #ifndef __LP64__ |
|---|
| 544 | n/a | |
|---|
| 545 | n/a | static PyTypeObject FInfo_Type; |
|---|
| 546 | n/a | |
|---|
| 547 | n/a | #define FInfo_Check(x) ((x)->ob_type == &FInfo_Type || PyObject_TypeCheck((x), &FInfo_Type)) |
|---|
| 548 | n/a | |
|---|
| 549 | n/a | typedef struct FInfoObject { |
|---|
| 550 | n/a | PyObject_HEAD |
|---|
| 551 | n/a | FInfo ob_itself; |
|---|
| 552 | n/a | } FInfoObject; |
|---|
| 553 | n/a | |
|---|
| 554 | n/a | static PyObject *FInfo_New(FInfo *itself) |
|---|
| 555 | n/a | { |
|---|
| 556 | n/a | FInfoObject *it; |
|---|
| 557 | n/a | if (itself == NULL) return PyMac_Error(resNotFound); |
|---|
| 558 | n/a | it = PyObject_NEW(FInfoObject, &FInfo_Type); |
|---|
| 559 | n/a | if (it == NULL) return NULL; |
|---|
| 560 | n/a | it->ob_itself = *itself; |
|---|
| 561 | n/a | return (PyObject *)it; |
|---|
| 562 | n/a | } |
|---|
| 563 | n/a | |
|---|
| 564 | n/a | static int FInfo_Convert(PyObject *v, FInfo *p_itself) |
|---|
| 565 | n/a | { |
|---|
| 566 | n/a | if (!FInfo_Check(v)) |
|---|
| 567 | n/a | { |
|---|
| 568 | n/a | PyErr_SetString(PyExc_TypeError, "FInfo required"); |
|---|
| 569 | n/a | return 0; |
|---|
| 570 | n/a | } |
|---|
| 571 | n/a | *p_itself = ((FInfoObject *)v)->ob_itself; |
|---|
| 572 | n/a | return 1; |
|---|
| 573 | n/a | } |
|---|
| 574 | n/a | |
|---|
| 575 | n/a | static void FInfo_dealloc(FInfoObject *self) |
|---|
| 576 | n/a | { |
|---|
| 577 | n/a | /* Cleanup of self->ob_itself goes here */ |
|---|
| 578 | n/a | self->ob_type->tp_free((PyObject *)self); |
|---|
| 579 | n/a | } |
|---|
| 580 | n/a | |
|---|
| 581 | n/a | static PyMethodDef FInfo_methods[] = { |
|---|
| 582 | n/a | {NULL, NULL, 0} |
|---|
| 583 | n/a | }; |
|---|
| 584 | n/a | |
|---|
| 585 | n/a | static PyObject *FInfo_get_Type(FInfoObject *self, void *closure) |
|---|
| 586 | n/a | { |
|---|
| 587 | n/a | return Py_BuildValue("O&", PyMac_BuildOSType, self->ob_itself.fdType); |
|---|
| 588 | n/a | } |
|---|
| 589 | n/a | |
|---|
| 590 | n/a | static int FInfo_set_Type(FInfoObject *self, PyObject *v, void *closure) |
|---|
| 591 | n/a | { |
|---|
| 592 | n/a | return PyArg_Parse(v, "O&", PyMac_GetOSType, &self->ob_itself.fdType)-1; |
|---|
| 593 | n/a | return 0; |
|---|
| 594 | n/a | } |
|---|
| 595 | n/a | |
|---|
| 596 | n/a | static PyObject *FInfo_get_Creator(FInfoObject *self, void *closure) |
|---|
| 597 | n/a | { |
|---|
| 598 | n/a | return Py_BuildValue("O&", PyMac_BuildOSType, self->ob_itself.fdCreator); |
|---|
| 599 | n/a | } |
|---|
| 600 | n/a | |
|---|
| 601 | n/a | static int FInfo_set_Creator(FInfoObject *self, PyObject *v, void *closure) |
|---|
| 602 | n/a | { |
|---|
| 603 | n/a | return PyArg_Parse(v, "O&", PyMac_GetOSType, &self->ob_itself.fdCreator)-1; |
|---|
| 604 | n/a | return 0; |
|---|
| 605 | n/a | } |
|---|
| 606 | n/a | |
|---|
| 607 | n/a | static PyObject *FInfo_get_Flags(FInfoObject *self, void *closure) |
|---|
| 608 | n/a | { |
|---|
| 609 | n/a | return Py_BuildValue("H", self->ob_itself.fdFlags); |
|---|
| 610 | n/a | } |
|---|
| 611 | n/a | |
|---|
| 612 | n/a | static int FInfo_set_Flags(FInfoObject *self, PyObject *v, void *closure) |
|---|
| 613 | n/a | { |
|---|
| 614 | n/a | return PyArg_Parse(v, "H", &self->ob_itself.fdFlags)-1; |
|---|
| 615 | n/a | return 0; |
|---|
| 616 | n/a | } |
|---|
| 617 | n/a | |
|---|
| 618 | n/a | static PyObject *FInfo_get_Location(FInfoObject *self, void *closure) |
|---|
| 619 | n/a | { |
|---|
| 620 | n/a | return Py_BuildValue("O&", PyMac_BuildPoint, self->ob_itself.fdLocation); |
|---|
| 621 | n/a | } |
|---|
| 622 | n/a | |
|---|
| 623 | n/a | static int FInfo_set_Location(FInfoObject *self, PyObject *v, void *closure) |
|---|
| 624 | n/a | { |
|---|
| 625 | n/a | return PyArg_Parse(v, "O&", PyMac_GetPoint, &self->ob_itself.fdLocation)-1; |
|---|
| 626 | n/a | return 0; |
|---|
| 627 | n/a | } |
|---|
| 628 | n/a | |
|---|
| 629 | n/a | static PyObject *FInfo_get_Fldr(FInfoObject *self, void *closure) |
|---|
| 630 | n/a | { |
|---|
| 631 | n/a | return Py_BuildValue("h", self->ob_itself.fdFldr); |
|---|
| 632 | n/a | } |
|---|
| 633 | n/a | |
|---|
| 634 | n/a | static int FInfo_set_Fldr(FInfoObject *self, PyObject *v, void *closure) |
|---|
| 635 | n/a | { |
|---|
| 636 | n/a | return PyArg_Parse(v, "h", &self->ob_itself.fdFldr)-1; |
|---|
| 637 | n/a | return 0; |
|---|
| 638 | n/a | } |
|---|
| 639 | n/a | |
|---|
| 640 | n/a | static PyGetSetDef FInfo_getsetlist[] = { |
|---|
| 641 | n/a | {"Type", (getter)FInfo_get_Type, (setter)FInfo_set_Type, "4-char file type"}, |
|---|
| 642 | n/a | {"Creator", (getter)FInfo_get_Creator, (setter)FInfo_set_Creator, "4-char file creator"}, |
|---|
| 643 | n/a | {"Flags", (getter)FInfo_get_Flags, (setter)FInfo_set_Flags, "Finder flag bits"}, |
|---|
| 644 | n/a | {"Location", (getter)FInfo_get_Location, (setter)FInfo_set_Location, "(x, y) location of the file's icon in its parent finder window"}, |
|---|
| 645 | n/a | {"Fldr", (getter)FInfo_get_Fldr, (setter)FInfo_set_Fldr, "Original folder, for 'put away'"}, |
|---|
| 646 | n/a | {NULL, NULL, NULL, NULL}, |
|---|
| 647 | n/a | }; |
|---|
| 648 | n/a | |
|---|
| 649 | n/a | |
|---|
| 650 | n/a | #define FInfo_compare NULL |
|---|
| 651 | n/a | |
|---|
| 652 | n/a | #define FInfo_repr NULL |
|---|
| 653 | n/a | |
|---|
| 654 | n/a | #define FInfo_hash NULL |
|---|
| 655 | n/a | static int FInfo_tp_init(PyObject *_self, PyObject *_args, PyObject *_kwds) |
|---|
| 656 | n/a | { |
|---|
| 657 | n/a | FInfo *itself = NULL; |
|---|
| 658 | n/a | static char *kw[] = {"itself", 0}; |
|---|
| 659 | n/a | |
|---|
| 660 | n/a | if (PyArg_ParseTupleAndKeywords(_args, _kwds, "|O&", kw, FInfo_Convert, &itself)) |
|---|
| 661 | n/a | { |
|---|
| 662 | n/a | if (itself) memcpy(&((FInfoObject *)_self)->ob_itself, itself, sizeof(FInfo)); |
|---|
| 663 | n/a | return 0; |
|---|
| 664 | n/a | } |
|---|
| 665 | n/a | return -1; |
|---|
| 666 | n/a | } |
|---|
| 667 | n/a | |
|---|
| 668 | n/a | #define FInfo_tp_alloc PyType_GenericAlloc |
|---|
| 669 | n/a | |
|---|
| 670 | n/a | static PyObject *FInfo_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) |
|---|
| 671 | n/a | { |
|---|
| 672 | n/a | PyObject *self; |
|---|
| 673 | n/a | |
|---|
| 674 | n/a | if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; |
|---|
| 675 | n/a | memset(&((FInfoObject *)self)->ob_itself, 0, sizeof(FInfo)); |
|---|
| 676 | n/a | return self; |
|---|
| 677 | n/a | } |
|---|
| 678 | n/a | |
|---|
| 679 | n/a | #define FInfo_tp_free PyObject_Del |
|---|
| 680 | n/a | |
|---|
| 681 | n/a | |
|---|
| 682 | n/a | static PyTypeObject FInfo_Type = { |
|---|
| 683 | n/a | PyObject_HEAD_INIT(NULL) |
|---|
| 684 | n/a | 0, /*ob_size*/ |
|---|
| 685 | n/a | "Carbon.File.FInfo", /*tp_name*/ |
|---|
| 686 | n/a | sizeof(FInfoObject), /*tp_basicsize*/ |
|---|
| 687 | n/a | 0, /*tp_itemsize*/ |
|---|
| 688 | n/a | /* methods */ |
|---|
| 689 | n/a | (destructor) FInfo_dealloc, /*tp_dealloc*/ |
|---|
| 690 | n/a | 0, /*tp_print*/ |
|---|
| 691 | n/a | (getattrfunc)0, /*tp_getattr*/ |
|---|
| 692 | n/a | (setattrfunc)0, /*tp_setattr*/ |
|---|
| 693 | n/a | (cmpfunc) FInfo_compare, /*tp_compare*/ |
|---|
| 694 | n/a | (reprfunc) FInfo_repr, /*tp_repr*/ |
|---|
| 695 | n/a | (PyNumberMethods *)0, /* tp_as_number */ |
|---|
| 696 | n/a | (PySequenceMethods *)0, /* tp_as_sequence */ |
|---|
| 697 | n/a | (PyMappingMethods *)0, /* tp_as_mapping */ |
|---|
| 698 | n/a | (hashfunc) FInfo_hash, /*tp_hash*/ |
|---|
| 699 | n/a | 0, /*tp_call*/ |
|---|
| 700 | n/a | 0, /*tp_str*/ |
|---|
| 701 | n/a | PyObject_GenericGetAttr, /*tp_getattro*/ |
|---|
| 702 | n/a | PyObject_GenericSetAttr, /*tp_setattro */ |
|---|
| 703 | n/a | 0, /*tp_as_buffer*/ |
|---|
| 704 | n/a | Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */ |
|---|
| 705 | n/a | 0, /*tp_doc*/ |
|---|
| 706 | n/a | 0, /*tp_traverse*/ |
|---|
| 707 | n/a | 0, /*tp_clear*/ |
|---|
| 708 | n/a | 0, /*tp_richcompare*/ |
|---|
| 709 | n/a | 0, /*tp_weaklistoffset*/ |
|---|
| 710 | n/a | 0, /*tp_iter*/ |
|---|
| 711 | n/a | 0, /*tp_iternext*/ |
|---|
| 712 | n/a | FInfo_methods, /* tp_methods */ |
|---|
| 713 | n/a | 0, /*tp_members*/ |
|---|
| 714 | n/a | FInfo_getsetlist, /*tp_getset*/ |
|---|
| 715 | n/a | 0, /*tp_base*/ |
|---|
| 716 | n/a | 0, /*tp_dict*/ |
|---|
| 717 | n/a | 0, /*tp_descr_get*/ |
|---|
| 718 | n/a | 0, /*tp_descr_set*/ |
|---|
| 719 | n/a | 0, /*tp_dictoffset*/ |
|---|
| 720 | n/a | FInfo_tp_init, /* tp_init */ |
|---|
| 721 | n/a | FInfo_tp_alloc, /* tp_alloc */ |
|---|
| 722 | n/a | FInfo_tp_new, /* tp_new */ |
|---|
| 723 | n/a | FInfo_tp_free, /* tp_free */ |
|---|
| 724 | n/a | }; |
|---|
| 725 | n/a | |
|---|
| 726 | n/a | #endif /* !__LP64__ */ |
|---|
| 727 | n/a | /* --------------------- End object type FInfo ---------------------- */ |
|---|
| 728 | n/a | |
|---|
| 729 | n/a | |
|---|
| 730 | n/a | /* ----------------------- Object type Alias ------------------------ */ |
|---|
| 731 | n/a | |
|---|
| 732 | n/a | static PyTypeObject Alias_Type; |
|---|
| 733 | n/a | |
|---|
| 734 | n/a | #define Alias_Check(x) ((x)->ob_type == &Alias_Type || PyObject_TypeCheck((x), &Alias_Type)) |
|---|
| 735 | n/a | |
|---|
| 736 | n/a | typedef struct AliasObject { |
|---|
| 737 | n/a | PyObject_HEAD |
|---|
| 738 | n/a | AliasHandle ob_itself; |
|---|
| 739 | n/a | void (*ob_freeit)(AliasHandle ptr); |
|---|
| 740 | n/a | } AliasObject; |
|---|
| 741 | n/a | |
|---|
| 742 | n/a | static PyObject *Alias_New(AliasHandle itself) |
|---|
| 743 | n/a | { |
|---|
| 744 | n/a | AliasObject *it; |
|---|
| 745 | n/a | if (itself == NULL) return PyMac_Error(resNotFound); |
|---|
| 746 | n/a | it = PyObject_NEW(AliasObject, &Alias_Type); |
|---|
| 747 | n/a | if (it == NULL) return NULL; |
|---|
| 748 | n/a | it->ob_itself = itself; |
|---|
| 749 | n/a | it->ob_freeit = NULL; |
|---|
| 750 | n/a | return (PyObject *)it; |
|---|
| 751 | n/a | } |
|---|
| 752 | n/a | |
|---|
| 753 | n/a | static int Alias_Convert(PyObject *v, AliasHandle *p_itself) |
|---|
| 754 | n/a | { |
|---|
| 755 | n/a | if (!Alias_Check(v)) |
|---|
| 756 | n/a | { |
|---|
| 757 | n/a | PyErr_SetString(PyExc_TypeError, "Alias required"); |
|---|
| 758 | n/a | return 0; |
|---|
| 759 | n/a | } |
|---|
| 760 | n/a | *p_itself = ((AliasObject *)v)->ob_itself; |
|---|
| 761 | n/a | return 1; |
|---|
| 762 | n/a | } |
|---|
| 763 | n/a | |
|---|
| 764 | n/a | static void Alias_dealloc(AliasObject *self) |
|---|
| 765 | n/a | { |
|---|
| 766 | n/a | if (self->ob_freeit && self->ob_itself) |
|---|
| 767 | n/a | { |
|---|
| 768 | n/a | self->ob_freeit(self->ob_itself); |
|---|
| 769 | n/a | } |
|---|
| 770 | n/a | self->ob_itself = NULL; |
|---|
| 771 | n/a | self->ob_type->tp_free((PyObject *)self); |
|---|
| 772 | n/a | } |
|---|
| 773 | n/a | |
|---|
| 774 | n/a | #ifndef __LP64__ |
|---|
| 775 | n/a | static PyObject *Alias_ResolveAlias(AliasObject *_self, PyObject *_args) |
|---|
| 776 | n/a | { |
|---|
| 777 | n/a | PyObject *_res = NULL; |
|---|
| 778 | n/a | OSErr _err; |
|---|
| 779 | n/a | FSSpec fromFile__buf__; |
|---|
| 780 | n/a | FSSpec *fromFile = &fromFile__buf__; |
|---|
| 781 | n/a | FSSpec target; |
|---|
| 782 | n/a | Boolean wasChanged; |
|---|
| 783 | n/a | if (!PyArg_ParseTuple(_args, "O&", |
|---|
| 784 | n/a | myPyMac_GetOptFSSpecPtr, &fromFile)) |
|---|
| 785 | n/a | return NULL; |
|---|
| 786 | n/a | _err = ResolveAlias(fromFile, |
|---|
| 787 | n/a | _self->ob_itself, |
|---|
| 788 | n/a | &target, |
|---|
| 789 | n/a | &wasChanged); |
|---|
| 790 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 791 | n/a | _res = Py_BuildValue("O&b", |
|---|
| 792 | n/a | FSSpec_New, &target, |
|---|
| 793 | n/a | wasChanged); |
|---|
| 794 | n/a | return _res; |
|---|
| 795 | n/a | } |
|---|
| 796 | n/a | |
|---|
| 797 | n/a | static PyObject *Alias_GetAliasInfo(AliasObject *_self, PyObject *_args) |
|---|
| 798 | n/a | { |
|---|
| 799 | n/a | PyObject *_res = NULL; |
|---|
| 800 | n/a | OSErr _err; |
|---|
| 801 | n/a | AliasInfoType index; |
|---|
| 802 | n/a | Str63 theString; |
|---|
| 803 | n/a | if (!PyArg_ParseTuple(_args, "h", |
|---|
| 804 | n/a | &index)) |
|---|
| 805 | n/a | return NULL; |
|---|
| 806 | n/a | _err = GetAliasInfo(_self->ob_itself, |
|---|
| 807 | n/a | index, |
|---|
| 808 | n/a | theString); |
|---|
| 809 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 810 | n/a | _res = Py_BuildValue("O&", |
|---|
| 811 | n/a | PyMac_BuildStr255, theString); |
|---|
| 812 | n/a | return _res; |
|---|
| 813 | n/a | } |
|---|
| 814 | n/a | |
|---|
| 815 | n/a | static PyObject *Alias_ResolveAliasWithMountFlags(AliasObject *_self, PyObject *_args) |
|---|
| 816 | n/a | { |
|---|
| 817 | n/a | PyObject *_res = NULL; |
|---|
| 818 | n/a | OSErr _err; |
|---|
| 819 | n/a | FSSpec fromFile__buf__; |
|---|
| 820 | n/a | FSSpec *fromFile = &fromFile__buf__; |
|---|
| 821 | n/a | FSSpec target; |
|---|
| 822 | n/a | Boolean wasChanged; |
|---|
| 823 | n/a | unsigned long mountFlags; |
|---|
| 824 | n/a | if (!PyArg_ParseTuple(_args, "O&l", |
|---|
| 825 | n/a | myPyMac_GetOptFSSpecPtr, &fromFile, |
|---|
| 826 | n/a | &mountFlags)) |
|---|
| 827 | n/a | return NULL; |
|---|
| 828 | n/a | _err = ResolveAliasWithMountFlags(fromFile, |
|---|
| 829 | n/a | _self->ob_itself, |
|---|
| 830 | n/a | &target, |
|---|
| 831 | n/a | &wasChanged, |
|---|
| 832 | n/a | mountFlags); |
|---|
| 833 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 834 | n/a | _res = Py_BuildValue("O&b", |
|---|
| 835 | n/a | FSSpec_New, &target, |
|---|
| 836 | n/a | wasChanged); |
|---|
| 837 | n/a | return _res; |
|---|
| 838 | n/a | } |
|---|
| 839 | n/a | |
|---|
| 840 | n/a | static PyObject *Alias_FollowFinderAlias(AliasObject *_self, PyObject *_args) |
|---|
| 841 | n/a | { |
|---|
| 842 | n/a | PyObject *_res = NULL; |
|---|
| 843 | n/a | OSErr _err; |
|---|
| 844 | n/a | FSSpec fromFile__buf__; |
|---|
| 845 | n/a | FSSpec *fromFile = &fromFile__buf__; |
|---|
| 846 | n/a | Boolean logon; |
|---|
| 847 | n/a | FSSpec target; |
|---|
| 848 | n/a | Boolean wasChanged; |
|---|
| 849 | n/a | if (!PyArg_ParseTuple(_args, "O&b", |
|---|
| 850 | n/a | myPyMac_GetOptFSSpecPtr, &fromFile, |
|---|
| 851 | n/a | &logon)) |
|---|
| 852 | n/a | return NULL; |
|---|
| 853 | n/a | _err = FollowFinderAlias(fromFile, |
|---|
| 854 | n/a | _self->ob_itself, |
|---|
| 855 | n/a | logon, |
|---|
| 856 | n/a | &target, |
|---|
| 857 | n/a | &wasChanged); |
|---|
| 858 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 859 | n/a | _res = Py_BuildValue("O&b", |
|---|
| 860 | n/a | FSSpec_New, &target, |
|---|
| 861 | n/a | wasChanged); |
|---|
| 862 | n/a | return _res; |
|---|
| 863 | n/a | } |
|---|
| 864 | n/a | #endif /* !__LP64__ */ |
|---|
| 865 | n/a | |
|---|
| 866 | n/a | static PyObject *Alias_FSResolveAliasWithMountFlags(AliasObject *_self, PyObject *_args) |
|---|
| 867 | n/a | { |
|---|
| 868 | n/a | PyObject *_res = NULL; |
|---|
| 869 | n/a | OSErr _err; |
|---|
| 870 | n/a | FSRef fromFile__buf__; |
|---|
| 871 | n/a | FSRef *fromFile = &fromFile__buf__; |
|---|
| 872 | n/a | FSRef target; |
|---|
| 873 | n/a | Boolean wasChanged; |
|---|
| 874 | n/a | unsigned long mountFlags; |
|---|
| 875 | n/a | if (!PyArg_ParseTuple(_args, "O&l", |
|---|
| 876 | n/a | myPyMac_GetOptFSRefPtr, &fromFile, |
|---|
| 877 | n/a | &mountFlags)) |
|---|
| 878 | n/a | return NULL; |
|---|
| 879 | n/a | _err = FSResolveAliasWithMountFlags(fromFile, |
|---|
| 880 | n/a | _self->ob_itself, |
|---|
| 881 | n/a | &target, |
|---|
| 882 | n/a | &wasChanged, |
|---|
| 883 | n/a | mountFlags); |
|---|
| 884 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 885 | n/a | _res = Py_BuildValue("O&b", |
|---|
| 886 | n/a | FSRef_New, &target, |
|---|
| 887 | n/a | wasChanged); |
|---|
| 888 | n/a | return _res; |
|---|
| 889 | n/a | } |
|---|
| 890 | n/a | |
|---|
| 891 | n/a | static PyObject *Alias_FSResolveAlias(AliasObject *_self, PyObject *_args) |
|---|
| 892 | n/a | { |
|---|
| 893 | n/a | PyObject *_res = NULL; |
|---|
| 894 | n/a | OSErr _err; |
|---|
| 895 | n/a | FSRef fromFile__buf__; |
|---|
| 896 | n/a | FSRef *fromFile = &fromFile__buf__; |
|---|
| 897 | n/a | FSRef target; |
|---|
| 898 | n/a | Boolean wasChanged; |
|---|
| 899 | n/a | if (!PyArg_ParseTuple(_args, "O&", |
|---|
| 900 | n/a | myPyMac_GetOptFSRefPtr, &fromFile)) |
|---|
| 901 | n/a | return NULL; |
|---|
| 902 | n/a | _err = FSResolveAlias(fromFile, |
|---|
| 903 | n/a | _self->ob_itself, |
|---|
| 904 | n/a | &target, |
|---|
| 905 | n/a | &wasChanged); |
|---|
| 906 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 907 | n/a | _res = Py_BuildValue("O&b", |
|---|
| 908 | n/a | FSRef_New, &target, |
|---|
| 909 | n/a | wasChanged); |
|---|
| 910 | n/a | return _res; |
|---|
| 911 | n/a | } |
|---|
| 912 | n/a | |
|---|
| 913 | n/a | static PyObject *Alias_FSFollowFinderAlias(AliasObject *_self, PyObject *_args) |
|---|
| 914 | n/a | { |
|---|
| 915 | n/a | PyObject *_res = NULL; |
|---|
| 916 | n/a | OSErr _err; |
|---|
| 917 | n/a | FSRef fromFile; |
|---|
| 918 | n/a | Boolean logon; |
|---|
| 919 | n/a | FSRef target; |
|---|
| 920 | n/a | Boolean wasChanged; |
|---|
| 921 | n/a | if (!PyArg_ParseTuple(_args, "b", |
|---|
| 922 | n/a | &logon)) |
|---|
| 923 | n/a | return NULL; |
|---|
| 924 | n/a | _err = FSFollowFinderAlias(&fromFile, |
|---|
| 925 | n/a | _self->ob_itself, |
|---|
| 926 | n/a | logon, |
|---|
| 927 | n/a | &target, |
|---|
| 928 | n/a | &wasChanged); |
|---|
| 929 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 930 | n/a | _res = Py_BuildValue("O&O&b", |
|---|
| 931 | n/a | FSRef_New, &fromFile, |
|---|
| 932 | n/a | FSRef_New, &target, |
|---|
| 933 | n/a | wasChanged); |
|---|
| 934 | n/a | return _res; |
|---|
| 935 | n/a | } |
|---|
| 936 | n/a | |
|---|
| 937 | n/a | static PyMethodDef Alias_methods[] = { |
|---|
| 938 | n/a | #ifndef __LP64__ |
|---|
| 939 | n/a | {"ResolveAlias", (PyCFunction)Alias_ResolveAlias, 1, |
|---|
| 940 | n/a | PyDoc_STR("(FSSpec fromFile) -> (FSSpec target, Boolean wasChanged)")}, |
|---|
| 941 | n/a | {"GetAliasInfo", (PyCFunction)Alias_GetAliasInfo, 1, |
|---|
| 942 | n/a | PyDoc_STR("(AliasInfoType index) -> (Str63 theString)")}, |
|---|
| 943 | n/a | {"ResolveAliasWithMountFlags", (PyCFunction)Alias_ResolveAliasWithMountFlags, 1, |
|---|
| 944 | n/a | PyDoc_STR("(FSSpec fromFile, unsigned long mountFlags) -> (FSSpec target, Boolean wasChanged)")}, |
|---|
| 945 | n/a | {"FollowFinderAlias", (PyCFunction)Alias_FollowFinderAlias, 1, |
|---|
| 946 | n/a | PyDoc_STR("(FSSpec fromFile, Boolean logon) -> (FSSpec target, Boolean wasChanged)")}, |
|---|
| 947 | n/a | #endif /* !__LP64__ */ |
|---|
| 948 | n/a | {"FSResolveAliasWithMountFlags", (PyCFunction)Alias_FSResolveAliasWithMountFlags, 1, |
|---|
| 949 | n/a | PyDoc_STR("(FSRef fromFile, unsigned long mountFlags) -> (FSRef target, Boolean wasChanged)")}, |
|---|
| 950 | n/a | {"FSResolveAlias", (PyCFunction)Alias_FSResolveAlias, 1, |
|---|
| 951 | n/a | PyDoc_STR("(FSRef fromFile) -> (FSRef target, Boolean wasChanged)")}, |
|---|
| 952 | n/a | {"FSFollowFinderAlias", (PyCFunction)Alias_FSFollowFinderAlias, 1, |
|---|
| 953 | n/a | PyDoc_STR("(Boolean logon) -> (FSRef fromFile, FSRef target, Boolean wasChanged)")}, |
|---|
| 954 | n/a | {NULL, NULL, 0} |
|---|
| 955 | n/a | }; |
|---|
| 956 | n/a | |
|---|
| 957 | n/a | static PyObject *Alias_get_data(AliasObject *self, void *closure) |
|---|
| 958 | n/a | { |
|---|
| 959 | n/a | int size; |
|---|
| 960 | n/a | PyObject *rv; |
|---|
| 961 | n/a | |
|---|
| 962 | n/a | size = GetHandleSize((Handle)self->ob_itself); |
|---|
| 963 | n/a | HLock((Handle)self->ob_itself); |
|---|
| 964 | n/a | rv = PyString_FromStringAndSize(*(Handle)self->ob_itself, size); |
|---|
| 965 | n/a | HUnlock((Handle)self->ob_itself); |
|---|
| 966 | n/a | return rv; |
|---|
| 967 | n/a | |
|---|
| 968 | n/a | } |
|---|
| 969 | n/a | |
|---|
| 970 | n/a | #define Alias_set_data NULL |
|---|
| 971 | n/a | |
|---|
| 972 | n/a | static PyGetSetDef Alias_getsetlist[] = { |
|---|
| 973 | n/a | {"data", (getter)Alias_get_data, (setter)Alias_set_data, "Raw data of the alias object"}, |
|---|
| 974 | n/a | {NULL, NULL, NULL, NULL}, |
|---|
| 975 | n/a | }; |
|---|
| 976 | n/a | |
|---|
| 977 | n/a | |
|---|
| 978 | n/a | #define Alias_compare NULL |
|---|
| 979 | n/a | |
|---|
| 980 | n/a | #define Alias_repr NULL |
|---|
| 981 | n/a | |
|---|
| 982 | n/a | #define Alias_hash NULL |
|---|
| 983 | n/a | static int Alias_tp_init(PyObject *_self, PyObject *_args, PyObject *_kwds) |
|---|
| 984 | n/a | { |
|---|
| 985 | n/a | AliasHandle itself = NULL; |
|---|
| 986 | n/a | char *rawdata = NULL; |
|---|
| 987 | n/a | int rawdatalen = 0; |
|---|
| 988 | n/a | Handle h; |
|---|
| 989 | n/a | static char *kw[] = {"itself", "rawdata", 0}; |
|---|
| 990 | n/a | |
|---|
| 991 | n/a | if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "|O&s#", kw, Alias_Convert, &itself, &rawdata, &rawdatalen)) |
|---|
| 992 | n/a | return -1; |
|---|
| 993 | n/a | if (itself && rawdata) |
|---|
| 994 | n/a | { |
|---|
| 995 | n/a | PyErr_SetString(PyExc_TypeError, "Only one of itself or rawdata may be specified"); |
|---|
| 996 | n/a | return -1; |
|---|
| 997 | n/a | } |
|---|
| 998 | n/a | if (!itself && !rawdata) |
|---|
| 999 | n/a | { |
|---|
| 1000 | n/a | PyErr_SetString(PyExc_TypeError, "One of itself or rawdata must be specified"); |
|---|
| 1001 | n/a | return -1; |
|---|
| 1002 | n/a | } |
|---|
| 1003 | n/a | if (rawdata) |
|---|
| 1004 | n/a | { |
|---|
| 1005 | n/a | if ((h = NewHandle(rawdatalen)) == NULL) |
|---|
| 1006 | n/a | { |
|---|
| 1007 | n/a | PyErr_NoMemory(); |
|---|
| 1008 | n/a | return -1; |
|---|
| 1009 | n/a | } |
|---|
| 1010 | n/a | HLock(h); |
|---|
| 1011 | n/a | memcpy((char *)*h, rawdata, rawdatalen); |
|---|
| 1012 | n/a | HUnlock(h); |
|---|
| 1013 | n/a | ((AliasObject *)_self)->ob_itself = (AliasHandle)h; |
|---|
| 1014 | n/a | return 0; |
|---|
| 1015 | n/a | } |
|---|
| 1016 | n/a | ((AliasObject *)_self)->ob_itself = itself; |
|---|
| 1017 | n/a | return 0; |
|---|
| 1018 | n/a | } |
|---|
| 1019 | n/a | |
|---|
| 1020 | n/a | #define Alias_tp_alloc PyType_GenericAlloc |
|---|
| 1021 | n/a | |
|---|
| 1022 | n/a | static PyObject *Alias_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) |
|---|
| 1023 | n/a | { |
|---|
| 1024 | n/a | PyObject *self; |
|---|
| 1025 | n/a | |
|---|
| 1026 | n/a | if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; |
|---|
| 1027 | n/a | ((AliasObject *)self)->ob_itself = NULL; |
|---|
| 1028 | n/a | return self; |
|---|
| 1029 | n/a | } |
|---|
| 1030 | n/a | |
|---|
| 1031 | n/a | #define Alias_tp_free PyObject_Del |
|---|
| 1032 | n/a | |
|---|
| 1033 | n/a | |
|---|
| 1034 | n/a | static PyTypeObject Alias_Type = { |
|---|
| 1035 | n/a | PyObject_HEAD_INIT(NULL) |
|---|
| 1036 | n/a | 0, /*ob_size*/ |
|---|
| 1037 | n/a | "Carbon.File.Alias", /*tp_name*/ |
|---|
| 1038 | n/a | sizeof(AliasObject), /*tp_basicsize*/ |
|---|
| 1039 | n/a | 0, /*tp_itemsize*/ |
|---|
| 1040 | n/a | /* methods */ |
|---|
| 1041 | n/a | (destructor) Alias_dealloc, /*tp_dealloc*/ |
|---|
| 1042 | n/a | 0, /*tp_print*/ |
|---|
| 1043 | n/a | (getattrfunc)0, /*tp_getattr*/ |
|---|
| 1044 | n/a | (setattrfunc)0, /*tp_setattr*/ |
|---|
| 1045 | n/a | (cmpfunc) Alias_compare, /*tp_compare*/ |
|---|
| 1046 | n/a | (reprfunc) Alias_repr, /*tp_repr*/ |
|---|
| 1047 | n/a | (PyNumberMethods *)0, /* tp_as_number */ |
|---|
| 1048 | n/a | (PySequenceMethods *)0, /* tp_as_sequence */ |
|---|
| 1049 | n/a | (PyMappingMethods *)0, /* tp_as_mapping */ |
|---|
| 1050 | n/a | (hashfunc) Alias_hash, /*tp_hash*/ |
|---|
| 1051 | n/a | 0, /*tp_call*/ |
|---|
| 1052 | n/a | 0, /*tp_str*/ |
|---|
| 1053 | n/a | PyObject_GenericGetAttr, /*tp_getattro*/ |
|---|
| 1054 | n/a | PyObject_GenericSetAttr, /*tp_setattro */ |
|---|
| 1055 | n/a | 0, /*tp_as_buffer*/ |
|---|
| 1056 | n/a | Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */ |
|---|
| 1057 | n/a | 0, /*tp_doc*/ |
|---|
| 1058 | n/a | 0, /*tp_traverse*/ |
|---|
| 1059 | n/a | 0, /*tp_clear*/ |
|---|
| 1060 | n/a | 0, /*tp_richcompare*/ |
|---|
| 1061 | n/a | 0, /*tp_weaklistoffset*/ |
|---|
| 1062 | n/a | 0, /*tp_iter*/ |
|---|
| 1063 | n/a | 0, /*tp_iternext*/ |
|---|
| 1064 | n/a | Alias_methods, /* tp_methods */ |
|---|
| 1065 | n/a | 0, /*tp_members*/ |
|---|
| 1066 | n/a | Alias_getsetlist, /*tp_getset*/ |
|---|
| 1067 | n/a | 0, /*tp_base*/ |
|---|
| 1068 | n/a | 0, /*tp_dict*/ |
|---|
| 1069 | n/a | 0, /*tp_descr_get*/ |
|---|
| 1070 | n/a | 0, /*tp_descr_set*/ |
|---|
| 1071 | n/a | 0, /*tp_dictoffset*/ |
|---|
| 1072 | n/a | Alias_tp_init, /* tp_init */ |
|---|
| 1073 | n/a | Alias_tp_alloc, /* tp_alloc */ |
|---|
| 1074 | n/a | Alias_tp_new, /* tp_new */ |
|---|
| 1075 | n/a | Alias_tp_free, /* tp_free */ |
|---|
| 1076 | n/a | }; |
|---|
| 1077 | n/a | |
|---|
| 1078 | n/a | /* --------------------- End object type Alias ---------------------- */ |
|---|
| 1079 | n/a | |
|---|
| 1080 | n/a | |
|---|
| 1081 | n/a | /* ----------------------- Object type FSSpec ----------------------- */ |
|---|
| 1082 | n/a | #ifndef __LP64__ |
|---|
| 1083 | n/a | |
|---|
| 1084 | n/a | static PyTypeObject FSSpec_Type; |
|---|
| 1085 | n/a | |
|---|
| 1086 | n/a | #define FSSpec_Check(x) ((x)->ob_type == &FSSpec_Type || PyObject_TypeCheck((x), &FSSpec_Type)) |
|---|
| 1087 | n/a | |
|---|
| 1088 | n/a | typedef struct FSSpecObject { |
|---|
| 1089 | n/a | PyObject_HEAD |
|---|
| 1090 | n/a | FSSpec ob_itself; |
|---|
| 1091 | n/a | } FSSpecObject; |
|---|
| 1092 | n/a | |
|---|
| 1093 | n/a | static PyObject *FSSpec_New(FSSpec *itself) |
|---|
| 1094 | n/a | { |
|---|
| 1095 | n/a | FSSpecObject *it; |
|---|
| 1096 | n/a | if (itself == NULL) return PyMac_Error(resNotFound); |
|---|
| 1097 | n/a | it = PyObject_NEW(FSSpecObject, &FSSpec_Type); |
|---|
| 1098 | n/a | if (it == NULL) return NULL; |
|---|
| 1099 | n/a | it->ob_itself = *itself; |
|---|
| 1100 | n/a | return (PyObject *)it; |
|---|
| 1101 | n/a | } |
|---|
| 1102 | n/a | |
|---|
| 1103 | n/a | static void FSSpec_dealloc(FSSpecObject *self) |
|---|
| 1104 | n/a | { |
|---|
| 1105 | n/a | /* Cleanup of self->ob_itself goes here */ |
|---|
| 1106 | n/a | self->ob_type->tp_free((PyObject *)self); |
|---|
| 1107 | n/a | } |
|---|
| 1108 | n/a | |
|---|
| 1109 | n/a | static PyObject *FSSpec_FSpOpenDF(FSSpecObject *_self, PyObject *_args) |
|---|
| 1110 | n/a | { |
|---|
| 1111 | n/a | PyObject *_res = NULL; |
|---|
| 1112 | n/a | OSErr _err; |
|---|
| 1113 | n/a | SInt8 permission; |
|---|
| 1114 | n/a | short refNum; |
|---|
| 1115 | n/a | if (!PyArg_ParseTuple(_args, "b", |
|---|
| 1116 | n/a | &permission)) |
|---|
| 1117 | n/a | return NULL; |
|---|
| 1118 | n/a | _err = FSpOpenDF(&_self->ob_itself, |
|---|
| 1119 | n/a | permission, |
|---|
| 1120 | n/a | &refNum); |
|---|
| 1121 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 1122 | n/a | _res = Py_BuildValue("h", |
|---|
| 1123 | n/a | refNum); |
|---|
| 1124 | n/a | return _res; |
|---|
| 1125 | n/a | } |
|---|
| 1126 | n/a | |
|---|
| 1127 | n/a | static PyObject *FSSpec_FSpOpenRF(FSSpecObject *_self, PyObject *_args) |
|---|
| 1128 | n/a | { |
|---|
| 1129 | n/a | PyObject *_res = NULL; |
|---|
| 1130 | n/a | OSErr _err; |
|---|
| 1131 | n/a | SInt8 permission; |
|---|
| 1132 | n/a | short refNum; |
|---|
| 1133 | n/a | if (!PyArg_ParseTuple(_args, "b", |
|---|
| 1134 | n/a | &permission)) |
|---|
| 1135 | n/a | return NULL; |
|---|
| 1136 | n/a | _err = FSpOpenRF(&_self->ob_itself, |
|---|
| 1137 | n/a | permission, |
|---|
| 1138 | n/a | &refNum); |
|---|
| 1139 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 1140 | n/a | _res = Py_BuildValue("h", |
|---|
| 1141 | n/a | refNum); |
|---|
| 1142 | n/a | return _res; |
|---|
| 1143 | n/a | } |
|---|
| 1144 | n/a | |
|---|
| 1145 | n/a | static PyObject *FSSpec_FSpCreate(FSSpecObject *_self, PyObject *_args) |
|---|
| 1146 | n/a | { |
|---|
| 1147 | n/a | PyObject *_res = NULL; |
|---|
| 1148 | n/a | OSErr _err; |
|---|
| 1149 | n/a | OSType creator; |
|---|
| 1150 | n/a | OSType fileType; |
|---|
| 1151 | n/a | ScriptCode scriptTag; |
|---|
| 1152 | n/a | if (!PyArg_ParseTuple(_args, "O&O&h", |
|---|
| 1153 | n/a | PyMac_GetOSType, &creator, |
|---|
| 1154 | n/a | PyMac_GetOSType, &fileType, |
|---|
| 1155 | n/a | &scriptTag)) |
|---|
| 1156 | n/a | return NULL; |
|---|
| 1157 | n/a | _err = FSpCreate(&_self->ob_itself, |
|---|
| 1158 | n/a | creator, |
|---|
| 1159 | n/a | fileType, |
|---|
| 1160 | n/a | scriptTag); |
|---|
| 1161 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 1162 | n/a | Py_INCREF(Py_None); |
|---|
| 1163 | n/a | _res = Py_None; |
|---|
| 1164 | n/a | return _res; |
|---|
| 1165 | n/a | } |
|---|
| 1166 | n/a | |
|---|
| 1167 | n/a | static PyObject *FSSpec_FSpDirCreate(FSSpecObject *_self, PyObject *_args) |
|---|
| 1168 | n/a | { |
|---|
| 1169 | n/a | PyObject *_res = NULL; |
|---|
| 1170 | n/a | OSErr _err; |
|---|
| 1171 | n/a | ScriptCode scriptTag; |
|---|
| 1172 | n/a | long createdDirID; |
|---|
| 1173 | n/a | if (!PyArg_ParseTuple(_args, "h", |
|---|
| 1174 | n/a | &scriptTag)) |
|---|
| 1175 | n/a | return NULL; |
|---|
| 1176 | n/a | _err = FSpDirCreate(&_self->ob_itself, |
|---|
| 1177 | n/a | scriptTag, |
|---|
| 1178 | n/a | &createdDirID); |
|---|
| 1179 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 1180 | n/a | _res = Py_BuildValue("l", |
|---|
| 1181 | n/a | createdDirID); |
|---|
| 1182 | n/a | return _res; |
|---|
| 1183 | n/a | } |
|---|
| 1184 | n/a | |
|---|
| 1185 | n/a | static PyObject *FSSpec_FSpDelete(FSSpecObject *_self, PyObject *_args) |
|---|
| 1186 | n/a | { |
|---|
| 1187 | n/a | PyObject *_res = NULL; |
|---|
| 1188 | n/a | OSErr _err; |
|---|
| 1189 | n/a | if (!PyArg_ParseTuple(_args, "")) |
|---|
| 1190 | n/a | return NULL; |
|---|
| 1191 | n/a | _err = FSpDelete(&_self->ob_itself); |
|---|
| 1192 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 1193 | n/a | Py_INCREF(Py_None); |
|---|
| 1194 | n/a | _res = Py_None; |
|---|
| 1195 | n/a | return _res; |
|---|
| 1196 | n/a | } |
|---|
| 1197 | n/a | |
|---|
| 1198 | n/a | static PyObject *FSSpec_FSpGetFInfo(FSSpecObject *_self, PyObject *_args) |
|---|
| 1199 | n/a | { |
|---|
| 1200 | n/a | PyObject *_res = NULL; |
|---|
| 1201 | n/a | OSErr _err; |
|---|
| 1202 | n/a | FInfo fndrInfo; |
|---|
| 1203 | n/a | if (!PyArg_ParseTuple(_args, "")) |
|---|
| 1204 | n/a | return NULL; |
|---|
| 1205 | n/a | _err = FSpGetFInfo(&_self->ob_itself, |
|---|
| 1206 | n/a | &fndrInfo); |
|---|
| 1207 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 1208 | n/a | _res = Py_BuildValue("O&", |
|---|
| 1209 | n/a | FInfo_New, &fndrInfo); |
|---|
| 1210 | n/a | return _res; |
|---|
| 1211 | n/a | } |
|---|
| 1212 | n/a | |
|---|
| 1213 | n/a | static PyObject *FSSpec_FSpSetFInfo(FSSpecObject *_self, PyObject *_args) |
|---|
| 1214 | n/a | { |
|---|
| 1215 | n/a | PyObject *_res = NULL; |
|---|
| 1216 | n/a | OSErr _err; |
|---|
| 1217 | n/a | FInfo fndrInfo; |
|---|
| 1218 | n/a | if (!PyArg_ParseTuple(_args, "O&", |
|---|
| 1219 | n/a | FInfo_Convert, &fndrInfo)) |
|---|
| 1220 | n/a | return NULL; |
|---|
| 1221 | n/a | _err = FSpSetFInfo(&_self->ob_itself, |
|---|
| 1222 | n/a | &fndrInfo); |
|---|
| 1223 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 1224 | n/a | Py_INCREF(Py_None); |
|---|
| 1225 | n/a | _res = Py_None; |
|---|
| 1226 | n/a | return _res; |
|---|
| 1227 | n/a | } |
|---|
| 1228 | n/a | |
|---|
| 1229 | n/a | static PyObject *FSSpec_FSpSetFLock(FSSpecObject *_self, PyObject *_args) |
|---|
| 1230 | n/a | { |
|---|
| 1231 | n/a | PyObject *_res = NULL; |
|---|
| 1232 | n/a | OSErr _err; |
|---|
| 1233 | n/a | if (!PyArg_ParseTuple(_args, "")) |
|---|
| 1234 | n/a | return NULL; |
|---|
| 1235 | n/a | _err = FSpSetFLock(&_self->ob_itself); |
|---|
| 1236 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 1237 | n/a | Py_INCREF(Py_None); |
|---|
| 1238 | n/a | _res = Py_None; |
|---|
| 1239 | n/a | return _res; |
|---|
| 1240 | n/a | } |
|---|
| 1241 | n/a | |
|---|
| 1242 | n/a | static PyObject *FSSpec_FSpRstFLock(FSSpecObject *_self, PyObject *_args) |
|---|
| 1243 | n/a | { |
|---|
| 1244 | n/a | PyObject *_res = NULL; |
|---|
| 1245 | n/a | OSErr _err; |
|---|
| 1246 | n/a | if (!PyArg_ParseTuple(_args, "")) |
|---|
| 1247 | n/a | return NULL; |
|---|
| 1248 | n/a | _err = FSpRstFLock(&_self->ob_itself); |
|---|
| 1249 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 1250 | n/a | Py_INCREF(Py_None); |
|---|
| 1251 | n/a | _res = Py_None; |
|---|
| 1252 | n/a | return _res; |
|---|
| 1253 | n/a | } |
|---|
| 1254 | n/a | |
|---|
| 1255 | n/a | static PyObject *FSSpec_FSpRename(FSSpecObject *_self, PyObject *_args) |
|---|
| 1256 | n/a | { |
|---|
| 1257 | n/a | PyObject *_res = NULL; |
|---|
| 1258 | n/a | OSErr _err; |
|---|
| 1259 | n/a | Str255 newName; |
|---|
| 1260 | n/a | if (!PyArg_ParseTuple(_args, "O&", |
|---|
| 1261 | n/a | PyMac_GetStr255, newName)) |
|---|
| 1262 | n/a | return NULL; |
|---|
| 1263 | n/a | _err = FSpRename(&_self->ob_itself, |
|---|
| 1264 | n/a | newName); |
|---|
| 1265 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 1266 | n/a | Py_INCREF(Py_None); |
|---|
| 1267 | n/a | _res = Py_None; |
|---|
| 1268 | n/a | return _res; |
|---|
| 1269 | n/a | } |
|---|
| 1270 | n/a | |
|---|
| 1271 | n/a | static PyObject *FSSpec_FSpCatMove(FSSpecObject *_self, PyObject *_args) |
|---|
| 1272 | n/a | { |
|---|
| 1273 | n/a | PyObject *_res = NULL; |
|---|
| 1274 | n/a | OSErr _err; |
|---|
| 1275 | n/a | FSSpec dest; |
|---|
| 1276 | n/a | if (!PyArg_ParseTuple(_args, "O&", |
|---|
| 1277 | n/a | FSSpec_Convert, &dest)) |
|---|
| 1278 | n/a | return NULL; |
|---|
| 1279 | n/a | _err = FSpCatMove(&_self->ob_itself, |
|---|
| 1280 | n/a | &dest); |
|---|
| 1281 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 1282 | n/a | Py_INCREF(Py_None); |
|---|
| 1283 | n/a | _res = Py_None; |
|---|
| 1284 | n/a | return _res; |
|---|
| 1285 | n/a | } |
|---|
| 1286 | n/a | |
|---|
| 1287 | n/a | static PyObject *FSSpec_FSpExchangeFiles(FSSpecObject *_self, PyObject *_args) |
|---|
| 1288 | n/a | { |
|---|
| 1289 | n/a | PyObject *_res = NULL; |
|---|
| 1290 | n/a | OSErr _err; |
|---|
| 1291 | n/a | FSSpec dest; |
|---|
| 1292 | n/a | if (!PyArg_ParseTuple(_args, "O&", |
|---|
| 1293 | n/a | FSSpec_Convert, &dest)) |
|---|
| 1294 | n/a | return NULL; |
|---|
| 1295 | n/a | _err = FSpExchangeFiles(&_self->ob_itself, |
|---|
| 1296 | n/a | &dest); |
|---|
| 1297 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 1298 | n/a | Py_INCREF(Py_None); |
|---|
| 1299 | n/a | _res = Py_None; |
|---|
| 1300 | n/a | return _res; |
|---|
| 1301 | n/a | } |
|---|
| 1302 | n/a | |
|---|
| 1303 | n/a | static PyObject *FSSpec_FSpMakeFSRef(FSSpecObject *_self, PyObject *_args) |
|---|
| 1304 | n/a | { |
|---|
| 1305 | n/a | PyObject *_res = NULL; |
|---|
| 1306 | n/a | OSErr _err; |
|---|
| 1307 | n/a | FSRef newRef; |
|---|
| 1308 | n/a | if (!PyArg_ParseTuple(_args, "")) |
|---|
| 1309 | n/a | return NULL; |
|---|
| 1310 | n/a | _err = FSpMakeFSRef(&_self->ob_itself, |
|---|
| 1311 | n/a | &newRef); |
|---|
| 1312 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 1313 | n/a | _res = Py_BuildValue("O&", |
|---|
| 1314 | n/a | FSRef_New, &newRef); |
|---|
| 1315 | n/a | return _res; |
|---|
| 1316 | n/a | } |
|---|
| 1317 | n/a | |
|---|
| 1318 | n/a | static PyObject *FSSpec_NewAliasMinimal(FSSpecObject *_self, PyObject *_args) |
|---|
| 1319 | n/a | { |
|---|
| 1320 | n/a | PyObject *_res = NULL; |
|---|
| 1321 | n/a | OSErr _err; |
|---|
| 1322 | n/a | AliasHandle alias; |
|---|
| 1323 | n/a | if (!PyArg_ParseTuple(_args, "")) |
|---|
| 1324 | n/a | return NULL; |
|---|
| 1325 | n/a | _err = NewAliasMinimal(&_self->ob_itself, |
|---|
| 1326 | n/a | &alias); |
|---|
| 1327 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 1328 | n/a | _res = Py_BuildValue("O&", |
|---|
| 1329 | n/a | Alias_New, alias); |
|---|
| 1330 | n/a | return _res; |
|---|
| 1331 | n/a | } |
|---|
| 1332 | n/a | |
|---|
| 1333 | n/a | static PyObject *FSSpec_IsAliasFile(FSSpecObject *_self, PyObject *_args) |
|---|
| 1334 | n/a | { |
|---|
| 1335 | n/a | PyObject *_res = NULL; |
|---|
| 1336 | n/a | OSErr _err; |
|---|
| 1337 | n/a | Boolean aliasFileFlag; |
|---|
| 1338 | n/a | Boolean folderFlag; |
|---|
| 1339 | n/a | if (!PyArg_ParseTuple(_args, "")) |
|---|
| 1340 | n/a | return NULL; |
|---|
| 1341 | n/a | _err = IsAliasFile(&_self->ob_itself, |
|---|
| 1342 | n/a | &aliasFileFlag, |
|---|
| 1343 | n/a | &folderFlag); |
|---|
| 1344 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 1345 | n/a | _res = Py_BuildValue("bb", |
|---|
| 1346 | n/a | aliasFileFlag, |
|---|
| 1347 | n/a | folderFlag); |
|---|
| 1348 | n/a | return _res; |
|---|
| 1349 | n/a | } |
|---|
| 1350 | n/a | |
|---|
| 1351 | n/a | static PyObject *FSSpec_as_pathname(FSSpecObject *_self, PyObject *_args) |
|---|
| 1352 | n/a | { |
|---|
| 1353 | n/a | PyObject *_res = NULL; |
|---|
| 1354 | n/a | |
|---|
| 1355 | n/a | char strbuf[1024]; |
|---|
| 1356 | n/a | OSErr err; |
|---|
| 1357 | n/a | |
|---|
| 1358 | n/a | if (!PyArg_ParseTuple(_args, "")) |
|---|
| 1359 | n/a | return NULL; |
|---|
| 1360 | n/a | err = _PyMac_GetFullPathname(&_self->ob_itself, strbuf, sizeof(strbuf)); |
|---|
| 1361 | n/a | if ( err ) { |
|---|
| 1362 | n/a | PyMac_Error(err); |
|---|
| 1363 | n/a | return NULL; |
|---|
| 1364 | n/a | } |
|---|
| 1365 | n/a | _res = PyString_FromString(strbuf); |
|---|
| 1366 | n/a | return _res; |
|---|
| 1367 | n/a | |
|---|
| 1368 | n/a | } |
|---|
| 1369 | n/a | |
|---|
| 1370 | n/a | static PyObject *FSSpec_as_tuple(FSSpecObject *_self, PyObject *_args) |
|---|
| 1371 | n/a | { |
|---|
| 1372 | n/a | PyObject *_res = NULL; |
|---|
| 1373 | n/a | |
|---|
| 1374 | n/a | if (!PyArg_ParseTuple(_args, "")) |
|---|
| 1375 | n/a | return NULL; |
|---|
| 1376 | n/a | _res = Py_BuildValue("(iis#)", _self->ob_itself.vRefNum, _self->ob_itself.parID, |
|---|
| 1377 | n/a | &_self->ob_itself.name[1], _self->ob_itself.name[0]); |
|---|
| 1378 | n/a | return _res; |
|---|
| 1379 | n/a | |
|---|
| 1380 | n/a | } |
|---|
| 1381 | n/a | |
|---|
| 1382 | n/a | static PyMethodDef FSSpec_methods[] = { |
|---|
| 1383 | n/a | {"FSpOpenDF", (PyCFunction)FSSpec_FSpOpenDF, 1, |
|---|
| 1384 | n/a | PyDoc_STR("(SInt8 permission) -> (short refNum)")}, |
|---|
| 1385 | n/a | {"FSpOpenRF", (PyCFunction)FSSpec_FSpOpenRF, 1, |
|---|
| 1386 | n/a | PyDoc_STR("(SInt8 permission) -> (short refNum)")}, |
|---|
| 1387 | n/a | {"FSpCreate", (PyCFunction)FSSpec_FSpCreate, 1, |
|---|
| 1388 | n/a | PyDoc_STR("(OSType creator, OSType fileType, ScriptCode scriptTag) -> None")}, |
|---|
| 1389 | n/a | {"FSpDirCreate", (PyCFunction)FSSpec_FSpDirCreate, 1, |
|---|
| 1390 | n/a | PyDoc_STR("(ScriptCode scriptTag) -> (long createdDirID)")}, |
|---|
| 1391 | n/a | {"FSpDelete", (PyCFunction)FSSpec_FSpDelete, 1, |
|---|
| 1392 | n/a | PyDoc_STR("() -> None")}, |
|---|
| 1393 | n/a | {"FSpGetFInfo", (PyCFunction)FSSpec_FSpGetFInfo, 1, |
|---|
| 1394 | n/a | PyDoc_STR("() -> (FInfo fndrInfo)")}, |
|---|
| 1395 | n/a | {"FSpSetFInfo", (PyCFunction)FSSpec_FSpSetFInfo, 1, |
|---|
| 1396 | n/a | PyDoc_STR("(FInfo fndrInfo) -> None")}, |
|---|
| 1397 | n/a | {"FSpSetFLock", (PyCFunction)FSSpec_FSpSetFLock, 1, |
|---|
| 1398 | n/a | PyDoc_STR("() -> None")}, |
|---|
| 1399 | n/a | {"FSpRstFLock", (PyCFunction)FSSpec_FSpRstFLock, 1, |
|---|
| 1400 | n/a | PyDoc_STR("() -> None")}, |
|---|
| 1401 | n/a | {"FSpRename", (PyCFunction)FSSpec_FSpRename, 1, |
|---|
| 1402 | n/a | PyDoc_STR("(Str255 newName) -> None")}, |
|---|
| 1403 | n/a | {"FSpCatMove", (PyCFunction)FSSpec_FSpCatMove, 1, |
|---|
| 1404 | n/a | PyDoc_STR("(FSSpec dest) -> None")}, |
|---|
| 1405 | n/a | {"FSpExchangeFiles", (PyCFunction)FSSpec_FSpExchangeFiles, 1, |
|---|
| 1406 | n/a | PyDoc_STR("(FSSpec dest) -> None")}, |
|---|
| 1407 | n/a | {"FSpMakeFSRef", (PyCFunction)FSSpec_FSpMakeFSRef, 1, |
|---|
| 1408 | n/a | PyDoc_STR("() -> (FSRef newRef)")}, |
|---|
| 1409 | n/a | {"NewAliasMinimal", (PyCFunction)FSSpec_NewAliasMinimal, 1, |
|---|
| 1410 | n/a | PyDoc_STR("() -> (AliasHandle alias)")}, |
|---|
| 1411 | n/a | {"IsAliasFile", (PyCFunction)FSSpec_IsAliasFile, 1, |
|---|
| 1412 | n/a | PyDoc_STR("() -> (Boolean aliasFileFlag, Boolean folderFlag)")}, |
|---|
| 1413 | n/a | {"as_pathname", (PyCFunction)FSSpec_as_pathname, 1, |
|---|
| 1414 | n/a | PyDoc_STR("() -> string")}, |
|---|
| 1415 | n/a | {"as_tuple", (PyCFunction)FSSpec_as_tuple, 1, |
|---|
| 1416 | n/a | PyDoc_STR("() -> (vRefNum, dirID, name)")}, |
|---|
| 1417 | n/a | {NULL, NULL, 0} |
|---|
| 1418 | n/a | }; |
|---|
| 1419 | n/a | |
|---|
| 1420 | n/a | static PyObject *FSSpec_get_data(FSSpecObject *self, void *closure) |
|---|
| 1421 | n/a | { |
|---|
| 1422 | n/a | return PyString_FromStringAndSize((char *)&self->ob_itself, sizeof(self->ob_itself)); |
|---|
| 1423 | n/a | } |
|---|
| 1424 | n/a | |
|---|
| 1425 | n/a | #define FSSpec_set_data NULL |
|---|
| 1426 | n/a | |
|---|
| 1427 | n/a | static PyGetSetDef FSSpec_getsetlist[] = { |
|---|
| 1428 | n/a | {"data", (getter)FSSpec_get_data, (setter)FSSpec_set_data, "Raw data of the FSSpec object"}, |
|---|
| 1429 | n/a | {NULL, NULL, NULL, NULL}, |
|---|
| 1430 | n/a | }; |
|---|
| 1431 | n/a | |
|---|
| 1432 | n/a | |
|---|
| 1433 | n/a | #define FSSpec_compare NULL |
|---|
| 1434 | n/a | |
|---|
| 1435 | n/a | static PyObject * FSSpec_repr(FSSpecObject *self) |
|---|
| 1436 | n/a | { |
|---|
| 1437 | n/a | char buf[512]; |
|---|
| 1438 | n/a | PyOS_snprintf(buf, sizeof(buf), "%s((%d, %ld, '%.*s'))", |
|---|
| 1439 | n/a | self->ob_type->tp_name, |
|---|
| 1440 | n/a | self->ob_itself.vRefNum, |
|---|
| 1441 | n/a | self->ob_itself.parID, |
|---|
| 1442 | n/a | self->ob_itself.name[0], self->ob_itself.name+1); |
|---|
| 1443 | n/a | return PyString_FromString(buf); |
|---|
| 1444 | n/a | } |
|---|
| 1445 | n/a | |
|---|
| 1446 | n/a | #define FSSpec_hash NULL |
|---|
| 1447 | n/a | static int FSSpec_tp_init(PyObject *_self, PyObject *_args, PyObject *_kwds) |
|---|
| 1448 | n/a | { |
|---|
| 1449 | n/a | PyObject *v = NULL; |
|---|
| 1450 | n/a | char *rawdata = NULL; |
|---|
| 1451 | n/a | int rawdatalen = 0; |
|---|
| 1452 | n/a | static char *kw[] = {"itself", "rawdata", 0}; |
|---|
| 1453 | n/a | |
|---|
| 1454 | n/a | if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "|Os#", kw, &v, &rawdata, &rawdatalen)) |
|---|
| 1455 | n/a | return -1; |
|---|
| 1456 | n/a | if (v && rawdata) |
|---|
| 1457 | n/a | { |
|---|
| 1458 | n/a | PyErr_SetString(PyExc_TypeError, "Only one of itself or rawdata may be specified"); |
|---|
| 1459 | n/a | return -1; |
|---|
| 1460 | n/a | } |
|---|
| 1461 | n/a | if (!v && !rawdata) |
|---|
| 1462 | n/a | { |
|---|
| 1463 | n/a | PyErr_SetString(PyExc_TypeError, "One of itself or rawdata must be specified"); |
|---|
| 1464 | n/a | return -1; |
|---|
| 1465 | n/a | } |
|---|
| 1466 | n/a | if (rawdata) |
|---|
| 1467 | n/a | { |
|---|
| 1468 | n/a | if (rawdatalen != sizeof(FSSpec)) |
|---|
| 1469 | n/a | { |
|---|
| 1470 | n/a | PyErr_SetString(PyExc_TypeError, "FSSpec rawdata incorrect size"); |
|---|
| 1471 | n/a | return -1; |
|---|
| 1472 | n/a | } |
|---|
| 1473 | n/a | memcpy(&((FSSpecObject *)_self)->ob_itself, rawdata, rawdatalen); |
|---|
| 1474 | n/a | return 0; |
|---|
| 1475 | n/a | } |
|---|
| 1476 | n/a | if (PyMac_GetFSSpec(v, &((FSSpecObject *)_self)->ob_itself)) return 0; |
|---|
| 1477 | n/a | return -1; |
|---|
| 1478 | n/a | } |
|---|
| 1479 | n/a | |
|---|
| 1480 | n/a | #define FSSpec_tp_alloc PyType_GenericAlloc |
|---|
| 1481 | n/a | |
|---|
| 1482 | n/a | static PyObject *FSSpec_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) |
|---|
| 1483 | n/a | { |
|---|
| 1484 | n/a | PyObject *self; |
|---|
| 1485 | n/a | |
|---|
| 1486 | n/a | if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; |
|---|
| 1487 | n/a | memset(&((FSSpecObject *)self)->ob_itself, 0, sizeof(FSSpec)); |
|---|
| 1488 | n/a | return self; |
|---|
| 1489 | n/a | } |
|---|
| 1490 | n/a | |
|---|
| 1491 | n/a | #define FSSpec_tp_free PyObject_Del |
|---|
| 1492 | n/a | |
|---|
| 1493 | n/a | |
|---|
| 1494 | n/a | static PyTypeObject FSSpec_Type = { |
|---|
| 1495 | n/a | PyObject_HEAD_INIT(NULL) |
|---|
| 1496 | n/a | 0, /*ob_size*/ |
|---|
| 1497 | n/a | "Carbon.File.FSSpec", /*tp_name*/ |
|---|
| 1498 | n/a | sizeof(FSSpecObject), /*tp_basicsize*/ |
|---|
| 1499 | n/a | 0, /*tp_itemsize*/ |
|---|
| 1500 | n/a | /* methods */ |
|---|
| 1501 | n/a | (destructor) FSSpec_dealloc, /*tp_dealloc*/ |
|---|
| 1502 | n/a | 0, /*tp_print*/ |
|---|
| 1503 | n/a | (getattrfunc)0, /*tp_getattr*/ |
|---|
| 1504 | n/a | (setattrfunc)0, /*tp_setattr*/ |
|---|
| 1505 | n/a | (cmpfunc) FSSpec_compare, /*tp_compare*/ |
|---|
| 1506 | n/a | (reprfunc) FSSpec_repr, /*tp_repr*/ |
|---|
| 1507 | n/a | (PyNumberMethods *)0, /* tp_as_number */ |
|---|
| 1508 | n/a | (PySequenceMethods *)0, /* tp_as_sequence */ |
|---|
| 1509 | n/a | (PyMappingMethods *)0, /* tp_as_mapping */ |
|---|
| 1510 | n/a | (hashfunc) FSSpec_hash, /*tp_hash*/ |
|---|
| 1511 | n/a | 0, /*tp_call*/ |
|---|
| 1512 | n/a | 0, /*tp_str*/ |
|---|
| 1513 | n/a | PyObject_GenericGetAttr, /*tp_getattro*/ |
|---|
| 1514 | n/a | PyObject_GenericSetAttr, /*tp_setattro */ |
|---|
| 1515 | n/a | 0, /*tp_as_buffer*/ |
|---|
| 1516 | n/a | Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */ |
|---|
| 1517 | n/a | 0, /*tp_doc*/ |
|---|
| 1518 | n/a | 0, /*tp_traverse*/ |
|---|
| 1519 | n/a | 0, /*tp_clear*/ |
|---|
| 1520 | n/a | 0, /*tp_richcompare*/ |
|---|
| 1521 | n/a | 0, /*tp_weaklistoffset*/ |
|---|
| 1522 | n/a | 0, /*tp_iter*/ |
|---|
| 1523 | n/a | 0, /*tp_iternext*/ |
|---|
| 1524 | n/a | FSSpec_methods, /* tp_methods */ |
|---|
| 1525 | n/a | 0, /*tp_members*/ |
|---|
| 1526 | n/a | FSSpec_getsetlist, /*tp_getset*/ |
|---|
| 1527 | n/a | 0, /*tp_base*/ |
|---|
| 1528 | n/a | 0, /*tp_dict*/ |
|---|
| 1529 | n/a | 0, /*tp_descr_get*/ |
|---|
| 1530 | n/a | 0, /*tp_descr_set*/ |
|---|
| 1531 | n/a | 0, /*tp_dictoffset*/ |
|---|
| 1532 | n/a | FSSpec_tp_init, /* tp_init */ |
|---|
| 1533 | n/a | FSSpec_tp_alloc, /* tp_alloc */ |
|---|
| 1534 | n/a | FSSpec_tp_new, /* tp_new */ |
|---|
| 1535 | n/a | FSSpec_tp_free, /* tp_free */ |
|---|
| 1536 | n/a | }; |
|---|
| 1537 | n/a | |
|---|
| 1538 | n/a | #endif /* !__LP64__ */ |
|---|
| 1539 | n/a | /* --------------------- End object type FSSpec --------------------- */ |
|---|
| 1540 | n/a | |
|---|
| 1541 | n/a | |
|---|
| 1542 | n/a | /* ----------------------- Object type FSRef ------------------------ */ |
|---|
| 1543 | n/a | |
|---|
| 1544 | n/a | static PyTypeObject FSRef_Type; |
|---|
| 1545 | n/a | |
|---|
| 1546 | n/a | #define FSRef_Check(x) ((x)->ob_type == &FSRef_Type || PyObject_TypeCheck((x), &FSRef_Type)) |
|---|
| 1547 | n/a | |
|---|
| 1548 | n/a | typedef struct FSRefObject { |
|---|
| 1549 | n/a | PyObject_HEAD |
|---|
| 1550 | n/a | FSRef ob_itself; |
|---|
| 1551 | n/a | } FSRefObject; |
|---|
| 1552 | n/a | |
|---|
| 1553 | n/a | static PyObject *FSRef_New(FSRef *itself) |
|---|
| 1554 | n/a | { |
|---|
| 1555 | n/a | FSRefObject *it; |
|---|
| 1556 | n/a | if (itself == NULL) return PyMac_Error(resNotFound); |
|---|
| 1557 | n/a | it = PyObject_NEW(FSRefObject, &FSRef_Type); |
|---|
| 1558 | n/a | if (it == NULL) return NULL; |
|---|
| 1559 | n/a | it->ob_itself = *itself; |
|---|
| 1560 | n/a | return (PyObject *)it; |
|---|
| 1561 | n/a | } |
|---|
| 1562 | n/a | |
|---|
| 1563 | n/a | static void FSRef_dealloc(FSRefObject *self) |
|---|
| 1564 | n/a | { |
|---|
| 1565 | n/a | /* Cleanup of self->ob_itself goes here */ |
|---|
| 1566 | n/a | self->ob_type->tp_free((PyObject *)self); |
|---|
| 1567 | n/a | } |
|---|
| 1568 | n/a | |
|---|
| 1569 | n/a | static PyObject *FSRef_FSMakeFSRefUnicode(FSRefObject *_self, PyObject *_args) |
|---|
| 1570 | n/a | { |
|---|
| 1571 | n/a | PyObject *_res = NULL; |
|---|
| 1572 | n/a | OSErr _err; |
|---|
| 1573 | n/a | UniChar *nameLength__in__; |
|---|
| 1574 | n/a | UniCharCount nameLength__len__; |
|---|
| 1575 | n/a | int nameLength__in_len__; |
|---|
| 1576 | n/a | TextEncoding textEncodingHint; |
|---|
| 1577 | n/a | FSRef newRef; |
|---|
| 1578 | n/a | if (!PyArg_ParseTuple(_args, "u#l", |
|---|
| 1579 | n/a | &nameLength__in__, &nameLength__in_len__, |
|---|
| 1580 | n/a | &textEncodingHint)) |
|---|
| 1581 | n/a | return NULL; |
|---|
| 1582 | n/a | nameLength__len__ = nameLength__in_len__; |
|---|
| 1583 | n/a | _err = FSMakeFSRefUnicode(&_self->ob_itself, |
|---|
| 1584 | n/a | nameLength__len__, nameLength__in__, |
|---|
| 1585 | n/a | textEncodingHint, |
|---|
| 1586 | n/a | &newRef); |
|---|
| 1587 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 1588 | n/a | _res = Py_BuildValue("O&", |
|---|
| 1589 | n/a | FSRef_New, &newRef); |
|---|
| 1590 | n/a | return _res; |
|---|
| 1591 | n/a | } |
|---|
| 1592 | n/a | |
|---|
| 1593 | n/a | static PyObject *FSRef_FSCompareFSRefs(FSRefObject *_self, PyObject *_args) |
|---|
| 1594 | n/a | { |
|---|
| 1595 | n/a | PyObject *_res = NULL; |
|---|
| 1596 | n/a | OSErr _err; |
|---|
| 1597 | n/a | FSRef ref2; |
|---|
| 1598 | n/a | if (!PyArg_ParseTuple(_args, "O&", |
|---|
| 1599 | n/a | FSRef_Convert, &ref2)) |
|---|
| 1600 | n/a | return NULL; |
|---|
| 1601 | n/a | _err = FSCompareFSRefs(&_self->ob_itself, |
|---|
| 1602 | n/a | &ref2); |
|---|
| 1603 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 1604 | n/a | Py_INCREF(Py_None); |
|---|
| 1605 | n/a | _res = Py_None; |
|---|
| 1606 | n/a | return _res; |
|---|
| 1607 | n/a | } |
|---|
| 1608 | n/a | |
|---|
| 1609 | n/a | static PyObject *FSRef_FSCreateFileUnicode(FSRefObject *_self, PyObject *_args) |
|---|
| 1610 | n/a | { |
|---|
| 1611 | n/a | PyObject *_res = NULL; |
|---|
| 1612 | n/a | OSErr _err; |
|---|
| 1613 | n/a | UniChar *nameLength__in__; |
|---|
| 1614 | n/a | UniCharCount nameLength__len__; |
|---|
| 1615 | n/a | int nameLength__in_len__; |
|---|
| 1616 | n/a | FSCatalogInfoBitmap whichInfo; |
|---|
| 1617 | n/a | FSCatalogInfo catalogInfo; |
|---|
| 1618 | n/a | FSRef newRef; |
|---|
| 1619 | n/a | #ifndef __LP64__ |
|---|
| 1620 | n/a | FSSpec newSpec; |
|---|
| 1621 | n/a | #endif |
|---|
| 1622 | n/a | if (!PyArg_ParseTuple(_args, "u#lO&", |
|---|
| 1623 | n/a | &nameLength__in__, &nameLength__in_len__, |
|---|
| 1624 | n/a | &whichInfo, |
|---|
| 1625 | n/a | FSCatalogInfo_Convert, &catalogInfo)) |
|---|
| 1626 | n/a | return NULL; |
|---|
| 1627 | n/a | nameLength__len__ = nameLength__in_len__; |
|---|
| 1628 | n/a | _err = FSCreateFileUnicode(&_self->ob_itself, |
|---|
| 1629 | n/a | nameLength__len__, nameLength__in__, |
|---|
| 1630 | n/a | whichInfo, |
|---|
| 1631 | n/a | &catalogInfo, |
|---|
| 1632 | n/a | &newRef, |
|---|
| 1633 | n/a | #ifndef __LP64__ |
|---|
| 1634 | n/a | &newSpec |
|---|
| 1635 | n/a | #else /* __LP64__ */ |
|---|
| 1636 | n/a | NULL |
|---|
| 1637 | n/a | #endif /* __LP64__*/ |
|---|
| 1638 | n/a | ); |
|---|
| 1639 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 1640 | n/a | |
|---|
| 1641 | n/a | #ifndef __LP64__ |
|---|
| 1642 | n/a | _res = Py_BuildValue("O&O&", |
|---|
| 1643 | n/a | FSRef_New, &newRef, |
|---|
| 1644 | n/a | FSSpec_New, &newSpec); |
|---|
| 1645 | n/a | #else /* __LP64__ */ |
|---|
| 1646 | n/a | _res = Py_BuildValue("O&O", FSRef_New, &newRef, Py_None); |
|---|
| 1647 | n/a | #endif /* __LP64__ */ |
|---|
| 1648 | n/a | |
|---|
| 1649 | n/a | return _res; |
|---|
| 1650 | n/a | } |
|---|
| 1651 | n/a | |
|---|
| 1652 | n/a | static PyObject *FSRef_FSCreateDirectoryUnicode(FSRefObject *_self, PyObject *_args) |
|---|
| 1653 | n/a | { |
|---|
| 1654 | n/a | PyObject *_res = NULL; |
|---|
| 1655 | n/a | OSErr _err; |
|---|
| 1656 | n/a | UniChar *nameLength__in__; |
|---|
| 1657 | n/a | UniCharCount nameLength__len__; |
|---|
| 1658 | n/a | int nameLength__in_len__; |
|---|
| 1659 | n/a | FSCatalogInfoBitmap whichInfo; |
|---|
| 1660 | n/a | FSCatalogInfo catalogInfo; |
|---|
| 1661 | n/a | FSRef newRef; |
|---|
| 1662 | n/a | #ifndef __LP64__ |
|---|
| 1663 | n/a | FSSpec newSpec; |
|---|
| 1664 | n/a | #endif /* !__LP64__ */ |
|---|
| 1665 | n/a | UInt32 newDirID; |
|---|
| 1666 | n/a | if (!PyArg_ParseTuple(_args, "u#lO&", |
|---|
| 1667 | n/a | &nameLength__in__, &nameLength__in_len__, |
|---|
| 1668 | n/a | &whichInfo, |
|---|
| 1669 | n/a | FSCatalogInfo_Convert, &catalogInfo)) |
|---|
| 1670 | n/a | return NULL; |
|---|
| 1671 | n/a | nameLength__len__ = nameLength__in_len__; |
|---|
| 1672 | n/a | _err = FSCreateDirectoryUnicode(&_self->ob_itself, |
|---|
| 1673 | n/a | nameLength__len__, nameLength__in__, |
|---|
| 1674 | n/a | whichInfo, |
|---|
| 1675 | n/a | &catalogInfo, |
|---|
| 1676 | n/a | &newRef, |
|---|
| 1677 | n/a | #ifndef __LP64__ |
|---|
| 1678 | n/a | &newSpec, |
|---|
| 1679 | n/a | #else /* !__LP64__ */ |
|---|
| 1680 | n/a | NULL, |
|---|
| 1681 | n/a | #endif /* !__LP64__ */ |
|---|
| 1682 | n/a | &newDirID); |
|---|
| 1683 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 1684 | n/a | |
|---|
| 1685 | n/a | #ifndef __LP64__ |
|---|
| 1686 | n/a | _res = Py_BuildValue("O&O&l", |
|---|
| 1687 | n/a | FSRef_New, &newRef, |
|---|
| 1688 | n/a | FSSpec_New, &newSpec, |
|---|
| 1689 | n/a | newDirID); |
|---|
| 1690 | n/a | #else /* __LP64__ */ |
|---|
| 1691 | n/a | _res = Py_BuildValue("O&Ol", |
|---|
| 1692 | n/a | FSRef_New, &newRef, |
|---|
| 1693 | n/a | Py_None, |
|---|
| 1694 | n/a | newDirID); |
|---|
| 1695 | n/a | #endif /* __LP64__ */ |
|---|
| 1696 | n/a | return _res; |
|---|
| 1697 | n/a | } |
|---|
| 1698 | n/a | |
|---|
| 1699 | n/a | static PyObject *FSRef_FSDeleteObject(FSRefObject *_self, PyObject *_args) |
|---|
| 1700 | n/a | { |
|---|
| 1701 | n/a | PyObject *_res = NULL; |
|---|
| 1702 | n/a | OSErr _err; |
|---|
| 1703 | n/a | if (!PyArg_ParseTuple(_args, "")) |
|---|
| 1704 | n/a | return NULL; |
|---|
| 1705 | n/a | _err = FSDeleteObject(&_self->ob_itself); |
|---|
| 1706 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 1707 | n/a | Py_INCREF(Py_None); |
|---|
| 1708 | n/a | _res = Py_None; |
|---|
| 1709 | n/a | return _res; |
|---|
| 1710 | n/a | } |
|---|
| 1711 | n/a | |
|---|
| 1712 | n/a | static PyObject *FSRef_FSMoveObject(FSRefObject *_self, PyObject *_args) |
|---|
| 1713 | n/a | { |
|---|
| 1714 | n/a | PyObject *_res = NULL; |
|---|
| 1715 | n/a | OSErr _err; |
|---|
| 1716 | n/a | FSRef destDirectory; |
|---|
| 1717 | n/a | FSRef newRef; |
|---|
| 1718 | n/a | if (!PyArg_ParseTuple(_args, "O&", |
|---|
| 1719 | n/a | FSRef_Convert, &destDirectory)) |
|---|
| 1720 | n/a | return NULL; |
|---|
| 1721 | n/a | _err = FSMoveObject(&_self->ob_itself, |
|---|
| 1722 | n/a | &destDirectory, |
|---|
| 1723 | n/a | &newRef); |
|---|
| 1724 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 1725 | n/a | _res = Py_BuildValue("O&", |
|---|
| 1726 | n/a | FSRef_New, &newRef); |
|---|
| 1727 | n/a | return _res; |
|---|
| 1728 | n/a | } |
|---|
| 1729 | n/a | |
|---|
| 1730 | n/a | static PyObject *FSRef_FSExchangeObjects(FSRefObject *_self, PyObject *_args) |
|---|
| 1731 | n/a | { |
|---|
| 1732 | n/a | PyObject *_res = NULL; |
|---|
| 1733 | n/a | OSErr _err; |
|---|
| 1734 | n/a | FSRef destRef; |
|---|
| 1735 | n/a | if (!PyArg_ParseTuple(_args, "O&", |
|---|
| 1736 | n/a | FSRef_Convert, &destRef)) |
|---|
| 1737 | n/a | return NULL; |
|---|
| 1738 | n/a | _err = FSExchangeObjects(&_self->ob_itself, |
|---|
| 1739 | n/a | &destRef); |
|---|
| 1740 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 1741 | n/a | Py_INCREF(Py_None); |
|---|
| 1742 | n/a | _res = Py_None; |
|---|
| 1743 | n/a | return _res; |
|---|
| 1744 | n/a | } |
|---|
| 1745 | n/a | |
|---|
| 1746 | n/a | static PyObject *FSRef_FSRenameUnicode(FSRefObject *_self, PyObject *_args) |
|---|
| 1747 | n/a | { |
|---|
| 1748 | n/a | PyObject *_res = NULL; |
|---|
| 1749 | n/a | OSErr _err; |
|---|
| 1750 | n/a | UniChar *nameLength__in__; |
|---|
| 1751 | n/a | UniCharCount nameLength__len__; |
|---|
| 1752 | n/a | int nameLength__in_len__; |
|---|
| 1753 | n/a | TextEncoding textEncodingHint; |
|---|
| 1754 | n/a | FSRef newRef; |
|---|
| 1755 | n/a | if (!PyArg_ParseTuple(_args, "u#l", |
|---|
| 1756 | n/a | &nameLength__in__, &nameLength__in_len__, |
|---|
| 1757 | n/a | &textEncodingHint)) |
|---|
| 1758 | n/a | return NULL; |
|---|
| 1759 | n/a | nameLength__len__ = nameLength__in_len__; |
|---|
| 1760 | n/a | _err = FSRenameUnicode(&_self->ob_itself, |
|---|
| 1761 | n/a | nameLength__len__, nameLength__in__, |
|---|
| 1762 | n/a | textEncodingHint, |
|---|
| 1763 | n/a | &newRef); |
|---|
| 1764 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 1765 | n/a | _res = Py_BuildValue("O&", |
|---|
| 1766 | n/a | FSRef_New, &newRef); |
|---|
| 1767 | n/a | return _res; |
|---|
| 1768 | n/a | } |
|---|
| 1769 | n/a | |
|---|
| 1770 | n/a | static PyObject *FSRef_FSGetCatalogInfo(FSRefObject *_self, PyObject *_args) |
|---|
| 1771 | n/a | { |
|---|
| 1772 | n/a | PyObject *_res = NULL; |
|---|
| 1773 | n/a | OSErr _err; |
|---|
| 1774 | n/a | FSCatalogInfoBitmap whichInfo; |
|---|
| 1775 | n/a | FSCatalogInfo catalogInfo; |
|---|
| 1776 | n/a | HFSUniStr255 outName; |
|---|
| 1777 | n/a | #ifndef __LP64__ |
|---|
| 1778 | n/a | FSSpec fsSpec; |
|---|
| 1779 | n/a | #endif /* !__LP64__ */ |
|---|
| 1780 | n/a | FSRef parentRef; |
|---|
| 1781 | n/a | if (!PyArg_ParseTuple(_args, "l", |
|---|
| 1782 | n/a | &whichInfo)) |
|---|
| 1783 | n/a | return NULL; |
|---|
| 1784 | n/a | _err = FSGetCatalogInfo(&_self->ob_itself, |
|---|
| 1785 | n/a | whichInfo, |
|---|
| 1786 | n/a | &catalogInfo, |
|---|
| 1787 | n/a | &outName, |
|---|
| 1788 | n/a | #ifndef __LP64__ |
|---|
| 1789 | n/a | &fsSpec, |
|---|
| 1790 | n/a | #else /* __LP64__ */ |
|---|
| 1791 | n/a | NULL, |
|---|
| 1792 | n/a | #endif /* __LP64__ */ |
|---|
| 1793 | n/a | &parentRef); |
|---|
| 1794 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 1795 | n/a | |
|---|
| 1796 | n/a | #ifndef __LP64__ |
|---|
| 1797 | n/a | _res = Py_BuildValue("O&O&O&O&", |
|---|
| 1798 | n/a | FSCatalogInfo_New, &catalogInfo, |
|---|
| 1799 | n/a | PyMac_BuildHFSUniStr255, &outName, |
|---|
| 1800 | n/a | FSSpec_New, &fsSpec, |
|---|
| 1801 | n/a | FSRef_New, &parentRef); |
|---|
| 1802 | n/a | #else /* __LP64__ */ |
|---|
| 1803 | n/a | _res = Py_BuildValue("O&O&OO&", |
|---|
| 1804 | n/a | FSCatalogInfo_New, &catalogInfo, |
|---|
| 1805 | n/a | PyMac_BuildHFSUniStr255, &outName, |
|---|
| 1806 | n/a | Py_None, |
|---|
| 1807 | n/a | FSRef_New, &parentRef); |
|---|
| 1808 | n/a | #endif /* __LP64__ */ |
|---|
| 1809 | n/a | return _res; |
|---|
| 1810 | n/a | } |
|---|
| 1811 | n/a | |
|---|
| 1812 | n/a | static PyObject *FSRef_FSSetCatalogInfo(FSRefObject *_self, PyObject *_args) |
|---|
| 1813 | n/a | { |
|---|
| 1814 | n/a | PyObject *_res = NULL; |
|---|
| 1815 | n/a | OSErr _err; |
|---|
| 1816 | n/a | FSCatalogInfoBitmap whichInfo; |
|---|
| 1817 | n/a | FSCatalogInfo catalogInfo; |
|---|
| 1818 | n/a | if (!PyArg_ParseTuple(_args, "lO&", |
|---|
| 1819 | n/a | &whichInfo, |
|---|
| 1820 | n/a | FSCatalogInfo_Convert, &catalogInfo)) |
|---|
| 1821 | n/a | return NULL; |
|---|
| 1822 | n/a | _err = FSSetCatalogInfo(&_self->ob_itself, |
|---|
| 1823 | n/a | whichInfo, |
|---|
| 1824 | n/a | &catalogInfo); |
|---|
| 1825 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 1826 | n/a | Py_INCREF(Py_None); |
|---|
| 1827 | n/a | _res = Py_None; |
|---|
| 1828 | n/a | return _res; |
|---|
| 1829 | n/a | } |
|---|
| 1830 | n/a | |
|---|
| 1831 | n/a | static PyObject *FSRef_FSCreateFork(FSRefObject *_self, PyObject *_args) |
|---|
| 1832 | n/a | { |
|---|
| 1833 | n/a | PyObject *_res = NULL; |
|---|
| 1834 | n/a | OSErr _err; |
|---|
| 1835 | n/a | UniChar *forkNameLength__in__; |
|---|
| 1836 | n/a | UniCharCount forkNameLength__len__; |
|---|
| 1837 | n/a | int forkNameLength__in_len__; |
|---|
| 1838 | n/a | if (!PyArg_ParseTuple(_args, "u#", |
|---|
| 1839 | n/a | &forkNameLength__in__, &forkNameLength__in_len__)) |
|---|
| 1840 | n/a | return NULL; |
|---|
| 1841 | n/a | forkNameLength__len__ = forkNameLength__in_len__; |
|---|
| 1842 | n/a | _err = FSCreateFork(&_self->ob_itself, |
|---|
| 1843 | n/a | forkNameLength__len__, forkNameLength__in__); |
|---|
| 1844 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 1845 | n/a | Py_INCREF(Py_None); |
|---|
| 1846 | n/a | _res = Py_None; |
|---|
| 1847 | n/a | return _res; |
|---|
| 1848 | n/a | } |
|---|
| 1849 | n/a | |
|---|
| 1850 | n/a | static PyObject *FSRef_FSDeleteFork(FSRefObject *_self, PyObject *_args) |
|---|
| 1851 | n/a | { |
|---|
| 1852 | n/a | PyObject *_res = NULL; |
|---|
| 1853 | n/a | OSErr _err; |
|---|
| 1854 | n/a | UniChar *forkNameLength__in__; |
|---|
| 1855 | n/a | UniCharCount forkNameLength__len__; |
|---|
| 1856 | n/a | int forkNameLength__in_len__; |
|---|
| 1857 | n/a | if (!PyArg_ParseTuple(_args, "u#", |
|---|
| 1858 | n/a | &forkNameLength__in__, &forkNameLength__in_len__)) |
|---|
| 1859 | n/a | return NULL; |
|---|
| 1860 | n/a | forkNameLength__len__ = forkNameLength__in_len__; |
|---|
| 1861 | n/a | _err = FSDeleteFork(&_self->ob_itself, |
|---|
| 1862 | n/a | forkNameLength__len__, forkNameLength__in__); |
|---|
| 1863 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 1864 | n/a | Py_INCREF(Py_None); |
|---|
| 1865 | n/a | _res = Py_None; |
|---|
| 1866 | n/a | return _res; |
|---|
| 1867 | n/a | } |
|---|
| 1868 | n/a | |
|---|
| 1869 | n/a | static PyObject *FSRef_FSOpenFork(FSRefObject *_self, PyObject *_args) |
|---|
| 1870 | n/a | { |
|---|
| 1871 | n/a | PyObject *_res = NULL; |
|---|
| 1872 | n/a | OSErr _err; |
|---|
| 1873 | n/a | UniChar *forkNameLength__in__; |
|---|
| 1874 | n/a | UniCharCount forkNameLength__len__; |
|---|
| 1875 | n/a | int forkNameLength__in_len__; |
|---|
| 1876 | n/a | SInt8 permissions; |
|---|
| 1877 | n/a | FSIORefNum forkRefNum; |
|---|
| 1878 | n/a | if (!PyArg_ParseTuple(_args, "u#b", |
|---|
| 1879 | n/a | &forkNameLength__in__, &forkNameLength__in_len__, |
|---|
| 1880 | n/a | &permissions)) |
|---|
| 1881 | n/a | return NULL; |
|---|
| 1882 | n/a | forkNameLength__len__ = forkNameLength__in_len__; |
|---|
| 1883 | n/a | _err = FSOpenFork(&_self->ob_itself, |
|---|
| 1884 | n/a | forkNameLength__len__, forkNameLength__in__, |
|---|
| 1885 | n/a | permissions, |
|---|
| 1886 | n/a | &forkRefNum); |
|---|
| 1887 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 1888 | n/a | _res = Py_BuildValue("h", |
|---|
| 1889 | n/a | forkRefNum); |
|---|
| 1890 | n/a | return _res; |
|---|
| 1891 | n/a | } |
|---|
| 1892 | n/a | |
|---|
| 1893 | n/a | static PyObject *FSRef_FNNotify(FSRefObject *_self, PyObject *_args) |
|---|
| 1894 | n/a | { |
|---|
| 1895 | n/a | PyObject *_res = NULL; |
|---|
| 1896 | n/a | OSStatus _err; |
|---|
| 1897 | n/a | FNMessage message; |
|---|
| 1898 | n/a | OptionBits flags; |
|---|
| 1899 | n/a | if (!PyArg_ParseTuple(_args, "ll", |
|---|
| 1900 | n/a | &message, |
|---|
| 1901 | n/a | &flags)) |
|---|
| 1902 | n/a | return NULL; |
|---|
| 1903 | n/a | _err = FNNotify(&_self->ob_itself, |
|---|
| 1904 | n/a | message, |
|---|
| 1905 | n/a | flags); |
|---|
| 1906 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 1907 | n/a | Py_INCREF(Py_None); |
|---|
| 1908 | n/a | _res = Py_None; |
|---|
| 1909 | n/a | return _res; |
|---|
| 1910 | n/a | } |
|---|
| 1911 | n/a | |
|---|
| 1912 | n/a | static PyObject *FSRef_FSNewAliasMinimal(FSRefObject *_self, PyObject *_args) |
|---|
| 1913 | n/a | { |
|---|
| 1914 | n/a | PyObject *_res = NULL; |
|---|
| 1915 | n/a | OSErr _err; |
|---|
| 1916 | n/a | AliasHandle inAlias; |
|---|
| 1917 | n/a | if (!PyArg_ParseTuple(_args, "")) |
|---|
| 1918 | n/a | return NULL; |
|---|
| 1919 | n/a | _err = FSNewAliasMinimal(&_self->ob_itself, |
|---|
| 1920 | n/a | &inAlias); |
|---|
| 1921 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 1922 | n/a | _res = Py_BuildValue("O&", |
|---|
| 1923 | n/a | Alias_New, inAlias); |
|---|
| 1924 | n/a | return _res; |
|---|
| 1925 | n/a | } |
|---|
| 1926 | n/a | |
|---|
| 1927 | n/a | static PyObject *FSRef_FSIsAliasFile(FSRefObject *_self, PyObject *_args) |
|---|
| 1928 | n/a | { |
|---|
| 1929 | n/a | PyObject *_res = NULL; |
|---|
| 1930 | n/a | OSErr _err; |
|---|
| 1931 | n/a | Boolean aliasFileFlag; |
|---|
| 1932 | n/a | Boolean folderFlag; |
|---|
| 1933 | n/a | if (!PyArg_ParseTuple(_args, "")) |
|---|
| 1934 | n/a | return NULL; |
|---|
| 1935 | n/a | _err = FSIsAliasFile(&_self->ob_itself, |
|---|
| 1936 | n/a | &aliasFileFlag, |
|---|
| 1937 | n/a | &folderFlag); |
|---|
| 1938 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 1939 | n/a | _res = Py_BuildValue("bb", |
|---|
| 1940 | n/a | aliasFileFlag, |
|---|
| 1941 | n/a | folderFlag); |
|---|
| 1942 | n/a | return _res; |
|---|
| 1943 | n/a | } |
|---|
| 1944 | n/a | |
|---|
| 1945 | n/a | static PyObject *FSRef_FSRefMakePath(FSRefObject *_self, PyObject *_args) |
|---|
| 1946 | n/a | { |
|---|
| 1947 | n/a | PyObject *_res = NULL; |
|---|
| 1948 | n/a | |
|---|
| 1949 | n/a | OSStatus _err; |
|---|
| 1950 | n/a | #define MAXPATHNAME 1024 |
|---|
| 1951 | n/a | UInt8 path[MAXPATHNAME]; |
|---|
| 1952 | n/a | UInt32 maxPathSize = MAXPATHNAME; |
|---|
| 1953 | n/a | |
|---|
| 1954 | n/a | if (!PyArg_ParseTuple(_args, "")) |
|---|
| 1955 | n/a | return NULL; |
|---|
| 1956 | n/a | _err = FSRefMakePath(&_self->ob_itself, |
|---|
| 1957 | n/a | path, |
|---|
| 1958 | n/a | maxPathSize); |
|---|
| 1959 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 1960 | n/a | _res = Py_BuildValue("s", path); |
|---|
| 1961 | n/a | return _res; |
|---|
| 1962 | n/a | |
|---|
| 1963 | n/a | } |
|---|
| 1964 | n/a | |
|---|
| 1965 | n/a | static PyObject *FSRef_as_pathname(FSRefObject *_self, PyObject *_args) |
|---|
| 1966 | n/a | { |
|---|
| 1967 | n/a | PyObject *_res = NULL; |
|---|
| 1968 | n/a | |
|---|
| 1969 | n/a | if (!PyArg_ParseTuple(_args, "")) |
|---|
| 1970 | n/a | return NULL; |
|---|
| 1971 | n/a | _res = FSRef_FSRefMakePath(_self, _args); |
|---|
| 1972 | n/a | return _res; |
|---|
| 1973 | n/a | |
|---|
| 1974 | n/a | } |
|---|
| 1975 | n/a | |
|---|
| 1976 | n/a | static PyMethodDef FSRef_methods[] = { |
|---|
| 1977 | n/a | {"FSMakeFSRefUnicode", (PyCFunction)FSRef_FSMakeFSRefUnicode, 1, |
|---|
| 1978 | n/a | PyDoc_STR("(Buffer nameLength, TextEncoding textEncodingHint) -> (FSRef newRef)")}, |
|---|
| 1979 | n/a | {"FSCompareFSRefs", (PyCFunction)FSRef_FSCompareFSRefs, 1, |
|---|
| 1980 | n/a | PyDoc_STR("(FSRef ref2) -> None")}, |
|---|
| 1981 | n/a | {"FSCreateFileUnicode", (PyCFunction)FSRef_FSCreateFileUnicode, 1, |
|---|
| 1982 | n/a | PyDoc_STR("(Buffer nameLength, FSCatalogInfoBitmap whichInfo, FSCatalogInfo catalogInfo) -> (FSRef newRef, FSSpec newSpec)")}, |
|---|
| 1983 | n/a | {"FSCreateDirectoryUnicode", (PyCFunction)FSRef_FSCreateDirectoryUnicode, 1, |
|---|
| 1984 | n/a | PyDoc_STR("(Buffer nameLength, FSCatalogInfoBitmap whichInfo, FSCatalogInfo catalogInfo) -> (FSRef newRef, FSSpec newSpec, UInt32 newDirID)")}, |
|---|
| 1985 | n/a | {"FSDeleteObject", (PyCFunction)FSRef_FSDeleteObject, 1, |
|---|
| 1986 | n/a | PyDoc_STR("() -> None")}, |
|---|
| 1987 | n/a | {"FSMoveObject", (PyCFunction)FSRef_FSMoveObject, 1, |
|---|
| 1988 | n/a | PyDoc_STR("(FSRef destDirectory) -> (FSRef newRef)")}, |
|---|
| 1989 | n/a | {"FSExchangeObjects", (PyCFunction)FSRef_FSExchangeObjects, 1, |
|---|
| 1990 | n/a | PyDoc_STR("(FSRef destRef) -> None")}, |
|---|
| 1991 | n/a | {"FSRenameUnicode", (PyCFunction)FSRef_FSRenameUnicode, 1, |
|---|
| 1992 | n/a | PyDoc_STR("(Buffer nameLength, TextEncoding textEncodingHint) -> (FSRef newRef)")}, |
|---|
| 1993 | n/a | {"FSGetCatalogInfo", (PyCFunction)FSRef_FSGetCatalogInfo, 1, |
|---|
| 1994 | n/a | PyDoc_STR("(FSCatalogInfoBitmap whichInfo) -> (FSCatalogInfo catalogInfo, HFSUniStr255 outName, FSSpec fsSpec, FSRef parentRef)")}, |
|---|
| 1995 | n/a | {"FSSetCatalogInfo", (PyCFunction)FSRef_FSSetCatalogInfo, 1, |
|---|
| 1996 | n/a | PyDoc_STR("(FSCatalogInfoBitmap whichInfo, FSCatalogInfo catalogInfo) -> None")}, |
|---|
| 1997 | n/a | {"FSCreateFork", (PyCFunction)FSRef_FSCreateFork, 1, |
|---|
| 1998 | n/a | PyDoc_STR("(Buffer forkNameLength) -> None")}, |
|---|
| 1999 | n/a | {"FSDeleteFork", (PyCFunction)FSRef_FSDeleteFork, 1, |
|---|
| 2000 | n/a | PyDoc_STR("(Buffer forkNameLength) -> None")}, |
|---|
| 2001 | n/a | {"FSOpenFork", (PyCFunction)FSRef_FSOpenFork, 1, |
|---|
| 2002 | n/a | PyDoc_STR("(Buffer forkNameLength, SInt8 permissions) -> (SInt16 forkRefNum)")}, |
|---|
| 2003 | n/a | {"FNNotify", (PyCFunction)FSRef_FNNotify, 1, |
|---|
| 2004 | n/a | PyDoc_STR("(FNMessage message, OptionBits flags) -> None")}, |
|---|
| 2005 | n/a | {"FSNewAliasMinimal", (PyCFunction)FSRef_FSNewAliasMinimal, 1, |
|---|
| 2006 | n/a | PyDoc_STR("() -> (AliasHandle inAlias)")}, |
|---|
| 2007 | n/a | {"FSIsAliasFile", (PyCFunction)FSRef_FSIsAliasFile, 1, |
|---|
| 2008 | n/a | PyDoc_STR("() -> (Boolean aliasFileFlag, Boolean folderFlag)")}, |
|---|
| 2009 | n/a | {"FSRefMakePath", (PyCFunction)FSRef_FSRefMakePath, 1, |
|---|
| 2010 | n/a | PyDoc_STR("() -> string")}, |
|---|
| 2011 | n/a | {"as_pathname", (PyCFunction)FSRef_as_pathname, 1, |
|---|
| 2012 | n/a | PyDoc_STR("() -> string")}, |
|---|
| 2013 | n/a | {NULL, NULL, 0} |
|---|
| 2014 | n/a | }; |
|---|
| 2015 | n/a | |
|---|
| 2016 | n/a | static PyObject *FSRef_get_data(FSRefObject *self, void *closure) |
|---|
| 2017 | n/a | { |
|---|
| 2018 | n/a | return PyString_FromStringAndSize((char *)&self->ob_itself, sizeof(self->ob_itself)); |
|---|
| 2019 | n/a | } |
|---|
| 2020 | n/a | |
|---|
| 2021 | n/a | #define FSRef_set_data NULL |
|---|
| 2022 | n/a | |
|---|
| 2023 | n/a | static PyGetSetDef FSRef_getsetlist[] = { |
|---|
| 2024 | n/a | {"data", (getter)FSRef_get_data, (setter)FSRef_set_data, "Raw data of the FSRef object"}, |
|---|
| 2025 | n/a | {NULL, NULL, NULL, NULL}, |
|---|
| 2026 | n/a | }; |
|---|
| 2027 | n/a | |
|---|
| 2028 | n/a | |
|---|
| 2029 | n/a | #define FSRef_compare NULL |
|---|
| 2030 | n/a | |
|---|
| 2031 | n/a | #define FSRef_repr NULL |
|---|
| 2032 | n/a | |
|---|
| 2033 | n/a | #define FSRef_hash NULL |
|---|
| 2034 | n/a | static int FSRef_tp_init(PyObject *_self, PyObject *_args, PyObject *_kwds) |
|---|
| 2035 | n/a | { |
|---|
| 2036 | n/a | PyObject *v = NULL; |
|---|
| 2037 | n/a | char *rawdata = NULL; |
|---|
| 2038 | n/a | int rawdatalen = 0; |
|---|
| 2039 | n/a | static char *kw[] = {"itself", "rawdata", 0}; |
|---|
| 2040 | n/a | |
|---|
| 2041 | n/a | if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "|Os#", kw, &v, &rawdata, &rawdatalen)) |
|---|
| 2042 | n/a | return -1; |
|---|
| 2043 | n/a | if (v && rawdata) |
|---|
| 2044 | n/a | { |
|---|
| 2045 | n/a | PyErr_SetString(PyExc_TypeError, "Only one of itself or rawdata may be specified"); |
|---|
| 2046 | n/a | return -1; |
|---|
| 2047 | n/a | } |
|---|
| 2048 | n/a | if (!v && !rawdata) |
|---|
| 2049 | n/a | { |
|---|
| 2050 | n/a | PyErr_SetString(PyExc_TypeError, "One of itself or rawdata must be specified"); |
|---|
| 2051 | n/a | return -1; |
|---|
| 2052 | n/a | } |
|---|
| 2053 | n/a | if (rawdata) |
|---|
| 2054 | n/a | { |
|---|
| 2055 | n/a | if (rawdatalen != sizeof(FSRef)) |
|---|
| 2056 | n/a | { |
|---|
| 2057 | n/a | PyErr_SetString(PyExc_TypeError, "FSRef rawdata incorrect size"); |
|---|
| 2058 | n/a | return -1; |
|---|
| 2059 | n/a | } |
|---|
| 2060 | n/a | memcpy(&((FSRefObject *)_self)->ob_itself, rawdata, rawdatalen); |
|---|
| 2061 | n/a | return 0; |
|---|
| 2062 | n/a | } |
|---|
| 2063 | n/a | if (PyMac_GetFSRef(v, &((FSRefObject *)_self)->ob_itself)) return 0; |
|---|
| 2064 | n/a | return -1; |
|---|
| 2065 | n/a | } |
|---|
| 2066 | n/a | |
|---|
| 2067 | n/a | #define FSRef_tp_alloc PyType_GenericAlloc |
|---|
| 2068 | n/a | |
|---|
| 2069 | n/a | static PyObject *FSRef_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) |
|---|
| 2070 | n/a | { |
|---|
| 2071 | n/a | PyObject *self; |
|---|
| 2072 | n/a | |
|---|
| 2073 | n/a | if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; |
|---|
| 2074 | n/a | memset(&((FSRefObject *)self)->ob_itself, 0, sizeof(FSRef)); |
|---|
| 2075 | n/a | return self; |
|---|
| 2076 | n/a | } |
|---|
| 2077 | n/a | |
|---|
| 2078 | n/a | #define FSRef_tp_free PyObject_Del |
|---|
| 2079 | n/a | |
|---|
| 2080 | n/a | |
|---|
| 2081 | n/a | static PyTypeObject FSRef_Type = { |
|---|
| 2082 | n/a | PyObject_HEAD_INIT(NULL) |
|---|
| 2083 | n/a | 0, /*ob_size*/ |
|---|
| 2084 | n/a | "Carbon.File.FSRef", /*tp_name*/ |
|---|
| 2085 | n/a | sizeof(FSRefObject), /*tp_basicsize*/ |
|---|
| 2086 | n/a | 0, /*tp_itemsize*/ |
|---|
| 2087 | n/a | /* methods */ |
|---|
| 2088 | n/a | (destructor) FSRef_dealloc, /*tp_dealloc*/ |
|---|
| 2089 | n/a | 0, /*tp_print*/ |
|---|
| 2090 | n/a | (getattrfunc)0, /*tp_getattr*/ |
|---|
| 2091 | n/a | (setattrfunc)0, /*tp_setattr*/ |
|---|
| 2092 | n/a | (cmpfunc) FSRef_compare, /*tp_compare*/ |
|---|
| 2093 | n/a | (reprfunc) FSRef_repr, /*tp_repr*/ |
|---|
| 2094 | n/a | (PyNumberMethods *)0, /* tp_as_number */ |
|---|
| 2095 | n/a | (PySequenceMethods *)0, /* tp_as_sequence */ |
|---|
| 2096 | n/a | (PyMappingMethods *)0, /* tp_as_mapping */ |
|---|
| 2097 | n/a | (hashfunc) FSRef_hash, /*tp_hash*/ |
|---|
| 2098 | n/a | 0, /*tp_call*/ |
|---|
| 2099 | n/a | 0, /*tp_str*/ |
|---|
| 2100 | n/a | PyObject_GenericGetAttr, /*tp_getattro*/ |
|---|
| 2101 | n/a | PyObject_GenericSetAttr, /*tp_setattro */ |
|---|
| 2102 | n/a | 0, /*tp_as_buffer*/ |
|---|
| 2103 | n/a | Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */ |
|---|
| 2104 | n/a | 0, /*tp_doc*/ |
|---|
| 2105 | n/a | 0, /*tp_traverse*/ |
|---|
| 2106 | n/a | 0, /*tp_clear*/ |
|---|
| 2107 | n/a | 0, /*tp_richcompare*/ |
|---|
| 2108 | n/a | 0, /*tp_weaklistoffset*/ |
|---|
| 2109 | n/a | 0, /*tp_iter*/ |
|---|
| 2110 | n/a | 0, /*tp_iternext*/ |
|---|
| 2111 | n/a | FSRef_methods, /* tp_methods */ |
|---|
| 2112 | n/a | 0, /*tp_members*/ |
|---|
| 2113 | n/a | FSRef_getsetlist, /*tp_getset*/ |
|---|
| 2114 | n/a | 0, /*tp_base*/ |
|---|
| 2115 | n/a | 0, /*tp_dict*/ |
|---|
| 2116 | n/a | 0, /*tp_descr_get*/ |
|---|
| 2117 | n/a | 0, /*tp_descr_set*/ |
|---|
| 2118 | n/a | 0, /*tp_dictoffset*/ |
|---|
| 2119 | n/a | FSRef_tp_init, /* tp_init */ |
|---|
| 2120 | n/a | FSRef_tp_alloc, /* tp_alloc */ |
|---|
| 2121 | n/a | FSRef_tp_new, /* tp_new */ |
|---|
| 2122 | n/a | FSRef_tp_free, /* tp_free */ |
|---|
| 2123 | n/a | }; |
|---|
| 2124 | n/a | |
|---|
| 2125 | n/a | /* --------------------- End object type FSRef ---------------------- */ |
|---|
| 2126 | n/a | |
|---|
| 2127 | n/a | #ifndef __LP64__ |
|---|
| 2128 | n/a | static PyObject *File_UnmountVol(PyObject *_self, PyObject *_args) |
|---|
| 2129 | n/a | { |
|---|
| 2130 | n/a | PyObject *_res = NULL; |
|---|
| 2131 | n/a | OSErr _err; |
|---|
| 2132 | n/a | Str63 volName; |
|---|
| 2133 | n/a | short vRefNum; |
|---|
| 2134 | n/a | if (!PyArg_ParseTuple(_args, "O&h", |
|---|
| 2135 | n/a | PyMac_GetStr255, volName, |
|---|
| 2136 | n/a | &vRefNum)) |
|---|
| 2137 | n/a | return NULL; |
|---|
| 2138 | n/a | _err = UnmountVol(volName, |
|---|
| 2139 | n/a | vRefNum); |
|---|
| 2140 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 2141 | n/a | Py_INCREF(Py_None); |
|---|
| 2142 | n/a | _res = Py_None; |
|---|
| 2143 | n/a | return _res; |
|---|
| 2144 | n/a | } |
|---|
| 2145 | n/a | |
|---|
| 2146 | n/a | static PyObject *File_FlushVol(PyObject *_self, PyObject *_args) |
|---|
| 2147 | n/a | { |
|---|
| 2148 | n/a | PyObject *_res = NULL; |
|---|
| 2149 | n/a | OSErr _err; |
|---|
| 2150 | n/a | Str63 volName; |
|---|
| 2151 | n/a | short vRefNum; |
|---|
| 2152 | n/a | if (!PyArg_ParseTuple(_args, "O&h", |
|---|
| 2153 | n/a | PyMac_GetStr255, volName, |
|---|
| 2154 | n/a | &vRefNum)) |
|---|
| 2155 | n/a | return NULL; |
|---|
| 2156 | n/a | _err = FlushVol(volName, |
|---|
| 2157 | n/a | vRefNum); |
|---|
| 2158 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 2159 | n/a | Py_INCREF(Py_None); |
|---|
| 2160 | n/a | _res = Py_None; |
|---|
| 2161 | n/a | return _res; |
|---|
| 2162 | n/a | } |
|---|
| 2163 | n/a | |
|---|
| 2164 | n/a | static PyObject *File_HSetVol(PyObject *_self, PyObject *_args) |
|---|
| 2165 | n/a | { |
|---|
| 2166 | n/a | PyObject *_res = NULL; |
|---|
| 2167 | n/a | OSErr _err; |
|---|
| 2168 | n/a | Str63 volName; |
|---|
| 2169 | n/a | short vRefNum; |
|---|
| 2170 | n/a | long dirID; |
|---|
| 2171 | n/a | if (!PyArg_ParseTuple(_args, "O&hl", |
|---|
| 2172 | n/a | PyMac_GetStr255, volName, |
|---|
| 2173 | n/a | &vRefNum, |
|---|
| 2174 | n/a | &dirID)) |
|---|
| 2175 | n/a | return NULL; |
|---|
| 2176 | n/a | _err = HSetVol(volName, |
|---|
| 2177 | n/a | vRefNum, |
|---|
| 2178 | n/a | dirID); |
|---|
| 2179 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 2180 | n/a | Py_INCREF(Py_None); |
|---|
| 2181 | n/a | _res = Py_None; |
|---|
| 2182 | n/a | return _res; |
|---|
| 2183 | n/a | } |
|---|
| 2184 | n/a | |
|---|
| 2185 | n/a | static PyObject *File_FSClose(PyObject *_self, PyObject *_args) |
|---|
| 2186 | n/a | { |
|---|
| 2187 | n/a | PyObject *_res = NULL; |
|---|
| 2188 | n/a | OSErr _err; |
|---|
| 2189 | n/a | short refNum; |
|---|
| 2190 | n/a | if (!PyArg_ParseTuple(_args, "h", |
|---|
| 2191 | n/a | &refNum)) |
|---|
| 2192 | n/a | return NULL; |
|---|
| 2193 | n/a | _err = FSClose(refNum); |
|---|
| 2194 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 2195 | n/a | Py_INCREF(Py_None); |
|---|
| 2196 | n/a | _res = Py_None; |
|---|
| 2197 | n/a | return _res; |
|---|
| 2198 | n/a | } |
|---|
| 2199 | n/a | |
|---|
| 2200 | n/a | static PyObject *File_Allocate(PyObject *_self, PyObject *_args) |
|---|
| 2201 | n/a | { |
|---|
| 2202 | n/a | PyObject *_res = NULL; |
|---|
| 2203 | n/a | OSErr _err; |
|---|
| 2204 | n/a | short refNum; |
|---|
| 2205 | n/a | long count; |
|---|
| 2206 | n/a | if (!PyArg_ParseTuple(_args, "h", |
|---|
| 2207 | n/a | &refNum)) |
|---|
| 2208 | n/a | return NULL; |
|---|
| 2209 | n/a | _err = Allocate(refNum, |
|---|
| 2210 | n/a | &count); |
|---|
| 2211 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 2212 | n/a | _res = Py_BuildValue("l", |
|---|
| 2213 | n/a | count); |
|---|
| 2214 | n/a | return _res; |
|---|
| 2215 | n/a | } |
|---|
| 2216 | n/a | |
|---|
| 2217 | n/a | static PyObject *File_GetEOF(PyObject *_self, PyObject *_args) |
|---|
| 2218 | n/a | { |
|---|
| 2219 | n/a | PyObject *_res = NULL; |
|---|
| 2220 | n/a | OSErr _err; |
|---|
| 2221 | n/a | short refNum; |
|---|
| 2222 | n/a | long logEOF; |
|---|
| 2223 | n/a | if (!PyArg_ParseTuple(_args, "h", |
|---|
| 2224 | n/a | &refNum)) |
|---|
| 2225 | n/a | return NULL; |
|---|
| 2226 | n/a | _err = GetEOF(refNum, |
|---|
| 2227 | n/a | &logEOF); |
|---|
| 2228 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 2229 | n/a | _res = Py_BuildValue("l", |
|---|
| 2230 | n/a | logEOF); |
|---|
| 2231 | n/a | return _res; |
|---|
| 2232 | n/a | } |
|---|
| 2233 | n/a | |
|---|
| 2234 | n/a | static PyObject *File_SetEOF(PyObject *_self, PyObject *_args) |
|---|
| 2235 | n/a | { |
|---|
| 2236 | n/a | PyObject *_res = NULL; |
|---|
| 2237 | n/a | OSErr _err; |
|---|
| 2238 | n/a | short refNum; |
|---|
| 2239 | n/a | long logEOF; |
|---|
| 2240 | n/a | if (!PyArg_ParseTuple(_args, "hl", |
|---|
| 2241 | n/a | &refNum, |
|---|
| 2242 | n/a | &logEOF)) |
|---|
| 2243 | n/a | return NULL; |
|---|
| 2244 | n/a | _err = SetEOF(refNum, |
|---|
| 2245 | n/a | logEOF); |
|---|
| 2246 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 2247 | n/a | Py_INCREF(Py_None); |
|---|
| 2248 | n/a | _res = Py_None; |
|---|
| 2249 | n/a | return _res; |
|---|
| 2250 | n/a | } |
|---|
| 2251 | n/a | |
|---|
| 2252 | n/a | static PyObject *File_GetFPos(PyObject *_self, PyObject *_args) |
|---|
| 2253 | n/a | { |
|---|
| 2254 | n/a | PyObject *_res = NULL; |
|---|
| 2255 | n/a | OSErr _err; |
|---|
| 2256 | n/a | short refNum; |
|---|
| 2257 | n/a | long filePos; |
|---|
| 2258 | n/a | if (!PyArg_ParseTuple(_args, "h", |
|---|
| 2259 | n/a | &refNum)) |
|---|
| 2260 | n/a | return NULL; |
|---|
| 2261 | n/a | _err = GetFPos(refNum, |
|---|
| 2262 | n/a | &filePos); |
|---|
| 2263 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 2264 | n/a | _res = Py_BuildValue("l", |
|---|
| 2265 | n/a | filePos); |
|---|
| 2266 | n/a | return _res; |
|---|
| 2267 | n/a | } |
|---|
| 2268 | n/a | |
|---|
| 2269 | n/a | static PyObject *File_SetFPos(PyObject *_self, PyObject *_args) |
|---|
| 2270 | n/a | { |
|---|
| 2271 | n/a | PyObject *_res = NULL; |
|---|
| 2272 | n/a | OSErr _err; |
|---|
| 2273 | n/a | short refNum; |
|---|
| 2274 | n/a | short posMode; |
|---|
| 2275 | n/a | long posOff; |
|---|
| 2276 | n/a | if (!PyArg_ParseTuple(_args, "hhl", |
|---|
| 2277 | n/a | &refNum, |
|---|
| 2278 | n/a | &posMode, |
|---|
| 2279 | n/a | &posOff)) |
|---|
| 2280 | n/a | return NULL; |
|---|
| 2281 | n/a | _err = SetFPos(refNum, |
|---|
| 2282 | n/a | posMode, |
|---|
| 2283 | n/a | posOff); |
|---|
| 2284 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 2285 | n/a | Py_INCREF(Py_None); |
|---|
| 2286 | n/a | _res = Py_None; |
|---|
| 2287 | n/a | return _res; |
|---|
| 2288 | n/a | } |
|---|
| 2289 | n/a | |
|---|
| 2290 | n/a | static PyObject *File_GetVRefNum(PyObject *_self, PyObject *_args) |
|---|
| 2291 | n/a | { |
|---|
| 2292 | n/a | PyObject *_res = NULL; |
|---|
| 2293 | n/a | OSErr _err; |
|---|
| 2294 | n/a | short fileRefNum; |
|---|
| 2295 | n/a | short vRefNum; |
|---|
| 2296 | n/a | if (!PyArg_ParseTuple(_args, "h", |
|---|
| 2297 | n/a | &fileRefNum)) |
|---|
| 2298 | n/a | return NULL; |
|---|
| 2299 | n/a | _err = GetVRefNum(fileRefNum, |
|---|
| 2300 | n/a | &vRefNum); |
|---|
| 2301 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 2302 | n/a | _res = Py_BuildValue("h", |
|---|
| 2303 | n/a | vRefNum); |
|---|
| 2304 | n/a | return _res; |
|---|
| 2305 | n/a | } |
|---|
| 2306 | n/a | |
|---|
| 2307 | n/a | static PyObject *File_HGetVol(PyObject *_self, PyObject *_args) |
|---|
| 2308 | n/a | { |
|---|
| 2309 | n/a | PyObject *_res = NULL; |
|---|
| 2310 | n/a | OSErr _err; |
|---|
| 2311 | n/a | StringPtr volName; |
|---|
| 2312 | n/a | short vRefNum; |
|---|
| 2313 | n/a | long dirID; |
|---|
| 2314 | n/a | if (!PyArg_ParseTuple(_args, "O&", |
|---|
| 2315 | n/a | PyMac_GetStr255, &volName)) |
|---|
| 2316 | n/a | return NULL; |
|---|
| 2317 | n/a | _err = HGetVol(volName, |
|---|
| 2318 | n/a | &vRefNum, |
|---|
| 2319 | n/a | &dirID); |
|---|
| 2320 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 2321 | n/a | _res = Py_BuildValue("hl", |
|---|
| 2322 | n/a | vRefNum, |
|---|
| 2323 | n/a | dirID); |
|---|
| 2324 | n/a | return _res; |
|---|
| 2325 | n/a | } |
|---|
| 2326 | n/a | |
|---|
| 2327 | n/a | static PyObject *File_HOpen(PyObject *_self, PyObject *_args) |
|---|
| 2328 | n/a | { |
|---|
| 2329 | n/a | PyObject *_res = NULL; |
|---|
| 2330 | n/a | OSErr _err; |
|---|
| 2331 | n/a | short vRefNum; |
|---|
| 2332 | n/a | long dirID; |
|---|
| 2333 | n/a | Str255 fileName; |
|---|
| 2334 | n/a | SInt8 permission; |
|---|
| 2335 | n/a | short refNum; |
|---|
| 2336 | n/a | if (!PyArg_ParseTuple(_args, "hlO&b", |
|---|
| 2337 | n/a | &vRefNum, |
|---|
| 2338 | n/a | &dirID, |
|---|
| 2339 | n/a | PyMac_GetStr255, fileName, |
|---|
| 2340 | n/a | &permission)) |
|---|
| 2341 | n/a | return NULL; |
|---|
| 2342 | n/a | _err = HOpen(vRefNum, |
|---|
| 2343 | n/a | dirID, |
|---|
| 2344 | n/a | fileName, |
|---|
| 2345 | n/a | permission, |
|---|
| 2346 | n/a | &refNum); |
|---|
| 2347 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 2348 | n/a | _res = Py_BuildValue("h", |
|---|
| 2349 | n/a | refNum); |
|---|
| 2350 | n/a | return _res; |
|---|
| 2351 | n/a | } |
|---|
| 2352 | n/a | |
|---|
| 2353 | n/a | static PyObject *File_HOpenDF(PyObject *_self, PyObject *_args) |
|---|
| 2354 | n/a | { |
|---|
| 2355 | n/a | PyObject *_res = NULL; |
|---|
| 2356 | n/a | OSErr _err; |
|---|
| 2357 | n/a | short vRefNum; |
|---|
| 2358 | n/a | long dirID; |
|---|
| 2359 | n/a | Str255 fileName; |
|---|
| 2360 | n/a | SInt8 permission; |
|---|
| 2361 | n/a | short refNum; |
|---|
| 2362 | n/a | if (!PyArg_ParseTuple(_args, "hlO&b", |
|---|
| 2363 | n/a | &vRefNum, |
|---|
| 2364 | n/a | &dirID, |
|---|
| 2365 | n/a | PyMac_GetStr255, fileName, |
|---|
| 2366 | n/a | &permission)) |
|---|
| 2367 | n/a | return NULL; |
|---|
| 2368 | n/a | _err = HOpenDF(vRefNum, |
|---|
| 2369 | n/a | dirID, |
|---|
| 2370 | n/a | fileName, |
|---|
| 2371 | n/a | permission, |
|---|
| 2372 | n/a | &refNum); |
|---|
| 2373 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 2374 | n/a | _res = Py_BuildValue("h", |
|---|
| 2375 | n/a | refNum); |
|---|
| 2376 | n/a | return _res; |
|---|
| 2377 | n/a | } |
|---|
| 2378 | n/a | |
|---|
| 2379 | n/a | static PyObject *File_HOpenRF(PyObject *_self, PyObject *_args) |
|---|
| 2380 | n/a | { |
|---|
| 2381 | n/a | PyObject *_res = NULL; |
|---|
| 2382 | n/a | OSErr _err; |
|---|
| 2383 | n/a | short vRefNum; |
|---|
| 2384 | n/a | long dirID; |
|---|
| 2385 | n/a | Str255 fileName; |
|---|
| 2386 | n/a | SInt8 permission; |
|---|
| 2387 | n/a | short refNum; |
|---|
| 2388 | n/a | if (!PyArg_ParseTuple(_args, "hlO&b", |
|---|
| 2389 | n/a | &vRefNum, |
|---|
| 2390 | n/a | &dirID, |
|---|
| 2391 | n/a | PyMac_GetStr255, fileName, |
|---|
| 2392 | n/a | &permission)) |
|---|
| 2393 | n/a | return NULL; |
|---|
| 2394 | n/a | _err = HOpenRF(vRefNum, |
|---|
| 2395 | n/a | dirID, |
|---|
| 2396 | n/a | fileName, |
|---|
| 2397 | n/a | permission, |
|---|
| 2398 | n/a | &refNum); |
|---|
| 2399 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 2400 | n/a | _res = Py_BuildValue("h", |
|---|
| 2401 | n/a | refNum); |
|---|
| 2402 | n/a | return _res; |
|---|
| 2403 | n/a | } |
|---|
| 2404 | n/a | |
|---|
| 2405 | n/a | static PyObject *File_AllocContig(PyObject *_self, PyObject *_args) |
|---|
| 2406 | n/a | { |
|---|
| 2407 | n/a | PyObject *_res = NULL; |
|---|
| 2408 | n/a | OSErr _err; |
|---|
| 2409 | n/a | short refNum; |
|---|
| 2410 | n/a | long count; |
|---|
| 2411 | n/a | if (!PyArg_ParseTuple(_args, "h", |
|---|
| 2412 | n/a | &refNum)) |
|---|
| 2413 | n/a | return NULL; |
|---|
| 2414 | n/a | _err = AllocContig(refNum, |
|---|
| 2415 | n/a | &count); |
|---|
| 2416 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 2417 | n/a | _res = Py_BuildValue("l", |
|---|
| 2418 | n/a | count); |
|---|
| 2419 | n/a | return _res; |
|---|
| 2420 | n/a | } |
|---|
| 2421 | n/a | |
|---|
| 2422 | n/a | static PyObject *File_HCreate(PyObject *_self, PyObject *_args) |
|---|
| 2423 | n/a | { |
|---|
| 2424 | n/a | PyObject *_res = NULL; |
|---|
| 2425 | n/a | OSErr _err; |
|---|
| 2426 | n/a | short vRefNum; |
|---|
| 2427 | n/a | long dirID; |
|---|
| 2428 | n/a | Str255 fileName; |
|---|
| 2429 | n/a | OSType creator; |
|---|
| 2430 | n/a | OSType fileType; |
|---|
| 2431 | n/a | if (!PyArg_ParseTuple(_args, "hlO&O&O&", |
|---|
| 2432 | n/a | &vRefNum, |
|---|
| 2433 | n/a | &dirID, |
|---|
| 2434 | n/a | PyMac_GetStr255, fileName, |
|---|
| 2435 | n/a | PyMac_GetOSType, &creator, |
|---|
| 2436 | n/a | PyMac_GetOSType, &fileType)) |
|---|
| 2437 | n/a | return NULL; |
|---|
| 2438 | n/a | _err = HCreate(vRefNum, |
|---|
| 2439 | n/a | dirID, |
|---|
| 2440 | n/a | fileName, |
|---|
| 2441 | n/a | creator, |
|---|
| 2442 | n/a | fileType); |
|---|
| 2443 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 2444 | n/a | Py_INCREF(Py_None); |
|---|
| 2445 | n/a | _res = Py_None; |
|---|
| 2446 | n/a | return _res; |
|---|
| 2447 | n/a | } |
|---|
| 2448 | n/a | |
|---|
| 2449 | n/a | static PyObject *File_DirCreate(PyObject *_self, PyObject *_args) |
|---|
| 2450 | n/a | { |
|---|
| 2451 | n/a | PyObject *_res = NULL; |
|---|
| 2452 | n/a | OSErr _err; |
|---|
| 2453 | n/a | short vRefNum; |
|---|
| 2454 | n/a | long parentDirID; |
|---|
| 2455 | n/a | Str255 directoryName; |
|---|
| 2456 | n/a | long createdDirID; |
|---|
| 2457 | n/a | if (!PyArg_ParseTuple(_args, "hlO&", |
|---|
| 2458 | n/a | &vRefNum, |
|---|
| 2459 | n/a | &parentDirID, |
|---|
| 2460 | n/a | PyMac_GetStr255, directoryName)) |
|---|
| 2461 | n/a | return NULL; |
|---|
| 2462 | n/a | _err = DirCreate(vRefNum, |
|---|
| 2463 | n/a | parentDirID, |
|---|
| 2464 | n/a | directoryName, |
|---|
| 2465 | n/a | &createdDirID); |
|---|
| 2466 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 2467 | n/a | _res = Py_BuildValue("l", |
|---|
| 2468 | n/a | createdDirID); |
|---|
| 2469 | n/a | return _res; |
|---|
| 2470 | n/a | } |
|---|
| 2471 | n/a | |
|---|
| 2472 | n/a | static PyObject *File_HDelete(PyObject *_self, PyObject *_args) |
|---|
| 2473 | n/a | { |
|---|
| 2474 | n/a | PyObject *_res = NULL; |
|---|
| 2475 | n/a | OSErr _err; |
|---|
| 2476 | n/a | short vRefNum; |
|---|
| 2477 | n/a | long dirID; |
|---|
| 2478 | n/a | Str255 fileName; |
|---|
| 2479 | n/a | if (!PyArg_ParseTuple(_args, "hlO&", |
|---|
| 2480 | n/a | &vRefNum, |
|---|
| 2481 | n/a | &dirID, |
|---|
| 2482 | n/a | PyMac_GetStr255, fileName)) |
|---|
| 2483 | n/a | return NULL; |
|---|
| 2484 | n/a | _err = HDelete(vRefNum, |
|---|
| 2485 | n/a | dirID, |
|---|
| 2486 | n/a | fileName); |
|---|
| 2487 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 2488 | n/a | Py_INCREF(Py_None); |
|---|
| 2489 | n/a | _res = Py_None; |
|---|
| 2490 | n/a | return _res; |
|---|
| 2491 | n/a | } |
|---|
| 2492 | n/a | |
|---|
| 2493 | n/a | static PyObject *File_HGetFInfo(PyObject *_self, PyObject *_args) |
|---|
| 2494 | n/a | { |
|---|
| 2495 | n/a | PyObject *_res = NULL; |
|---|
| 2496 | n/a | OSErr _err; |
|---|
| 2497 | n/a | short vRefNum; |
|---|
| 2498 | n/a | long dirID; |
|---|
| 2499 | n/a | Str255 fileName; |
|---|
| 2500 | n/a | FInfo fndrInfo; |
|---|
| 2501 | n/a | if (!PyArg_ParseTuple(_args, "hlO&", |
|---|
| 2502 | n/a | &vRefNum, |
|---|
| 2503 | n/a | &dirID, |
|---|
| 2504 | n/a | PyMac_GetStr255, fileName)) |
|---|
| 2505 | n/a | return NULL; |
|---|
| 2506 | n/a | _err = HGetFInfo(vRefNum, |
|---|
| 2507 | n/a | dirID, |
|---|
| 2508 | n/a | fileName, |
|---|
| 2509 | n/a | &fndrInfo); |
|---|
| 2510 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 2511 | n/a | _res = Py_BuildValue("O&", |
|---|
| 2512 | n/a | FInfo_New, &fndrInfo); |
|---|
| 2513 | n/a | return _res; |
|---|
| 2514 | n/a | } |
|---|
| 2515 | n/a | |
|---|
| 2516 | n/a | static PyObject *File_HSetFInfo(PyObject *_self, PyObject *_args) |
|---|
| 2517 | n/a | { |
|---|
| 2518 | n/a | PyObject *_res = NULL; |
|---|
| 2519 | n/a | OSErr _err; |
|---|
| 2520 | n/a | short vRefNum; |
|---|
| 2521 | n/a | long dirID; |
|---|
| 2522 | n/a | Str255 fileName; |
|---|
| 2523 | n/a | FInfo fndrInfo; |
|---|
| 2524 | n/a | if (!PyArg_ParseTuple(_args, "hlO&O&", |
|---|
| 2525 | n/a | &vRefNum, |
|---|
| 2526 | n/a | &dirID, |
|---|
| 2527 | n/a | PyMac_GetStr255, fileName, |
|---|
| 2528 | n/a | FInfo_Convert, &fndrInfo)) |
|---|
| 2529 | n/a | return NULL; |
|---|
| 2530 | n/a | _err = HSetFInfo(vRefNum, |
|---|
| 2531 | n/a | dirID, |
|---|
| 2532 | n/a | fileName, |
|---|
| 2533 | n/a | &fndrInfo); |
|---|
| 2534 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 2535 | n/a | Py_INCREF(Py_None); |
|---|
| 2536 | n/a | _res = Py_None; |
|---|
| 2537 | n/a | return _res; |
|---|
| 2538 | n/a | } |
|---|
| 2539 | n/a | |
|---|
| 2540 | n/a | static PyObject *File_HSetFLock(PyObject *_self, PyObject *_args) |
|---|
| 2541 | n/a | { |
|---|
| 2542 | n/a | PyObject *_res = NULL; |
|---|
| 2543 | n/a | OSErr _err; |
|---|
| 2544 | n/a | short vRefNum; |
|---|
| 2545 | n/a | long dirID; |
|---|
| 2546 | n/a | Str255 fileName; |
|---|
| 2547 | n/a | if (!PyArg_ParseTuple(_args, "hlO&", |
|---|
| 2548 | n/a | &vRefNum, |
|---|
| 2549 | n/a | &dirID, |
|---|
| 2550 | n/a | PyMac_GetStr255, fileName)) |
|---|
| 2551 | n/a | return NULL; |
|---|
| 2552 | n/a | _err = HSetFLock(vRefNum, |
|---|
| 2553 | n/a | dirID, |
|---|
| 2554 | n/a | fileName); |
|---|
| 2555 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 2556 | n/a | Py_INCREF(Py_None); |
|---|
| 2557 | n/a | _res = Py_None; |
|---|
| 2558 | n/a | return _res; |
|---|
| 2559 | n/a | } |
|---|
| 2560 | n/a | |
|---|
| 2561 | n/a | static PyObject *File_HRstFLock(PyObject *_self, PyObject *_args) |
|---|
| 2562 | n/a | { |
|---|
| 2563 | n/a | PyObject *_res = NULL; |
|---|
| 2564 | n/a | OSErr _err; |
|---|
| 2565 | n/a | short vRefNum; |
|---|
| 2566 | n/a | long dirID; |
|---|
| 2567 | n/a | Str255 fileName; |
|---|
| 2568 | n/a | if (!PyArg_ParseTuple(_args, "hlO&", |
|---|
| 2569 | n/a | &vRefNum, |
|---|
| 2570 | n/a | &dirID, |
|---|
| 2571 | n/a | PyMac_GetStr255, fileName)) |
|---|
| 2572 | n/a | return NULL; |
|---|
| 2573 | n/a | _err = HRstFLock(vRefNum, |
|---|
| 2574 | n/a | dirID, |
|---|
| 2575 | n/a | fileName); |
|---|
| 2576 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 2577 | n/a | Py_INCREF(Py_None); |
|---|
| 2578 | n/a | _res = Py_None; |
|---|
| 2579 | n/a | return _res; |
|---|
| 2580 | n/a | } |
|---|
| 2581 | n/a | |
|---|
| 2582 | n/a | static PyObject *File_HRename(PyObject *_self, PyObject *_args) |
|---|
| 2583 | n/a | { |
|---|
| 2584 | n/a | PyObject *_res = NULL; |
|---|
| 2585 | n/a | OSErr _err; |
|---|
| 2586 | n/a | short vRefNum; |
|---|
| 2587 | n/a | long dirID; |
|---|
| 2588 | n/a | Str255 oldName; |
|---|
| 2589 | n/a | Str255 newName; |
|---|
| 2590 | n/a | if (!PyArg_ParseTuple(_args, "hlO&O&", |
|---|
| 2591 | n/a | &vRefNum, |
|---|
| 2592 | n/a | &dirID, |
|---|
| 2593 | n/a | PyMac_GetStr255, oldName, |
|---|
| 2594 | n/a | PyMac_GetStr255, newName)) |
|---|
| 2595 | n/a | return NULL; |
|---|
| 2596 | n/a | _err = HRename(vRefNum, |
|---|
| 2597 | n/a | dirID, |
|---|
| 2598 | n/a | oldName, |
|---|
| 2599 | n/a | newName); |
|---|
| 2600 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 2601 | n/a | Py_INCREF(Py_None); |
|---|
| 2602 | n/a | _res = Py_None; |
|---|
| 2603 | n/a | return _res; |
|---|
| 2604 | n/a | } |
|---|
| 2605 | n/a | |
|---|
| 2606 | n/a | static PyObject *File_CatMove(PyObject *_self, PyObject *_args) |
|---|
| 2607 | n/a | { |
|---|
| 2608 | n/a | PyObject *_res = NULL; |
|---|
| 2609 | n/a | OSErr _err; |
|---|
| 2610 | n/a | short vRefNum; |
|---|
| 2611 | n/a | long dirID; |
|---|
| 2612 | n/a | Str255 oldName; |
|---|
| 2613 | n/a | long newDirID; |
|---|
| 2614 | n/a | Str255 newName; |
|---|
| 2615 | n/a | if (!PyArg_ParseTuple(_args, "hlO&lO&", |
|---|
| 2616 | n/a | &vRefNum, |
|---|
| 2617 | n/a | &dirID, |
|---|
| 2618 | n/a | PyMac_GetStr255, oldName, |
|---|
| 2619 | n/a | &newDirID, |
|---|
| 2620 | n/a | PyMac_GetStr255, newName)) |
|---|
| 2621 | n/a | return NULL; |
|---|
| 2622 | n/a | _err = CatMove(vRefNum, |
|---|
| 2623 | n/a | dirID, |
|---|
| 2624 | n/a | oldName, |
|---|
| 2625 | n/a | newDirID, |
|---|
| 2626 | n/a | newName); |
|---|
| 2627 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 2628 | n/a | Py_INCREF(Py_None); |
|---|
| 2629 | n/a | _res = Py_None; |
|---|
| 2630 | n/a | return _res; |
|---|
| 2631 | n/a | } |
|---|
| 2632 | n/a | |
|---|
| 2633 | n/a | static PyObject *File_FSMakeFSSpec(PyObject *_self, PyObject *_args) |
|---|
| 2634 | n/a | { |
|---|
| 2635 | n/a | PyObject *_res = NULL; |
|---|
| 2636 | n/a | OSErr _err; |
|---|
| 2637 | n/a | short vRefNum; |
|---|
| 2638 | n/a | long dirID; |
|---|
| 2639 | n/a | Str255 fileName; |
|---|
| 2640 | n/a | FSSpec spec; |
|---|
| 2641 | n/a | if (!PyArg_ParseTuple(_args, "hlO&", |
|---|
| 2642 | n/a | &vRefNum, |
|---|
| 2643 | n/a | &dirID, |
|---|
| 2644 | n/a | PyMac_GetStr255, fileName)) |
|---|
| 2645 | n/a | return NULL; |
|---|
| 2646 | n/a | _err = FSMakeFSSpec(vRefNum, |
|---|
| 2647 | n/a | dirID, |
|---|
| 2648 | n/a | fileName, |
|---|
| 2649 | n/a | &spec); |
|---|
| 2650 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 2651 | n/a | _res = Py_BuildValue("O&", |
|---|
| 2652 | n/a | FSSpec_New, &spec); |
|---|
| 2653 | n/a | return _res; |
|---|
| 2654 | n/a | } |
|---|
| 2655 | n/a | #endif /* !__LP64__ */ |
|---|
| 2656 | n/a | |
|---|
| 2657 | n/a | static PyObject *File_FSGetForkPosition(PyObject *_self, PyObject *_args) |
|---|
| 2658 | n/a | { |
|---|
| 2659 | n/a | PyObject *_res = NULL; |
|---|
| 2660 | n/a | OSErr _err; |
|---|
| 2661 | n/a | SInt16 forkRefNum; |
|---|
| 2662 | n/a | SInt64 position; |
|---|
| 2663 | n/a | if (!PyArg_ParseTuple(_args, "h", |
|---|
| 2664 | n/a | &forkRefNum)) |
|---|
| 2665 | n/a | return NULL; |
|---|
| 2666 | n/a | _err = FSGetForkPosition(forkRefNum, |
|---|
| 2667 | n/a | &position); |
|---|
| 2668 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 2669 | n/a | _res = Py_BuildValue("L", |
|---|
| 2670 | n/a | position); |
|---|
| 2671 | n/a | return _res; |
|---|
| 2672 | n/a | } |
|---|
| 2673 | n/a | |
|---|
| 2674 | n/a | static PyObject *File_FSSetForkPosition(PyObject *_self, PyObject *_args) |
|---|
| 2675 | n/a | { |
|---|
| 2676 | n/a | PyObject *_res = NULL; |
|---|
| 2677 | n/a | OSErr _err; |
|---|
| 2678 | n/a | SInt16 forkRefNum; |
|---|
| 2679 | n/a | UInt16 positionMode; |
|---|
| 2680 | n/a | SInt64 positionOffset; |
|---|
| 2681 | n/a | if (!PyArg_ParseTuple(_args, "hHL", |
|---|
| 2682 | n/a | &forkRefNum, |
|---|
| 2683 | n/a | &positionMode, |
|---|
| 2684 | n/a | &positionOffset)) |
|---|
| 2685 | n/a | return NULL; |
|---|
| 2686 | n/a | _err = FSSetForkPosition(forkRefNum, |
|---|
| 2687 | n/a | positionMode, |
|---|
| 2688 | n/a | positionOffset); |
|---|
| 2689 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 2690 | n/a | Py_INCREF(Py_None); |
|---|
| 2691 | n/a | _res = Py_None; |
|---|
| 2692 | n/a | return _res; |
|---|
| 2693 | n/a | } |
|---|
| 2694 | n/a | |
|---|
| 2695 | n/a | static PyObject *File_FSGetForkSize(PyObject *_self, PyObject *_args) |
|---|
| 2696 | n/a | { |
|---|
| 2697 | n/a | PyObject *_res = NULL; |
|---|
| 2698 | n/a | OSErr _err; |
|---|
| 2699 | n/a | SInt16 forkRefNum; |
|---|
| 2700 | n/a | SInt64 forkSize; |
|---|
| 2701 | n/a | if (!PyArg_ParseTuple(_args, "h", |
|---|
| 2702 | n/a | &forkRefNum)) |
|---|
| 2703 | n/a | return NULL; |
|---|
| 2704 | n/a | _err = FSGetForkSize(forkRefNum, |
|---|
| 2705 | n/a | &forkSize); |
|---|
| 2706 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 2707 | n/a | _res = Py_BuildValue("L", |
|---|
| 2708 | n/a | forkSize); |
|---|
| 2709 | n/a | return _res; |
|---|
| 2710 | n/a | } |
|---|
| 2711 | n/a | |
|---|
| 2712 | n/a | static PyObject *File_FSSetForkSize(PyObject *_self, PyObject *_args) |
|---|
| 2713 | n/a | { |
|---|
| 2714 | n/a | PyObject *_res = NULL; |
|---|
| 2715 | n/a | OSErr _err; |
|---|
| 2716 | n/a | SInt16 forkRefNum; |
|---|
| 2717 | n/a | UInt16 positionMode; |
|---|
| 2718 | n/a | SInt64 positionOffset; |
|---|
| 2719 | n/a | if (!PyArg_ParseTuple(_args, "hHL", |
|---|
| 2720 | n/a | &forkRefNum, |
|---|
| 2721 | n/a | &positionMode, |
|---|
| 2722 | n/a | &positionOffset)) |
|---|
| 2723 | n/a | return NULL; |
|---|
| 2724 | n/a | _err = FSSetForkSize(forkRefNum, |
|---|
| 2725 | n/a | positionMode, |
|---|
| 2726 | n/a | positionOffset); |
|---|
| 2727 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 2728 | n/a | Py_INCREF(Py_None); |
|---|
| 2729 | n/a | _res = Py_None; |
|---|
| 2730 | n/a | return _res; |
|---|
| 2731 | n/a | } |
|---|
| 2732 | n/a | |
|---|
| 2733 | n/a | static PyObject *File_FSAllocateFork(PyObject *_self, PyObject *_args) |
|---|
| 2734 | n/a | { |
|---|
| 2735 | n/a | PyObject *_res = NULL; |
|---|
| 2736 | n/a | OSErr _err; |
|---|
| 2737 | n/a | SInt16 forkRefNum; |
|---|
| 2738 | n/a | FSAllocationFlags flags; |
|---|
| 2739 | n/a | UInt16 positionMode; |
|---|
| 2740 | n/a | SInt64 positionOffset; |
|---|
| 2741 | n/a | UInt64 requestCount; |
|---|
| 2742 | n/a | UInt64 actualCount; |
|---|
| 2743 | n/a | if (!PyArg_ParseTuple(_args, "hHHLL", |
|---|
| 2744 | n/a | &forkRefNum, |
|---|
| 2745 | n/a | &flags, |
|---|
| 2746 | n/a | &positionMode, |
|---|
| 2747 | n/a | &positionOffset, |
|---|
| 2748 | n/a | &requestCount)) |
|---|
| 2749 | n/a | return NULL; |
|---|
| 2750 | n/a | _err = FSAllocateFork(forkRefNum, |
|---|
| 2751 | n/a | flags, |
|---|
| 2752 | n/a | positionMode, |
|---|
| 2753 | n/a | positionOffset, |
|---|
| 2754 | n/a | requestCount, |
|---|
| 2755 | n/a | &actualCount); |
|---|
| 2756 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 2757 | n/a | _res = Py_BuildValue("L", |
|---|
| 2758 | n/a | actualCount); |
|---|
| 2759 | n/a | return _res; |
|---|
| 2760 | n/a | } |
|---|
| 2761 | n/a | |
|---|
| 2762 | n/a | static PyObject *File_FSFlushFork(PyObject *_self, PyObject *_args) |
|---|
| 2763 | n/a | { |
|---|
| 2764 | n/a | PyObject *_res = NULL; |
|---|
| 2765 | n/a | OSErr _err; |
|---|
| 2766 | n/a | SInt16 forkRefNum; |
|---|
| 2767 | n/a | if (!PyArg_ParseTuple(_args, "h", |
|---|
| 2768 | n/a | &forkRefNum)) |
|---|
| 2769 | n/a | return NULL; |
|---|
| 2770 | n/a | _err = FSFlushFork(forkRefNum); |
|---|
| 2771 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 2772 | n/a | Py_INCREF(Py_None); |
|---|
| 2773 | n/a | _res = Py_None; |
|---|
| 2774 | n/a | return _res; |
|---|
| 2775 | n/a | } |
|---|
| 2776 | n/a | |
|---|
| 2777 | n/a | static PyObject *File_FSCloseFork(PyObject *_self, PyObject *_args) |
|---|
| 2778 | n/a | { |
|---|
| 2779 | n/a | PyObject *_res = NULL; |
|---|
| 2780 | n/a | OSErr _err; |
|---|
| 2781 | n/a | SInt16 forkRefNum; |
|---|
| 2782 | n/a | if (!PyArg_ParseTuple(_args, "h", |
|---|
| 2783 | n/a | &forkRefNum)) |
|---|
| 2784 | n/a | return NULL; |
|---|
| 2785 | n/a | _err = FSCloseFork(forkRefNum); |
|---|
| 2786 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 2787 | n/a | Py_INCREF(Py_None); |
|---|
| 2788 | n/a | _res = Py_None; |
|---|
| 2789 | n/a | return _res; |
|---|
| 2790 | n/a | } |
|---|
| 2791 | n/a | |
|---|
| 2792 | n/a | static PyObject *File_FSGetDataForkName(PyObject *_self, PyObject *_args) |
|---|
| 2793 | n/a | { |
|---|
| 2794 | n/a | PyObject *_res = NULL; |
|---|
| 2795 | n/a | OSErr _err; |
|---|
| 2796 | n/a | HFSUniStr255 dataForkName; |
|---|
| 2797 | n/a | if (!PyArg_ParseTuple(_args, "")) |
|---|
| 2798 | n/a | return NULL; |
|---|
| 2799 | n/a | _err = FSGetDataForkName(&dataForkName); |
|---|
| 2800 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 2801 | n/a | _res = Py_BuildValue("O&", |
|---|
| 2802 | n/a | PyMac_BuildHFSUniStr255, &dataForkName); |
|---|
| 2803 | n/a | return _res; |
|---|
| 2804 | n/a | } |
|---|
| 2805 | n/a | |
|---|
| 2806 | n/a | static PyObject *File_FSGetResourceForkName(PyObject *_self, PyObject *_args) |
|---|
| 2807 | n/a | { |
|---|
| 2808 | n/a | PyObject *_res = NULL; |
|---|
| 2809 | n/a | OSErr _err; |
|---|
| 2810 | n/a | HFSUniStr255 resourceForkName; |
|---|
| 2811 | n/a | if (!PyArg_ParseTuple(_args, "")) |
|---|
| 2812 | n/a | return NULL; |
|---|
| 2813 | n/a | _err = FSGetResourceForkName(&resourceForkName); |
|---|
| 2814 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 2815 | n/a | _res = Py_BuildValue("O&", |
|---|
| 2816 | n/a | PyMac_BuildHFSUniStr255, &resourceForkName); |
|---|
| 2817 | n/a | return _res; |
|---|
| 2818 | n/a | } |
|---|
| 2819 | n/a | |
|---|
| 2820 | n/a | static PyObject *File_FSPathMakeRef(PyObject *_self, PyObject *_args) |
|---|
| 2821 | n/a | { |
|---|
| 2822 | n/a | PyObject *_res = NULL; |
|---|
| 2823 | n/a | OSStatus _err; |
|---|
| 2824 | n/a | UInt8 * path; |
|---|
| 2825 | n/a | FSRef ref; |
|---|
| 2826 | n/a | Boolean isDirectory; |
|---|
| 2827 | n/a | if (!PyArg_ParseTuple(_args, "s", |
|---|
| 2828 | n/a | &path)) |
|---|
| 2829 | n/a | return NULL; |
|---|
| 2830 | n/a | _err = FSPathMakeRef(path, |
|---|
| 2831 | n/a | &ref, |
|---|
| 2832 | n/a | &isDirectory); |
|---|
| 2833 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 2834 | n/a | _res = Py_BuildValue("O&b", |
|---|
| 2835 | n/a | FSRef_New, &ref, |
|---|
| 2836 | n/a | isDirectory); |
|---|
| 2837 | n/a | return _res; |
|---|
| 2838 | n/a | } |
|---|
| 2839 | n/a | |
|---|
| 2840 | n/a | static PyObject *File_FNNotifyByPath(PyObject *_self, PyObject *_args) |
|---|
| 2841 | n/a | { |
|---|
| 2842 | n/a | PyObject *_res = NULL; |
|---|
| 2843 | n/a | OSStatus _err; |
|---|
| 2844 | n/a | UInt8 * path; |
|---|
| 2845 | n/a | FNMessage message; |
|---|
| 2846 | n/a | OptionBits flags; |
|---|
| 2847 | n/a | if (!PyArg_ParseTuple(_args, "sll", |
|---|
| 2848 | n/a | &path, |
|---|
| 2849 | n/a | &message, |
|---|
| 2850 | n/a | &flags)) |
|---|
| 2851 | n/a | return NULL; |
|---|
| 2852 | n/a | _err = FNNotifyByPath(path, |
|---|
| 2853 | n/a | message, |
|---|
| 2854 | n/a | flags); |
|---|
| 2855 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 2856 | n/a | Py_INCREF(Py_None); |
|---|
| 2857 | n/a | _res = Py_None; |
|---|
| 2858 | n/a | return _res; |
|---|
| 2859 | n/a | } |
|---|
| 2860 | n/a | |
|---|
| 2861 | n/a | static PyObject *File_FNNotifyAll(PyObject *_self, PyObject *_args) |
|---|
| 2862 | n/a | { |
|---|
| 2863 | n/a | PyObject *_res = NULL; |
|---|
| 2864 | n/a | OSStatus _err; |
|---|
| 2865 | n/a | FNMessage message; |
|---|
| 2866 | n/a | OptionBits flags; |
|---|
| 2867 | n/a | if (!PyArg_ParseTuple(_args, "ll", |
|---|
| 2868 | n/a | &message, |
|---|
| 2869 | n/a | &flags)) |
|---|
| 2870 | n/a | return NULL; |
|---|
| 2871 | n/a | _err = FNNotifyAll(message, |
|---|
| 2872 | n/a | flags); |
|---|
| 2873 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 2874 | n/a | Py_INCREF(Py_None); |
|---|
| 2875 | n/a | _res = Py_None; |
|---|
| 2876 | n/a | return _res; |
|---|
| 2877 | n/a | } |
|---|
| 2878 | n/a | |
|---|
| 2879 | n/a | #ifndef __LP64__ |
|---|
| 2880 | n/a | static PyObject *File_NewAlias(PyObject *_self, PyObject *_args) |
|---|
| 2881 | n/a | { |
|---|
| 2882 | n/a | PyObject *_res = NULL; |
|---|
| 2883 | n/a | OSErr _err; |
|---|
| 2884 | n/a | FSSpec fromFile__buf__; |
|---|
| 2885 | n/a | FSSpec *fromFile = &fromFile__buf__; |
|---|
| 2886 | n/a | FSSpec target; |
|---|
| 2887 | n/a | AliasHandle alias; |
|---|
| 2888 | n/a | if (!PyArg_ParseTuple(_args, "O&O&", |
|---|
| 2889 | n/a | myPyMac_GetOptFSSpecPtr, &fromFile, |
|---|
| 2890 | n/a | FSSpec_Convert, &target)) |
|---|
| 2891 | n/a | return NULL; |
|---|
| 2892 | n/a | _err = NewAlias(fromFile, |
|---|
| 2893 | n/a | &target, |
|---|
| 2894 | n/a | &alias); |
|---|
| 2895 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 2896 | n/a | _res = Py_BuildValue("O&", |
|---|
| 2897 | n/a | Alias_New, alias); |
|---|
| 2898 | n/a | return _res; |
|---|
| 2899 | n/a | } |
|---|
| 2900 | n/a | |
|---|
| 2901 | n/a | static PyObject *File_NewAliasMinimalFromFullPath(PyObject *_self, PyObject *_args) |
|---|
| 2902 | n/a | { |
|---|
| 2903 | n/a | PyObject *_res = NULL; |
|---|
| 2904 | n/a | OSErr _err; |
|---|
| 2905 | n/a | char *fullPath__in__; |
|---|
| 2906 | n/a | int fullPath__len__; |
|---|
| 2907 | n/a | int fullPath__in_len__; |
|---|
| 2908 | n/a | Str32 zoneName; |
|---|
| 2909 | n/a | Str31 serverName; |
|---|
| 2910 | n/a | AliasHandle alias; |
|---|
| 2911 | n/a | if (!PyArg_ParseTuple(_args, "s#O&O&", |
|---|
| 2912 | n/a | &fullPath__in__, &fullPath__in_len__, |
|---|
| 2913 | n/a | PyMac_GetStr255, zoneName, |
|---|
| 2914 | n/a | PyMac_GetStr255, serverName)) |
|---|
| 2915 | n/a | return NULL; |
|---|
| 2916 | n/a | fullPath__len__ = fullPath__in_len__; |
|---|
| 2917 | n/a | _err = NewAliasMinimalFromFullPath(fullPath__len__, fullPath__in__, |
|---|
| 2918 | n/a | zoneName, |
|---|
| 2919 | n/a | serverName, |
|---|
| 2920 | n/a | &alias); |
|---|
| 2921 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 2922 | n/a | _res = Py_BuildValue("O&", |
|---|
| 2923 | n/a | Alias_New, alias); |
|---|
| 2924 | n/a | return _res; |
|---|
| 2925 | n/a | } |
|---|
| 2926 | n/a | |
|---|
| 2927 | n/a | static PyObject *File_ResolveAliasFile(PyObject *_self, PyObject *_args) |
|---|
| 2928 | n/a | { |
|---|
| 2929 | n/a | PyObject *_res = NULL; |
|---|
| 2930 | n/a | OSErr _err; |
|---|
| 2931 | n/a | FSSpec theSpec; |
|---|
| 2932 | n/a | Boolean resolveAliasChains; |
|---|
| 2933 | n/a | Boolean targetIsFolder; |
|---|
| 2934 | n/a | Boolean wasAliased; |
|---|
| 2935 | n/a | if (!PyArg_ParseTuple(_args, "O&b", |
|---|
| 2936 | n/a | FSSpec_Convert, &theSpec, |
|---|
| 2937 | n/a | &resolveAliasChains)) |
|---|
| 2938 | n/a | return NULL; |
|---|
| 2939 | n/a | _err = ResolveAliasFile(&theSpec, |
|---|
| 2940 | n/a | resolveAliasChains, |
|---|
| 2941 | n/a | &targetIsFolder, |
|---|
| 2942 | n/a | &wasAliased); |
|---|
| 2943 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 2944 | n/a | _res = Py_BuildValue("O&bb", |
|---|
| 2945 | n/a | FSSpec_New, &theSpec, |
|---|
| 2946 | n/a | targetIsFolder, |
|---|
| 2947 | n/a | wasAliased); |
|---|
| 2948 | n/a | return _res; |
|---|
| 2949 | n/a | } |
|---|
| 2950 | n/a | |
|---|
| 2951 | n/a | static PyObject *File_ResolveAliasFileWithMountFlags(PyObject *_self, PyObject *_args) |
|---|
| 2952 | n/a | { |
|---|
| 2953 | n/a | PyObject *_res = NULL; |
|---|
| 2954 | n/a | OSErr _err; |
|---|
| 2955 | n/a | FSSpec theSpec; |
|---|
| 2956 | n/a | Boolean resolveAliasChains; |
|---|
| 2957 | n/a | Boolean targetIsFolder; |
|---|
| 2958 | n/a | Boolean wasAliased; |
|---|
| 2959 | n/a | unsigned long mountFlags; |
|---|
| 2960 | n/a | if (!PyArg_ParseTuple(_args, "O&bl", |
|---|
| 2961 | n/a | FSSpec_Convert, &theSpec, |
|---|
| 2962 | n/a | &resolveAliasChains, |
|---|
| 2963 | n/a | &mountFlags)) |
|---|
| 2964 | n/a | return NULL; |
|---|
| 2965 | n/a | _err = ResolveAliasFileWithMountFlags(&theSpec, |
|---|
| 2966 | n/a | resolveAliasChains, |
|---|
| 2967 | n/a | &targetIsFolder, |
|---|
| 2968 | n/a | &wasAliased, |
|---|
| 2969 | n/a | mountFlags); |
|---|
| 2970 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 2971 | n/a | _res = Py_BuildValue("O&bb", |
|---|
| 2972 | n/a | FSSpec_New, &theSpec, |
|---|
| 2973 | n/a | targetIsFolder, |
|---|
| 2974 | n/a | wasAliased); |
|---|
| 2975 | n/a | return _res; |
|---|
| 2976 | n/a | } |
|---|
| 2977 | n/a | |
|---|
| 2978 | n/a | static PyObject *File_UpdateAlias(PyObject *_self, PyObject *_args) |
|---|
| 2979 | n/a | { |
|---|
| 2980 | n/a | PyObject *_res = NULL; |
|---|
| 2981 | n/a | OSErr _err; |
|---|
| 2982 | n/a | FSSpec fromFile__buf__; |
|---|
| 2983 | n/a | FSSpec *fromFile = &fromFile__buf__; |
|---|
| 2984 | n/a | FSSpec target; |
|---|
| 2985 | n/a | AliasHandle alias; |
|---|
| 2986 | n/a | Boolean wasChanged; |
|---|
| 2987 | n/a | if (!PyArg_ParseTuple(_args, "O&O&O&", |
|---|
| 2988 | n/a | myPyMac_GetOptFSSpecPtr, &fromFile, |
|---|
| 2989 | n/a | FSSpec_Convert, &target, |
|---|
| 2990 | n/a | Alias_Convert, &alias)) |
|---|
| 2991 | n/a | return NULL; |
|---|
| 2992 | n/a | _err = UpdateAlias(fromFile, |
|---|
| 2993 | n/a | &target, |
|---|
| 2994 | n/a | alias, |
|---|
| 2995 | n/a | &wasChanged); |
|---|
| 2996 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 2997 | n/a | _res = Py_BuildValue("b", |
|---|
| 2998 | n/a | wasChanged); |
|---|
| 2999 | n/a | return _res; |
|---|
| 3000 | n/a | } |
|---|
| 3001 | n/a | |
|---|
| 3002 | n/a | static PyObject *File_ResolveAliasFileWithMountFlagsNoUI(PyObject *_self, PyObject *_args) |
|---|
| 3003 | n/a | { |
|---|
| 3004 | n/a | PyObject *_res = NULL; |
|---|
| 3005 | n/a | OSErr _err; |
|---|
| 3006 | n/a | FSSpec theSpec; |
|---|
| 3007 | n/a | Boolean resolveAliasChains; |
|---|
| 3008 | n/a | Boolean targetIsFolder; |
|---|
| 3009 | n/a | Boolean wasAliased; |
|---|
| 3010 | n/a | unsigned long mountFlags; |
|---|
| 3011 | n/a | if (!PyArg_ParseTuple(_args, "O&bl", |
|---|
| 3012 | n/a | FSSpec_Convert, &theSpec, |
|---|
| 3013 | n/a | &resolveAliasChains, |
|---|
| 3014 | n/a | &mountFlags)) |
|---|
| 3015 | n/a | return NULL; |
|---|
| 3016 | n/a | _err = ResolveAliasFileWithMountFlagsNoUI(&theSpec, |
|---|
| 3017 | n/a | resolveAliasChains, |
|---|
| 3018 | n/a | &targetIsFolder, |
|---|
| 3019 | n/a | &wasAliased, |
|---|
| 3020 | n/a | mountFlags); |
|---|
| 3021 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 3022 | n/a | _res = Py_BuildValue("O&bb", |
|---|
| 3023 | n/a | FSSpec_New, &theSpec, |
|---|
| 3024 | n/a | targetIsFolder, |
|---|
| 3025 | n/a | wasAliased); |
|---|
| 3026 | n/a | return _res; |
|---|
| 3027 | n/a | } |
|---|
| 3028 | n/a | #endif /* !__LP64__ */ |
|---|
| 3029 | n/a | |
|---|
| 3030 | n/a | static PyObject *File_FSNewAlias(PyObject *_self, PyObject *_args) |
|---|
| 3031 | n/a | { |
|---|
| 3032 | n/a | PyObject *_res = NULL; |
|---|
| 3033 | n/a | OSErr _err; |
|---|
| 3034 | n/a | FSRef fromFile__buf__; |
|---|
| 3035 | n/a | FSRef *fromFile = &fromFile__buf__; |
|---|
| 3036 | n/a | FSRef target; |
|---|
| 3037 | n/a | AliasHandle inAlias; |
|---|
| 3038 | n/a | if (!PyArg_ParseTuple(_args, "O&O&", |
|---|
| 3039 | n/a | myPyMac_GetOptFSRefPtr, &fromFile, |
|---|
| 3040 | n/a | FSRef_Convert, &target)) |
|---|
| 3041 | n/a | return NULL; |
|---|
| 3042 | n/a | _err = FSNewAlias(fromFile, |
|---|
| 3043 | n/a | &target, |
|---|
| 3044 | n/a | &inAlias); |
|---|
| 3045 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 3046 | n/a | _res = Py_BuildValue("O&", |
|---|
| 3047 | n/a | Alias_New, inAlias); |
|---|
| 3048 | n/a | return _res; |
|---|
| 3049 | n/a | } |
|---|
| 3050 | n/a | |
|---|
| 3051 | n/a | static PyObject *File_FSResolveAliasFileWithMountFlags(PyObject *_self, PyObject *_args) |
|---|
| 3052 | n/a | { |
|---|
| 3053 | n/a | PyObject *_res = NULL; |
|---|
| 3054 | n/a | OSErr _err; |
|---|
| 3055 | n/a | FSRef theRef; |
|---|
| 3056 | n/a | Boolean resolveAliasChains; |
|---|
| 3057 | n/a | Boolean targetIsFolder; |
|---|
| 3058 | n/a | Boolean wasAliased; |
|---|
| 3059 | n/a | unsigned long mountFlags; |
|---|
| 3060 | n/a | if (!PyArg_ParseTuple(_args, "O&bl", |
|---|
| 3061 | n/a | FSRef_Convert, &theRef, |
|---|
| 3062 | n/a | &resolveAliasChains, |
|---|
| 3063 | n/a | &mountFlags)) |
|---|
| 3064 | n/a | return NULL; |
|---|
| 3065 | n/a | _err = FSResolveAliasFileWithMountFlags(&theRef, |
|---|
| 3066 | n/a | resolveAliasChains, |
|---|
| 3067 | n/a | &targetIsFolder, |
|---|
| 3068 | n/a | &wasAliased, |
|---|
| 3069 | n/a | mountFlags); |
|---|
| 3070 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 3071 | n/a | _res = Py_BuildValue("O&bb", |
|---|
| 3072 | n/a | FSRef_New, &theRef, |
|---|
| 3073 | n/a | targetIsFolder, |
|---|
| 3074 | n/a | wasAliased); |
|---|
| 3075 | n/a | return _res; |
|---|
| 3076 | n/a | } |
|---|
| 3077 | n/a | |
|---|
| 3078 | n/a | static PyObject *File_FSResolveAliasFile(PyObject *_self, PyObject *_args) |
|---|
| 3079 | n/a | { |
|---|
| 3080 | n/a | PyObject *_res = NULL; |
|---|
| 3081 | n/a | OSErr _err; |
|---|
| 3082 | n/a | FSRef theRef; |
|---|
| 3083 | n/a | Boolean resolveAliasChains; |
|---|
| 3084 | n/a | Boolean targetIsFolder; |
|---|
| 3085 | n/a | Boolean wasAliased; |
|---|
| 3086 | n/a | if (!PyArg_ParseTuple(_args, "O&b", |
|---|
| 3087 | n/a | FSRef_Convert, &theRef, |
|---|
| 3088 | n/a | &resolveAliasChains)) |
|---|
| 3089 | n/a | return NULL; |
|---|
| 3090 | n/a | _err = FSResolveAliasFile(&theRef, |
|---|
| 3091 | n/a | resolveAliasChains, |
|---|
| 3092 | n/a | &targetIsFolder, |
|---|
| 3093 | n/a | &wasAliased); |
|---|
| 3094 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 3095 | n/a | _res = Py_BuildValue("O&bb", |
|---|
| 3096 | n/a | FSRef_New, &theRef, |
|---|
| 3097 | n/a | targetIsFolder, |
|---|
| 3098 | n/a | wasAliased); |
|---|
| 3099 | n/a | return _res; |
|---|
| 3100 | n/a | } |
|---|
| 3101 | n/a | |
|---|
| 3102 | n/a | static PyObject *File_FSUpdateAlias(PyObject *_self, PyObject *_args) |
|---|
| 3103 | n/a | { |
|---|
| 3104 | n/a | PyObject *_res = NULL; |
|---|
| 3105 | n/a | OSErr _err; |
|---|
| 3106 | n/a | FSRef fromFile__buf__; |
|---|
| 3107 | n/a | FSRef *fromFile = &fromFile__buf__; |
|---|
| 3108 | n/a | FSRef target; |
|---|
| 3109 | n/a | AliasHandle alias; |
|---|
| 3110 | n/a | Boolean wasChanged; |
|---|
| 3111 | n/a | if (!PyArg_ParseTuple(_args, "O&O&O&", |
|---|
| 3112 | n/a | myPyMac_GetOptFSRefPtr, &fromFile, |
|---|
| 3113 | n/a | FSRef_Convert, &target, |
|---|
| 3114 | n/a | Alias_Convert, &alias)) |
|---|
| 3115 | n/a | return NULL; |
|---|
| 3116 | n/a | _err = FSUpdateAlias(fromFile, |
|---|
| 3117 | n/a | &target, |
|---|
| 3118 | n/a | alias, |
|---|
| 3119 | n/a | &wasChanged); |
|---|
| 3120 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 3121 | n/a | _res = Py_BuildValue("b", |
|---|
| 3122 | n/a | wasChanged); |
|---|
| 3123 | n/a | return _res; |
|---|
| 3124 | n/a | } |
|---|
| 3125 | n/a | |
|---|
| 3126 | n/a | static PyObject *File_pathname(PyObject *_self, PyObject *_args) |
|---|
| 3127 | n/a | { |
|---|
| 3128 | n/a | PyObject *_res = NULL; |
|---|
| 3129 | n/a | |
|---|
| 3130 | n/a | PyObject *obj; |
|---|
| 3131 | n/a | |
|---|
| 3132 | n/a | if (!PyArg_ParseTuple(_args, "O", &obj)) |
|---|
| 3133 | n/a | return NULL; |
|---|
| 3134 | n/a | if (PyString_Check(obj)) { |
|---|
| 3135 | n/a | Py_INCREF(obj); |
|---|
| 3136 | n/a | return obj; |
|---|
| 3137 | n/a | } |
|---|
| 3138 | n/a | if (PyUnicode_Check(obj)) |
|---|
| 3139 | n/a | return PyUnicode_AsEncodedString(obj, "utf8", "strict"); |
|---|
| 3140 | n/a | _res = PyObject_CallMethod(obj, "as_pathname", NULL); |
|---|
| 3141 | n/a | return _res; |
|---|
| 3142 | n/a | |
|---|
| 3143 | n/a | } |
|---|
| 3144 | n/a | |
|---|
| 3145 | n/a | static PyMethodDef File_methods[] = { |
|---|
| 3146 | n/a | #ifndef __LP64__ |
|---|
| 3147 | n/a | {"UnmountVol", (PyCFunction)File_UnmountVol, 1, |
|---|
| 3148 | n/a | PyDoc_STR("(Str63 volName, short vRefNum) -> None")}, |
|---|
| 3149 | n/a | {"FlushVol", (PyCFunction)File_FlushVol, 1, |
|---|
| 3150 | n/a | PyDoc_STR("(Str63 volName, short vRefNum) -> None")}, |
|---|
| 3151 | n/a | {"HSetVol", (PyCFunction)File_HSetVol, 1, |
|---|
| 3152 | n/a | PyDoc_STR("(Str63 volName, short vRefNum, long dirID) -> None")}, |
|---|
| 3153 | n/a | {"FSClose", (PyCFunction)File_FSClose, 1, |
|---|
| 3154 | n/a | PyDoc_STR("(short refNum) -> None")}, |
|---|
| 3155 | n/a | {"Allocate", (PyCFunction)File_Allocate, 1, |
|---|
| 3156 | n/a | PyDoc_STR("(short refNum) -> (long count)")}, |
|---|
| 3157 | n/a | {"GetEOF", (PyCFunction)File_GetEOF, 1, |
|---|
| 3158 | n/a | PyDoc_STR("(short refNum) -> (long logEOF)")}, |
|---|
| 3159 | n/a | {"SetEOF", (PyCFunction)File_SetEOF, 1, |
|---|
| 3160 | n/a | PyDoc_STR("(short refNum, long logEOF) -> None")}, |
|---|
| 3161 | n/a | {"GetFPos", (PyCFunction)File_GetFPos, 1, |
|---|
| 3162 | n/a | PyDoc_STR("(short refNum) -> (long filePos)")}, |
|---|
| 3163 | n/a | {"SetFPos", (PyCFunction)File_SetFPos, 1, |
|---|
| 3164 | n/a | PyDoc_STR("(short refNum, short posMode, long posOff) -> None")}, |
|---|
| 3165 | n/a | {"GetVRefNum", (PyCFunction)File_GetVRefNum, 1, |
|---|
| 3166 | n/a | PyDoc_STR("(short fileRefNum) -> (short vRefNum)")}, |
|---|
| 3167 | n/a | {"HGetVol", (PyCFunction)File_HGetVol, 1, |
|---|
| 3168 | n/a | PyDoc_STR("(StringPtr volName) -> (short vRefNum, long dirID)")}, |
|---|
| 3169 | n/a | {"HOpen", (PyCFunction)File_HOpen, 1, |
|---|
| 3170 | n/a | PyDoc_STR("(short vRefNum, long dirID, Str255 fileName, SInt8 permission) -> (short refNum)")}, |
|---|
| 3171 | n/a | {"HOpenDF", (PyCFunction)File_HOpenDF, 1, |
|---|
| 3172 | n/a | PyDoc_STR("(short vRefNum, long dirID, Str255 fileName, SInt8 permission) -> (short refNum)")}, |
|---|
| 3173 | n/a | {"HOpenRF", (PyCFunction)File_HOpenRF, 1, |
|---|
| 3174 | n/a | PyDoc_STR("(short vRefNum, long dirID, Str255 fileName, SInt8 permission) -> (short refNum)")}, |
|---|
| 3175 | n/a | {"AllocContig", (PyCFunction)File_AllocContig, 1, |
|---|
| 3176 | n/a | PyDoc_STR("(short refNum) -> (long count)")}, |
|---|
| 3177 | n/a | {"HCreate", (PyCFunction)File_HCreate, 1, |
|---|
| 3178 | n/a | PyDoc_STR("(short vRefNum, long dirID, Str255 fileName, OSType creator, OSType fileType) -> None")}, |
|---|
| 3179 | n/a | {"DirCreate", (PyCFunction)File_DirCreate, 1, |
|---|
| 3180 | n/a | PyDoc_STR("(short vRefNum, long parentDirID, Str255 directoryName) -> (long createdDirID)")}, |
|---|
| 3181 | n/a | {"HDelete", (PyCFunction)File_HDelete, 1, |
|---|
| 3182 | n/a | PyDoc_STR("(short vRefNum, long dirID, Str255 fileName) -> None")}, |
|---|
| 3183 | n/a | {"HGetFInfo", (PyCFunction)File_HGetFInfo, 1, |
|---|
| 3184 | n/a | PyDoc_STR("(short vRefNum, long dirID, Str255 fileName) -> (FInfo fndrInfo)")}, |
|---|
| 3185 | n/a | {"HSetFInfo", (PyCFunction)File_HSetFInfo, 1, |
|---|
| 3186 | n/a | PyDoc_STR("(short vRefNum, long dirID, Str255 fileName, FInfo fndrInfo) -> None")}, |
|---|
| 3187 | n/a | {"HSetFLock", (PyCFunction)File_HSetFLock, 1, |
|---|
| 3188 | n/a | PyDoc_STR("(short vRefNum, long dirID, Str255 fileName) -> None")}, |
|---|
| 3189 | n/a | {"HRstFLock", (PyCFunction)File_HRstFLock, 1, |
|---|
| 3190 | n/a | PyDoc_STR("(short vRefNum, long dirID, Str255 fileName) -> None")}, |
|---|
| 3191 | n/a | {"HRename", (PyCFunction)File_HRename, 1, |
|---|
| 3192 | n/a | PyDoc_STR("(short vRefNum, long dirID, Str255 oldName, Str255 newName) -> None")}, |
|---|
| 3193 | n/a | {"CatMove", (PyCFunction)File_CatMove, 1, |
|---|
| 3194 | n/a | PyDoc_STR("(short vRefNum, long dirID, Str255 oldName, long newDirID, Str255 newName) -> None")}, |
|---|
| 3195 | n/a | {"FSMakeFSSpec", (PyCFunction)File_FSMakeFSSpec, 1, |
|---|
| 3196 | n/a | PyDoc_STR("(short vRefNum, long dirID, Str255 fileName) -> (FSSpec spec)")}, |
|---|
| 3197 | n/a | #endif /* !__LP64__*/ |
|---|
| 3198 | n/a | {"FSGetForkPosition", (PyCFunction)File_FSGetForkPosition, 1, |
|---|
| 3199 | n/a | PyDoc_STR("(SInt16 forkRefNum) -> (SInt64 position)")}, |
|---|
| 3200 | n/a | {"FSSetForkPosition", (PyCFunction)File_FSSetForkPosition, 1, |
|---|
| 3201 | n/a | PyDoc_STR("(SInt16 forkRefNum, UInt16 positionMode, SInt64 positionOffset) -> None")}, |
|---|
| 3202 | n/a | {"FSGetForkSize", (PyCFunction)File_FSGetForkSize, 1, |
|---|
| 3203 | n/a | PyDoc_STR("(SInt16 forkRefNum) -> (SInt64 forkSize)")}, |
|---|
| 3204 | n/a | {"FSSetForkSize", (PyCFunction)File_FSSetForkSize, 1, |
|---|
| 3205 | n/a | PyDoc_STR("(SInt16 forkRefNum, UInt16 positionMode, SInt64 positionOffset) -> None")}, |
|---|
| 3206 | n/a | {"FSAllocateFork", (PyCFunction)File_FSAllocateFork, 1, |
|---|
| 3207 | n/a | PyDoc_STR("(SInt16 forkRefNum, FSAllocationFlags flags, UInt16 positionMode, SInt64 positionOffset, UInt64 requestCount) -> (UInt64 actualCount)")}, |
|---|
| 3208 | n/a | {"FSFlushFork", (PyCFunction)File_FSFlushFork, 1, |
|---|
| 3209 | n/a | PyDoc_STR("(SInt16 forkRefNum) -> None")}, |
|---|
| 3210 | n/a | {"FSCloseFork", (PyCFunction)File_FSCloseFork, 1, |
|---|
| 3211 | n/a | PyDoc_STR("(SInt16 forkRefNum) -> None")}, |
|---|
| 3212 | n/a | {"FSGetDataForkName", (PyCFunction)File_FSGetDataForkName, 1, |
|---|
| 3213 | n/a | PyDoc_STR("() -> (HFSUniStr255 dataForkName)")}, |
|---|
| 3214 | n/a | {"FSGetResourceForkName", (PyCFunction)File_FSGetResourceForkName, 1, |
|---|
| 3215 | n/a | PyDoc_STR("() -> (HFSUniStr255 resourceForkName)")}, |
|---|
| 3216 | n/a | {"FSPathMakeRef", (PyCFunction)File_FSPathMakeRef, 1, |
|---|
| 3217 | n/a | PyDoc_STR("(UInt8 * path) -> (FSRef ref, Boolean isDirectory)")}, |
|---|
| 3218 | n/a | {"FNNotifyByPath", (PyCFunction)File_FNNotifyByPath, 1, |
|---|
| 3219 | n/a | PyDoc_STR("(UInt8 * path, FNMessage message, OptionBits flags) -> None")}, |
|---|
| 3220 | n/a | {"FNNotifyAll", (PyCFunction)File_FNNotifyAll, 1, |
|---|
| 3221 | n/a | PyDoc_STR("(FNMessage message, OptionBits flags) -> None")}, |
|---|
| 3222 | n/a | #ifndef __LP64__ |
|---|
| 3223 | n/a | {"NewAlias", (PyCFunction)File_NewAlias, 1, |
|---|
| 3224 | n/a | PyDoc_STR("(FSSpec fromFile, FSSpec target) -> (AliasHandle alias)")}, |
|---|
| 3225 | n/a | {"NewAliasMinimalFromFullPath", (PyCFunction)File_NewAliasMinimalFromFullPath, 1, |
|---|
| 3226 | n/a | PyDoc_STR("(Buffer fullPath, Str32 zoneName, Str31 serverName) -> (AliasHandle alias)")}, |
|---|
| 3227 | n/a | {"ResolveAliasFile", (PyCFunction)File_ResolveAliasFile, 1, |
|---|
| 3228 | n/a | PyDoc_STR("(FSSpec theSpec, Boolean resolveAliasChains) -> (FSSpec theSpec, Boolean targetIsFolder, Boolean wasAliased)")}, |
|---|
| 3229 | n/a | {"ResolveAliasFileWithMountFlags", (PyCFunction)File_ResolveAliasFileWithMountFlags, 1, |
|---|
| 3230 | n/a | PyDoc_STR("(FSSpec theSpec, Boolean resolveAliasChains, unsigned long mountFlags) -> (FSSpec theSpec, Boolean targetIsFolder, Boolean wasAliased)")}, |
|---|
| 3231 | n/a | {"UpdateAlias", (PyCFunction)File_UpdateAlias, 1, |
|---|
| 3232 | n/a | PyDoc_STR("(FSSpec fromFile, FSSpec target, AliasHandle alias) -> (Boolean wasChanged)")}, |
|---|
| 3233 | n/a | {"ResolveAliasFileWithMountFlagsNoUI", (PyCFunction)File_ResolveAliasFileWithMountFlagsNoUI, 1, |
|---|
| 3234 | n/a | PyDoc_STR("(FSSpec theSpec, Boolean resolveAliasChains, unsigned long mountFlags) -> (FSSpec theSpec, Boolean targetIsFolder, Boolean wasAliased)")}, |
|---|
| 3235 | n/a | #endif /* !__LP64__ */ |
|---|
| 3236 | n/a | {"FSNewAlias", (PyCFunction)File_FSNewAlias, 1, |
|---|
| 3237 | n/a | PyDoc_STR("(FSRef fromFile, FSRef target) -> (AliasHandle inAlias)")}, |
|---|
| 3238 | n/a | {"FSResolveAliasFileWithMountFlags", (PyCFunction)File_FSResolveAliasFileWithMountFlags, 1, |
|---|
| 3239 | n/a | PyDoc_STR("(FSRef theRef, Boolean resolveAliasChains, unsigned long mountFlags) -> (FSRef theRef, Boolean targetIsFolder, Boolean wasAliased)")}, |
|---|
| 3240 | n/a | {"FSResolveAliasFile", (PyCFunction)File_FSResolveAliasFile, 1, |
|---|
| 3241 | n/a | PyDoc_STR("(FSRef theRef, Boolean resolveAliasChains) -> (FSRef theRef, Boolean targetIsFolder, Boolean wasAliased)")}, |
|---|
| 3242 | n/a | {"FSUpdateAlias", (PyCFunction)File_FSUpdateAlias, 1, |
|---|
| 3243 | n/a | PyDoc_STR("(FSRef fromFile, FSRef target, AliasHandle alias) -> (Boolean wasChanged)")}, |
|---|
| 3244 | n/a | {"pathname", (PyCFunction)File_pathname, 1, |
|---|
| 3245 | n/a | PyDoc_STR("(str|unicode|FSSpec|FSref) -> pathname")}, |
|---|
| 3246 | n/a | {NULL, NULL, 0} |
|---|
| 3247 | n/a | }; |
|---|
| 3248 | n/a | |
|---|
| 3249 | n/a | |
|---|
| 3250 | n/a | #ifndef __LP64__ |
|---|
| 3251 | n/a | int |
|---|
| 3252 | n/a | PyMac_GetFSSpec(PyObject *v, FSSpec *spec) |
|---|
| 3253 | n/a | { |
|---|
| 3254 | n/a | Str255 path; |
|---|
| 3255 | n/a | short refnum; |
|---|
| 3256 | n/a | long parid; |
|---|
| 3257 | n/a | OSErr err; |
|---|
| 3258 | n/a | FSRef fsr; |
|---|
| 3259 | n/a | |
|---|
| 3260 | n/a | if (FSSpec_Check(v)) { |
|---|
| 3261 | n/a | *spec = ((FSSpecObject *)v)->ob_itself; |
|---|
| 3262 | n/a | return 1; |
|---|
| 3263 | n/a | } |
|---|
| 3264 | n/a | |
|---|
| 3265 | n/a | if (PyArg_Parse(v, "(hlO&)", |
|---|
| 3266 | n/a | &refnum, &parid, PyMac_GetStr255, &path)) { |
|---|
| 3267 | n/a | err = FSMakeFSSpec(refnum, parid, path, spec); |
|---|
| 3268 | n/a | if ( err && err != fnfErr ) { |
|---|
| 3269 | n/a | PyMac_Error(err); |
|---|
| 3270 | n/a | return 0; |
|---|
| 3271 | n/a | } |
|---|
| 3272 | n/a | return 1; |
|---|
| 3273 | n/a | } |
|---|
| 3274 | n/a | PyErr_Clear(); |
|---|
| 3275 | n/a | /* Otherwise we try to go via an FSRef. On OSX we go all the way, |
|---|
| 3276 | n/a | ** on OS9 we accept only a real FSRef object |
|---|
| 3277 | n/a | */ |
|---|
| 3278 | n/a | if ( PyMac_GetFSRef(v, &fsr) ) { |
|---|
| 3279 | n/a | err = FSGetCatalogInfo(&fsr, kFSCatInfoNone, NULL, NULL, spec, NULL); |
|---|
| 3280 | n/a | if (err != noErr) { |
|---|
| 3281 | n/a | PyMac_Error(err); |
|---|
| 3282 | n/a | return 0; |
|---|
| 3283 | n/a | } |
|---|
| 3284 | n/a | return 1; |
|---|
| 3285 | n/a | } |
|---|
| 3286 | n/a | return 0; |
|---|
| 3287 | n/a | } |
|---|
| 3288 | n/a | #endif /* !__LP64__ */ |
|---|
| 3289 | n/a | |
|---|
| 3290 | n/a | int |
|---|
| 3291 | n/a | PyMac_GetFSRef(PyObject *v, FSRef *fsr) |
|---|
| 3292 | n/a | { |
|---|
| 3293 | n/a | OSStatus err; |
|---|
| 3294 | n/a | #ifndef __LP64__ |
|---|
| 3295 | n/a | FSSpec fss; |
|---|
| 3296 | n/a | #endif /* !__LP64__ */ |
|---|
| 3297 | n/a | |
|---|
| 3298 | n/a | if (FSRef_Check(v)) { |
|---|
| 3299 | n/a | *fsr = ((FSRefObject *)v)->ob_itself; |
|---|
| 3300 | n/a | return 1; |
|---|
| 3301 | n/a | } |
|---|
| 3302 | n/a | |
|---|
| 3303 | n/a | /* On OSX we now try a pathname */ |
|---|
| 3304 | n/a | if ( PyString_Check(v) || PyUnicode_Check(v)) { |
|---|
| 3305 | n/a | char *path = NULL; |
|---|
| 3306 | n/a | if (!PyArg_Parse(v, "et", Py_FileSystemDefaultEncoding, &path)) |
|---|
| 3307 | n/a | return 0; |
|---|
| 3308 | n/a | if ( (err=FSPathMakeRef((unsigned char*)path, fsr, NULL)) ) |
|---|
| 3309 | n/a | PyMac_Error(err); |
|---|
| 3310 | n/a | PyMem_Free(path); |
|---|
| 3311 | n/a | return !err; |
|---|
| 3312 | n/a | } |
|---|
| 3313 | n/a | /* XXXX Should try unicode here too */ |
|---|
| 3314 | n/a | |
|---|
| 3315 | n/a | #ifndef __LP64__ |
|---|
| 3316 | n/a | /* Otherwise we try to go via an FSSpec */ |
|---|
| 3317 | n/a | if (FSSpec_Check(v)) { |
|---|
| 3318 | n/a | fss = ((FSSpecObject *)v)->ob_itself; |
|---|
| 3319 | n/a | if ((err=FSpMakeFSRef(&fss, fsr)) == 0) |
|---|
| 3320 | n/a | return 1; |
|---|
| 3321 | n/a | PyMac_Error(err); |
|---|
| 3322 | n/a | return 0; |
|---|
| 3323 | n/a | } |
|---|
| 3324 | n/a | #endif /* !__LP64__ */ |
|---|
| 3325 | n/a | |
|---|
| 3326 | n/a | PyErr_SetString(PyExc_TypeError, "FSRef, FSSpec or pathname required"); |
|---|
| 3327 | n/a | return 0; |
|---|
| 3328 | n/a | } |
|---|
| 3329 | n/a | |
|---|
| 3330 | n/a | #ifndef __LP64__ |
|---|
| 3331 | n/a | extern PyObject * |
|---|
| 3332 | n/a | PyMac_BuildFSSpec(FSSpec *spec) |
|---|
| 3333 | n/a | { |
|---|
| 3334 | n/a | return FSSpec_New(spec); |
|---|
| 3335 | n/a | } |
|---|
| 3336 | n/a | #endif /* !__LP64__ */ |
|---|
| 3337 | n/a | |
|---|
| 3338 | n/a | extern PyObject * |
|---|
| 3339 | n/a | PyMac_BuildFSRef(FSRef *spec) |
|---|
| 3340 | n/a | { |
|---|
| 3341 | n/a | return FSRef_New(spec); |
|---|
| 3342 | n/a | } |
|---|
| 3343 | n/a | |
|---|
| 3344 | n/a | |
|---|
| 3345 | n/a | void init_File(void) |
|---|
| 3346 | n/a | { |
|---|
| 3347 | n/a | PyObject *m; |
|---|
| 3348 | n/a | PyObject *d; |
|---|
| 3349 | n/a | |
|---|
| 3350 | n/a | |
|---|
| 3351 | n/a | #ifndef __LP64__ |
|---|
| 3352 | n/a | PyMac_INIT_TOOLBOX_OBJECT_NEW(FSSpec *, PyMac_BuildFSSpec); |
|---|
| 3353 | n/a | PyMac_INIT_TOOLBOX_OBJECT_CONVERT(FSSpec, PyMac_GetFSSpec); |
|---|
| 3354 | n/a | #endif /* !__LP64__ */ |
|---|
| 3355 | n/a | |
|---|
| 3356 | n/a | PyMac_INIT_TOOLBOX_OBJECT_NEW(FSRef *, PyMac_BuildFSRef); |
|---|
| 3357 | n/a | PyMac_INIT_TOOLBOX_OBJECT_CONVERT(FSRef, PyMac_GetFSRef); |
|---|
| 3358 | n/a | |
|---|
| 3359 | n/a | |
|---|
| 3360 | n/a | m = Py_InitModule("_File", File_methods); |
|---|
| 3361 | n/a | d = PyModule_GetDict(m); |
|---|
| 3362 | n/a | File_Error = PyMac_GetOSErrException(); |
|---|
| 3363 | n/a | if (File_Error == NULL || |
|---|
| 3364 | n/a | PyDict_SetItemString(d, "Error", File_Error) != 0) |
|---|
| 3365 | n/a | return; |
|---|
| 3366 | n/a | FSCatalogInfo_Type.ob_type = &PyType_Type; |
|---|
| 3367 | n/a | if (PyType_Ready(&FSCatalogInfo_Type) < 0) return; |
|---|
| 3368 | n/a | Py_INCREF(&FSCatalogInfo_Type); |
|---|
| 3369 | n/a | PyModule_AddObject(m, "FSCatalogInfo", (PyObject *)&FSCatalogInfo_Type); |
|---|
| 3370 | n/a | /* Backward-compatible name */ |
|---|
| 3371 | n/a | Py_INCREF(&FSCatalogInfo_Type); |
|---|
| 3372 | n/a | PyModule_AddObject(m, "FSCatalogInfoType", (PyObject *)&FSCatalogInfo_Type); |
|---|
| 3373 | n/a | |
|---|
| 3374 | n/a | #ifndef __LP64__ |
|---|
| 3375 | n/a | FInfo_Type.ob_type = &PyType_Type; |
|---|
| 3376 | n/a | if (PyType_Ready(&FInfo_Type) < 0) return; |
|---|
| 3377 | n/a | Py_INCREF(&FInfo_Type); |
|---|
| 3378 | n/a | PyModule_AddObject(m, "FInfo", (PyObject *)&FInfo_Type); |
|---|
| 3379 | n/a | /* Backward-compatible name */ |
|---|
| 3380 | n/a | Py_INCREF(&FInfo_Type); |
|---|
| 3381 | n/a | PyModule_AddObject(m, "FInfoType", (PyObject *)&FInfo_Type); |
|---|
| 3382 | n/a | #endif /* !__LP64__ */ |
|---|
| 3383 | n/a | Alias_Type.ob_type = &PyType_Type; |
|---|
| 3384 | n/a | if (PyType_Ready(&Alias_Type) < 0) return; |
|---|
| 3385 | n/a | Py_INCREF(&Alias_Type); |
|---|
| 3386 | n/a | PyModule_AddObject(m, "Alias", (PyObject *)&Alias_Type); |
|---|
| 3387 | n/a | /* Backward-compatible name */ |
|---|
| 3388 | n/a | Py_INCREF(&Alias_Type); |
|---|
| 3389 | n/a | PyModule_AddObject(m, "AliasType", (PyObject *)&Alias_Type); |
|---|
| 3390 | n/a | |
|---|
| 3391 | n/a | #ifndef __LP64__ |
|---|
| 3392 | n/a | FSSpec_Type.ob_type = &PyType_Type; |
|---|
| 3393 | n/a | if (PyType_Ready(&FSSpec_Type) < 0) return; |
|---|
| 3394 | n/a | Py_INCREF(&FSSpec_Type); |
|---|
| 3395 | n/a | PyModule_AddObject(m, "FSSpec", (PyObject *)&FSSpec_Type); |
|---|
| 3396 | n/a | /* Backward-compatible name */ |
|---|
| 3397 | n/a | Py_INCREF(&FSSpec_Type); |
|---|
| 3398 | n/a | PyModule_AddObject(m, "FSSpecType", (PyObject *)&FSSpec_Type); |
|---|
| 3399 | n/a | #endif /* !__LP64__ */ |
|---|
| 3400 | n/a | FSRef_Type.ob_type = &PyType_Type; |
|---|
| 3401 | n/a | if (PyType_Ready(&FSRef_Type) < 0) return; |
|---|
| 3402 | n/a | Py_INCREF(&FSRef_Type); |
|---|
| 3403 | n/a | PyModule_AddObject(m, "FSRef", (PyObject *)&FSRef_Type); |
|---|
| 3404 | n/a | /* Backward-compatible name */ |
|---|
| 3405 | n/a | Py_INCREF(&FSRef_Type); |
|---|
| 3406 | n/a | PyModule_AddObject(m, "FSRefType", (PyObject *)&FSRef_Type); |
|---|
| 3407 | n/a | } |
|---|
| 3408 | n/a | |
|---|
| 3409 | n/a | /* ======================== End module _File ======================== */ |
|---|
| 3410 | n/a | |
|---|