equal
deleted
inserted
replaced
274 } |
274 } |
275 #endif |
275 #endif |
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; |
282 char fullpath[PATH_MAX + 10]; |
292 char fullpath[PATH_MAX + 10]; |
283 int kind, err; |
293 int kind, err; |
349 ret = PyList_New(0); |
359 ret = PyList_New(0); |
350 goto error; |
360 goto error; |
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); |
361 if (!elem) |
370 if (!elem) |
362 goto error; |
371 goto error; |