Show More
@@ -391,51 +391,51 b' error_value:' | |||||
391 |
|
391 | |||
392 | static PyObject *statfiles(PyObject *self, PyObject *args) |
|
392 | static PyObject *statfiles(PyObject *self, PyObject *args) | |
393 | { |
|
393 | { | |
394 |
|
|
394 | PyObject *names, *stats; | |
395 |
|
|
395 | Py_ssize_t i, count; | |
396 |
|
396 | |||
397 |
|
|
397 | if (!PyArg_ParseTuple(args, "O:statfiles", &names)) | |
398 | return NULL; |
|
398 | return NULL; | |
399 |
|
399 | |||
400 |
|
|
400 | count = PySequence_Length(names); | |
401 |
|
|
401 | if (count == -1) { | |
402 |
|
|
402 | PyErr_SetString(PyExc_TypeError, "not a sequence"); | |
403 | return NULL; |
|
403 | return NULL; | |
404 | } |
|
404 | } | |
405 |
|
405 | |||
406 |
|
|
406 | stats = PyList_New(count); | |
407 |
|
|
407 | if (stats == NULL) | |
408 | return NULL; |
|
408 | return NULL; | |
409 |
|
409 | |||
410 |
|
|
410 | for (i = 0; i < count; i++) { | |
411 |
|
|
411 | PyObject *stat; | |
412 |
|
|
412 | struct stat st; | |
413 |
|
|
413 | int ret, kind; | |
414 | char *path; |
|
414 | char *path; | |
415 |
|
415 | |||
416 |
|
|
416 | path = PyString_AsString(PySequence_GetItem(names, i)); | |
417 |
|
|
417 | if (path == NULL) { | |
418 |
|
|
418 | PyErr_SetString(PyExc_TypeError, "not a string"); | |
419 | goto bail; |
|
419 | goto bail; | |
420 | } |
|
420 | } | |
421 |
|
|
421 | ret = lstat(path, &st); | |
422 |
|
|
422 | kind = st.st_mode & S_IFMT; | |
423 |
|
|
423 | if (ret != -1 && (kind == S_IFREG || kind == S_IFLNK)) { | |
424 |
|
|
424 | stat = makestat(&st); | |
425 | if (stat == NULL) |
|
425 | if (stat == NULL) | |
426 | goto bail; |
|
426 | goto bail; | |
427 |
|
|
427 | PyList_SET_ITEM(stats, i, stat); | |
428 | } else { |
|
428 | } else { | |
429 | Py_INCREF(Py_None); |
|
429 | Py_INCREF(Py_None); | |
430 |
|
|
430 | PyList_SET_ITEM(stats, i, Py_None); | |
431 | } |
|
431 | } | |
432 | } |
|
432 | } | |
433 |
|
433 | |||
434 |
|
|
434 | return stats; | |
435 |
|
435 | |||
436 | bail: |
|
436 | bail: | |
437 |
|
|
437 | Py_DECREF(stats); | |
438 |
|
|
438 | return NULL; | |
439 | } |
|
439 | } | |
440 |
|
440 | |||
441 | #endif /* ndef _WIN32 */ |
|
441 | #endif /* ndef _WIN32 */ |
General Comments 0
You need to be logged in to leave comments.
Login now