Show More
@@ -276,6 +276,16 b' int entkind(struct dirent *ent)' | |||||
276 | return -1; |
|
276 | return -1; | |
277 | } |
|
277 | } | |
278 |
|
278 | |||
|
279 | static PyObject *makestat(const struct stat *st) | |||
|
280 | { | |||
|
281 | PyObject *stat; | |||
|
282 | ||||
|
283 | stat = PyObject_CallObject((PyObject *)&listdir_stat_type, NULL); | |||
|
284 | if (stat) | |||
|
285 | memcpy(&((struct listdir_stat *)stat)->st, st, sizeof(*st)); | |||
|
286 | return stat; | |||
|
287 | } | |||
|
288 | ||||
279 | static PyObject *_listdir(char *path, int pathlen, int keepstat, char *skip) |
|
289 | static PyObject *_listdir(char *path, int pathlen, int keepstat, char *skip) | |
280 | { |
|
290 | { | |
281 | PyObject *list, *elem, *stat, *ret = NULL; |
|
291 | PyObject *list, *elem, *stat, *ret = NULL; | |
@@ -351,10 +361,9 b' static PyObject *_listdir(char *path, in' | |||||
351 | } |
|
361 | } | |
352 |
|
362 | |||
353 | if (keepstat) { |
|
363 | if (keepstat) { | |
354 | stat = PyObject_CallObject((PyObject *)&listdir_stat_type, NULL); |
|
364 | stat = makestat(&st); | |
355 | if (!stat) |
|
365 | if (!stat) | |
356 | goto error; |
|
366 | goto error; | |
357 | memcpy(&((struct listdir_stat *)stat)->st, &st, sizeof(st)); |
|
|||
358 | elem = Py_BuildValue("siN", ent->d_name, kind, stat); |
|
367 | elem = Py_BuildValue("siN", ent->d_name, kind, stat); | |
359 | } else |
|
368 | } else | |
360 | elem = Py_BuildValue("si", ent->d_name, kind); |
|
369 | elem = Py_BuildValue("si", ent->d_name, kind); |
General Comments 0
You need to be logged in to leave comments.
Login now