~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/_readdir_pyx.pyx

  • Committer: Matt Nordhoff
  • Date: 2009-04-04 02:50:01 UTC
  • mfrom: (4253 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4256.
  • Revision ID: mnordhoff@mattnordhoff.com-20090404025001-z1403k0tatmc8l91
Merge bzr.dev, fixing conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006, 2008 Canonical Ltd
 
1
# Copyright (C) 2006, 2008, 2009 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
"""Wrapper for readdir which returns files ordered by inode."""
18
18
 
298
298
        # passing full paths every time.
299
299
        orig_dir_fd = open(".", O_RDONLY, 0)
300
300
        if orig_dir_fd == -1:
301
 
            raise OSError(errno, strerror(errno))
 
301
            raise OSError(errno, "open: " + strerror(errno), ".")
302
302
        if -1 == chdir(path):
303
 
            raise OSError(errno, strerror(errno))
 
303
            raise OSError(errno, "chdir: " + strerror(errno), path)
304
304
    else:
305
305
        orig_dir_fd = -1
306
306
 
307
307
    try:
308
308
        the_dir = opendir(".")
309
309
        if NULL == the_dir:
310
 
            raise OSError(errno, strerror(errno))
 
310
            raise OSError(errno, "opendir: " + strerror(errno), path)
311
311
        try:
312
312
            result = []
313
313
            entry = &sentinel
330
330
                        # we consider ENOTDIR to be 'no error'.
331
331
                        continue
332
332
                    else:
333
 
                        raise OSError(errno, strerror(errno))
 
333
                        raise OSError(errno, "readdir: " + strerror(errno), path)
334
334
                name = entry.d_name
335
335
                if not (name[0] == c"." and (
336
336
                    (name[1] == 0) or 
340
340
                    stat_result = lstat(entry.d_name, &statvalue._st)
341
341
                    if stat_result != 0:
342
342
                        if errno != ENOENT:
343
 
                            raise OSError(errno, strerror(errno))
 
343
                            raise OSError(errno, "lstat: " + strerror(errno),
 
344
                                path + "/" + entry.d_name)
344
345
                        else:
345
346
                            kind = _missing
346
347
                            statvalue = None
355
356
                        statvalue, None))
356
357
        finally:
357
358
            if -1 == closedir(the_dir):
358
 
                raise OSError(errno, strerror(errno))
 
359
                raise OSError(errno, "closedir: " + strerror(errno), path)
359
360
    finally:
360
361
        if -1 != orig_dir_fd:
361
362
            failed = False
363
364
                # try to close the original directory anyhow
364
365
                failed = True
365
366
            if -1 == close(orig_dir_fd) or failed:
366
 
                raise OSError(errno, strerror(errno))
 
367
                raise OSError(errno, "return to orig_dir: " + strerror(errno))
367
368
 
368
369
    return result
369
370