368 |
return Py_BuildValue("s", unquote(s)); |
return Py_BuildValue("s", unquote(s)); |
369 |
} |
} |
370 |
|
|
371 |
|
/* ------------- lchown taken from Python's posixmodule.c -------------- */ |
372 |
|
/* duplicate here to avoid v2.3 requirement */ |
373 |
|
|
374 |
|
static PyObject * |
375 |
|
posix_error_with_allocated_filename(char* name) |
376 |
|
{ |
377 |
|
PyObject *rc = PyErr_SetFromErrnoWithFilename(PyExc_OSError, name); |
378 |
|
PyMem_Free(name); |
379 |
|
return rc; |
380 |
|
} |
381 |
|
|
382 |
|
static PyObject * |
383 |
|
posix_lchown(PyObject *self, PyObject *args) |
384 |
|
{ |
385 |
|
char *path = NULL; |
386 |
|
int uid, gid; |
387 |
|
int res; |
388 |
|
if (!PyArg_ParseTuple(args, "etii:lchown", |
389 |
|
Py_FileSystemDefaultEncoding, &path, |
390 |
|
&uid, &gid)) |
391 |
|
return NULL; |
392 |
|
Py_BEGIN_ALLOW_THREADS |
393 |
|
res = lchown(path, (uid_t) uid, (gid_t) gid); |
394 |
|
Py_END_ALLOW_THREADS |
395 |
|
if (res < 0) |
396 |
|
return posix_error_with_allocated_filename(path); |
397 |
|
PyMem_Free(path); |
398 |
|
Py_INCREF(Py_None); |
399 |
|
return Py_None; |
400 |
|
} |
401 |
|
|
402 |
/* ------------- Python export lists -------------------------------- */ |
/* ------------- Python export lists -------------------------------- */ |
403 |
|
|
411 |
"Quote string, escaping non-printables"}, |
"Quote string, escaping non-printables"}, |
412 |
{"acl_unquote", acl_unquote, METH_VARARGS, |
{"acl_unquote", acl_unquote, METH_VARARGS, |
413 |
"Unquote string, producing original input to quote"}, |
"Unquote string, producing original input to quote"}, |
414 |
|
{"lchown", posix_lchown, METH_VARARGS, |
415 |
|
"Like chown, but don't follow symlinks"}, |
416 |
{NULL, NULL, 0, NULL} |
{NULL, NULL, 0, NULL} |
417 |
}; |
}; |
418 |
|
|