285
285
cwd = getcwd(NULL, 0)
286
286
if -1 == chdir(path):
287
287
raise OSError(errno, strerror(errno))
288
the_dir = opendir(".")
290
raise OSError(errno, strerror(errno))
295
# Unlike most libc functions, readdir needs errno set to 0
296
# beforehand so that eof can be distinguished from errors. See
297
# <https://bugs.launchpad.net/bzr/+bug/279381>
300
entry = readdir(the_dir)
301
if entry == NULL and (errno == EAGAIN or errno == EINTR):
307
if errno == ENOTDIR or errno == 0:
308
# We see ENOTDIR at the end of a normal directory.
309
# As ENOTDIR for read_dir(file) is triggered on opendir,
310
# we consider ENOTDIR to be 'no error'.
313
raise OSError(errno, strerror(errno))
315
if not (name[0] == c"." and (
317
(name[1] == c"." and name[2] == 0))
320
stat_result = lstat(entry.d_name, &statvalue._st)
289
the_dir = opendir(".")
291
raise OSError(errno, strerror(errno))
296
# Unlike most libc functions, readdir needs errno set to 0
297
# beforehand so that eof can be distinguished from errors. See
298
# <https://bugs.launchpad.net/bzr/+bug/279381>
301
entry = readdir(the_dir)
302
if entry == NULL and (errno == EAGAIN or errno == EINTR):
308
if errno == ENOTDIR or errno == 0:
309
# We see ENOTDIR at the end of a normal directory.
310
# As ENOTDIR for read_dir(file) is triggered on opendir,
311
# we consider ENOTDIR to be 'no error'.
323
314
raise OSError(errno, strerror(errno))
327
# We append a 5-tuple that can be modified in-place by the C
329
# inode to sort on (to replace with top_path)
331
# kind (None, to set)
332
# statvalue (to keep)
333
# abspath (None, to set)
334
PyList_Append(result, (entry.d_ino, entry.d_name, None,
316
if not (name[0] == c"." and (
318
(name[1] == c"." and name[2] == 0))
321
stat_result = lstat(entry.d_name, &statvalue._st)
324
raise OSError(errno, strerror(errno))
328
# We append a 5-tuple that can be modified in-place by the C
330
# inode to sort on (to replace with top_path)
332
# kind (None, to set)
333
# statvalue (to keep)
334
# abspath (None, to set)
335
PyList_Append(result, (entry.d_ino, entry.d_name, None,
338
if -1 == closedir(the_dir):
339
raise OSError(errno, strerror(errno))
337
341
if -1 == chdir(cwd):
339
343
raise OSError(errno, strerror(errno))
341
if -1 == closedir(the_dir):
342
raise OSError(errno, strerror(errno))