156
147
(mode, ino, dev, nlink, uid, gid, size, None(atime), mtime, ctime)
158
149
return repr((self.st_mode, 0, 0, 0, 0, 0, self.st_size, None,
159
self.st_mtime, self.st_ctime))
150
self._mtime, self._ctime))
162
153
from bzrlib import osutils
295
280
cdef int stat_result
296
281
cdef _Stat statvalue
300
# Avoid chdir('') because it causes problems on Sun OS, and avoid this if
302
if path != "" and path != '.':
303
# we change into the requested directory before reading, and back at the
304
# end, because that turns out to make the stat calls measurably faster than
305
# passing full paths every time.
306
orig_dir_fd = open(".", O_RDONLY, 0)
307
if orig_dir_fd == -1:
308
raise_os_error(errno, "open: ", ".")
309
if -1 == chdir(path):
310
raise_os_error(errno, "chdir: ", path)
285
cwd = getcwd(NULL, 0)
286
if -1 == chdir(path):
287
raise OSError(errno, strerror(errno))
288
the_dir = opendir(".")
290
raise OSError(errno, strerror(errno))
315
the_dir = opendir(".")
317
raise_os_error(errno, "opendir: ", path)
322
# Unlike most libc functions, readdir needs errno set to 0
323
# beforehand so that eof can be distinguished from errors. See
324
# <https://bugs.launchpad.net/bzr/+bug/279381>
327
entry = readdir(the_dir)
328
if entry == NULL and (errno == EAGAIN or errno == EINTR):
336
if errno == ENOTDIR or errno == 0:
337
# We see ENOTDIR at the end of a normal directory.
338
# As ENOTDIR for read_dir(file) is triggered on opendir,
339
# we consider ENOTDIR to be 'no error'.
342
raise_os_error(errno, "readdir: ", path)
344
if not (name[0] == c"." and (
346
(name[1] == c"." and name[2] == 0))
349
stat_result = lstat(entry.d_name, &statvalue._st)
352
raise_os_error(errno, "lstat: ",
353
path + "/" + entry.d_name)
355
# the file seems to have disappeared after being
356
# seen by readdir - perhaps a transient temporary
357
# file. there's no point returning it.
359
# We append a 5-tuple that can be modified in-place by the C
361
# inode to sort on (to replace with top_path)
363
# kind (None, to set)
364
# statvalue (to keep)
365
# abspath (None, to set)
366
PyList_Append(result, (entry.d_ino, entry.d_name, None,
369
if -1 == closedir(the_dir):
370
raise_os_error(errno, "closedir: ", path)
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)
323
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,
372
if -1 != orig_dir_fd:
374
if -1 == fchdir(orig_dir_fd):
375
# try to close the original directory anyhow
377
if -1 == close(orig_dir_fd) or failed:
378
raise_os_error(errno, "return to orig_dir: ", "")
339
raise OSError(errno, strerror(errno))
341
if -1 == closedir(the_dir):
342
raise OSError(errno, strerror(errno))