/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/readdir.c

  • Committer: Robert Collins
  • Date: 2008-08-20 02:07:36 UTC
  • mfrom: (3640 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3682.
  • Revision ID: robertc@robertcollins.net-20080820020736-g2xe4921zzxtymle
Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Generated by Pyrex 0.9.6.4 on Wed Aug 20 12:04:52 2008 */
 
2
 
 
3
#define PY_SSIZE_T_CLEAN
 
4
#include "Python.h"
 
5
#include "structmember.h"
 
6
#ifndef PY_LONG_LONG
 
7
  #define PY_LONG_LONG LONG_LONG
 
8
#endif
 
9
#if PY_VERSION_HEX < 0x02050000
 
10
  typedef int Py_ssize_t;
 
11
  #define PY_SSIZE_T_MAX INT_MAX
 
12
  #define PY_SSIZE_T_MIN INT_MIN
 
13
  #define PyInt_FromSsize_t(z) PyInt_FromLong(z)
 
14
  #define PyInt_AsSsize_t(o)    PyInt_AsLong(o)
 
15
#endif
 
16
#ifndef WIN32
 
17
  #ifndef __stdcall
 
18
    #define __stdcall
 
19
  #endif
 
20
  #ifndef __cdecl
 
21
    #define __cdecl
 
22
  #endif
 
23
#endif
 
24
#ifdef __cplusplus
 
25
#define __PYX_EXTERN_C extern "C"
 
26
#else
 
27
#define __PYX_EXTERN_C extern
 
28
#endif
 
29
#include <math.h>
 
30
#include "errno.h"
 
31
#include "sys/types.h"
 
32
#include "dirent.h"
 
33
#include "readdir.h"
 
34
 
 
35
 
 
36
typedef struct {PyObject **p; char *s;} __Pyx_InternTabEntry; /*proto*/
 
37
typedef struct {PyObject **p; char *s; long n;} __Pyx_StringTabEntry; /*proto*/
 
38
 
 
39
static PyObject *__pyx_m;
 
40
static PyObject *__pyx_b;
 
41
static int __pyx_lineno;
 
42
static char *__pyx_filename;
 
43
static char **__pyx_f;
 
44
 
 
45
static char __pyx_mdoc[] = "Wrapper for readdir which grabs file type from d_type.";
 
46
 
 
47
static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list); /*proto*/
 
48
 
 
49
static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/
 
50
 
 
51
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
 
52
 
 
53
static int __Pyx_InternStrings(__Pyx_InternTabEntry *t); /*proto*/
 
54
 
 
55
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
 
56
 
 
57
static void __Pyx_AddTraceback(char *funcname); /*proto*/
 
58
 
 
59
/* Declarations from readdir */
 
60
 
 
61
 
 
62
 
 
63
/* Implementation of readdir */
 
64
 
 
65
static char __pyx_k11[] = ".";
 
66
 
 
67
static PyObject *__pyx_n_os;
 
68
static PyObject *__pyx_n_sys;
 
69
static PyObject *__pyx_n__directory;
 
70
static PyObject *__pyx_n_directory;
 
71
static PyObject *__pyx_n__chardev;
 
72
static PyObject *__pyx_n_chardev;
 
73
static PyObject *__pyx_n__block;
 
74
static PyObject *__pyx_n_block;
 
75
static PyObject *__pyx_n__file;
 
76
static PyObject *__pyx_n_file;
 
77
static PyObject *__pyx_n__fifo;
 
78
static PyObject *__pyx_n_fifo;
 
79
static PyObject *__pyx_n__symlink;
 
80
static PyObject *__pyx_n_symlink;
 
81
static PyObject *__pyx_n__socket;
 
82
static PyObject *__pyx_n_socket;
 
83
static PyObject *__pyx_n__unknown;
 
84
static PyObject *__pyx_n_unknown;
 
85
static PyObject *__pyx_n_ord;
 
86
static PyObject *__pyx_n_dot;
 
87
 
 
88
static PyObject *__pyx_k11p;
 
89
 
 
90
static PyObject *__pyx_n_OSError;
 
91
static PyObject *__pyx_n_append;
 
92
 
 
93
 
 
94
static PyObject *__pyx_f_7readdir_read_dir(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
 
95
static char __pyx_doc_7readdir_read_dir[] = "Like os.listdir, this reads a directories contents.\n\n    :param path: the directory to list.\n    :return: a list of (basename, kind) tuples.\n    ";
 
96
static PyObject *__pyx_f_7readdir_read_dir(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
 
97
  PyObject *__pyx_v_path = 0;
 
98
  DIR *__pyx_v_the_dir;
 
99
  dirent *__pyx_v_entry;
 
100
  dirent __pyx_v_sentinel;
 
101
  char *__pyx_v_name;
 
102
  PyObject *__pyx_v_result;
 
103
  PyObject *__pyx_v_type;
 
104
  PyObject *__pyx_r;
 
105
  char *__pyx_1;
 
106
  int __pyx_2;
 
107
  PyObject *__pyx_3 = 0;
 
108
  PyObject *__pyx_4 = 0;
 
109
  PyObject *__pyx_5 = 0;
 
110
  PyObject *__pyx_6 = 0;
 
111
  int __pyx_7;
 
112
  static char *__pyx_argnames[] = {"path",0};
 
113
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_path)) return 0;
 
114
  Py_INCREF(__pyx_v_path);
 
115
  __pyx_v_result = Py_None; Py_INCREF(Py_None);
 
116
  __pyx_v_type = Py_None; Py_INCREF(Py_None);
 
117
 
 
118
  /* "/home/robertc/source/baz/readdir/bzrlib/readdir.pyx":82 */
 
119
  __pyx_1 = PyString_AsString(__pyx_v_path); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; goto __pyx_L1;}
 
120
  __pyx_v_the_dir = opendir(__pyx_1);
 
121
 
 
122
  /* "/home/robertc/source/baz/readdir/bzrlib/readdir.pyx":83 */
 
123
  __pyx_2 = (NULL == __pyx_v_the_dir);
 
124
  if (__pyx_2) {
 
125
    __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_OSError); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; goto __pyx_L1;}
 
126
    __pyx_4 = PyInt_FromLong(errno); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; goto __pyx_L1;}
 
127
    __pyx_5 = PyString_FromString(strerror(errno)); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; goto __pyx_L1;}
 
128
    __pyx_6 = PyTuple_New(2); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; goto __pyx_L1;}
 
129
    PyTuple_SET_ITEM(__pyx_6, 0, __pyx_4);
 
130
    PyTuple_SET_ITEM(__pyx_6, 1, __pyx_5);
 
131
    __pyx_4 = 0;
 
132
    __pyx_5 = 0;
 
133
    __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_6); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; goto __pyx_L1;}
 
134
    Py_DECREF(__pyx_3); __pyx_3 = 0;
 
135
    Py_DECREF(__pyx_6); __pyx_6 = 0;
 
136
    __Pyx_Raise(__pyx_4, 0, 0);
 
137
    Py_DECREF(__pyx_4); __pyx_4 = 0;
 
138
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; goto __pyx_L1;}
 
139
    goto __pyx_L2;
 
140
  }
 
141
  __pyx_L2:;
 
142
 
 
143
  /* "/home/robertc/source/baz/readdir/bzrlib/readdir.pyx":85 */
 
144
  __pyx_5 = PyList_New(0); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; goto __pyx_L1;}
 
145
  Py_DECREF(__pyx_v_result);
 
146
  __pyx_v_result = __pyx_5;
 
147
  __pyx_5 = 0;
 
148
 
 
149
  /* "/home/robertc/source/baz/readdir/bzrlib/readdir.pyx":86 */
 
150
  /*try:*/ {
 
151
 
 
152
    /* "/home/robertc/source/baz/readdir/bzrlib/readdir.pyx":87 */
 
153
    __pyx_v_entry = (&__pyx_v_sentinel);
 
154
 
 
155
    /* "/home/robertc/source/baz/readdir/bzrlib/readdir.pyx":88 */
 
156
    while (1) {
 
157
      __pyx_2 = (__pyx_v_entry != NULL);
 
158
      if (!__pyx_2) break;
 
159
 
 
160
      /* "/home/robertc/source/baz/readdir/bzrlib/readdir.pyx":89 */
 
161
      __pyx_v_entry = readdir(__pyx_v_the_dir);
 
162
 
 
163
      /* "/home/robertc/source/baz/readdir/bzrlib/readdir.pyx":90 */
 
164
      __pyx_2 = (__pyx_v_entry == NULL);
 
165
      if (__pyx_2) {
 
166
        __pyx_2 = (errno == EAGAIN);
 
167
        if (__pyx_2) {
 
168
          goto __pyx_L6;
 
169
          goto __pyx_L9;
 
170
        }
 
171
        __pyx_2 = (errno != ENOTDIR);
 
172
        if (__pyx_2) {
 
173
          __pyx_2 = (errno != ENOENT);
 
174
          if (__pyx_2) {
 
175
            __pyx_2 = (errno != 0);
 
176
          }
 
177
        }
 
178
        if (__pyx_2) {
 
179
          __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_OSError); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; goto __pyx_L4;}
 
180
          __pyx_6 = PyInt_FromLong(errno); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; goto __pyx_L4;}
 
181
          __pyx_4 = PyString_FromString(strerror(errno)); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; goto __pyx_L4;}
 
182
          __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; goto __pyx_L4;}
 
183
          PyTuple_SET_ITEM(__pyx_5, 0, __pyx_6);
 
184
          PyTuple_SET_ITEM(__pyx_5, 1, __pyx_4);
 
185
          __pyx_6 = 0;
 
186
          __pyx_4 = 0;
 
187
          __pyx_6 = PyObject_CallObject(__pyx_3, __pyx_5); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; goto __pyx_L4;}
 
188
          Py_DECREF(__pyx_3); __pyx_3 = 0;
 
189
          Py_DECREF(__pyx_5); __pyx_5 = 0;
 
190
          __Pyx_Raise(__pyx_6, 0, 0);
 
191
          Py_DECREF(__pyx_6); __pyx_6 = 0;
 
192
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; goto __pyx_L4;}
 
193
          goto __pyx_L9;
 
194
        }
 
195
        /*else*/ {
 
196
          goto __pyx_L6;
 
197
        }
 
198
        __pyx_L9:;
 
199
        goto __pyx_L8;
 
200
      }
 
201
      __pyx_L8:;
 
202
 
 
203
      /* "/home/robertc/source/baz/readdir/bzrlib/readdir.pyx":104 */
 
204
      __pyx_v_name = __pyx_v_entry->d_name;
 
205
 
 
206
      /* "/home/robertc/source/baz/readdir/bzrlib/readdir.pyx":105 */
 
207
      __pyx_4 = PyInt_FromLong((__pyx_v_name[0])); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; goto __pyx_L4;}
 
208
      __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_dot); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; goto __pyx_L4;}
 
209
      if (PyObject_Cmp(__pyx_4, __pyx_3, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; goto __pyx_L4;}
 
210
      __pyx_2 = __pyx_2 == 0;
 
211
      Py_DECREF(__pyx_4); __pyx_4 = 0;
 
212
      Py_DECREF(__pyx_3); __pyx_3 = 0;
 
213
      if (__pyx_2) {
 
214
        __pyx_2 = ((__pyx_v_name[1]) == 0);
 
215
        if (!__pyx_2) {
 
216
          __pyx_5 = PyInt_FromLong((__pyx_v_name[1])); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; goto __pyx_L4;}
 
217
          __pyx_6 = __Pyx_GetName(__pyx_m, __pyx_n_dot); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; goto __pyx_L4;}
 
218
          if (PyObject_Cmp(__pyx_5, __pyx_6, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; goto __pyx_L4;}
 
219
          __pyx_2 = __pyx_2 == 0;
 
220
          Py_DECREF(__pyx_5); __pyx_5 = 0;
 
221
          Py_DECREF(__pyx_6); __pyx_6 = 0;
 
222
          if (__pyx_2) {
 
223
            __pyx_2 = ((__pyx_v_name[2]) == 0);
 
224
          }
 
225
        }
 
226
      }
 
227
      __pyx_7 = (!__pyx_2);
 
228
      if (__pyx_7) {
 
229
 
 
230
        /* "/home/robertc/source/baz/readdir/bzrlib/readdir.pyx":109 */
 
231
        __pyx_2 = (__pyx_v_entry->d_type == DT_UNKNOWN);
 
232
        if (__pyx_2) {
 
233
          __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n__unknown); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; goto __pyx_L4;}
 
234
          Py_DECREF(__pyx_v_type);
 
235
          __pyx_v_type = __pyx_4;
 
236
          __pyx_4 = 0;
 
237
          goto __pyx_L11;
 
238
        }
 
239
        __pyx_7 = (__pyx_v_entry->d_type == DT_REG);
 
240
        if (__pyx_7) {
 
241
          __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__file); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; goto __pyx_L4;}
 
242
          Py_DECREF(__pyx_v_type);
 
243
          __pyx_v_type = __pyx_3;
 
244
          __pyx_3 = 0;
 
245
          goto __pyx_L11;
 
246
        }
 
247
        __pyx_2 = (__pyx_v_entry->d_type == DT_DIR);
 
248
        if (__pyx_2) {
 
249
          __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n__directory); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; goto __pyx_L4;}
 
250
          Py_DECREF(__pyx_v_type);
 
251
          __pyx_v_type = __pyx_5;
 
252
          __pyx_5 = 0;
 
253
          goto __pyx_L11;
 
254
        }
 
255
        __pyx_7 = (__pyx_v_entry->d_type == DT_FIFO);
 
256
        if (__pyx_7) {
 
257
          __pyx_6 = __Pyx_GetName(__pyx_m, __pyx_n__fifo); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; goto __pyx_L4;}
 
258
          Py_DECREF(__pyx_v_type);
 
259
          __pyx_v_type = __pyx_6;
 
260
          __pyx_6 = 0;
 
261
          goto __pyx_L11;
 
262
        }
 
263
        __pyx_2 = (__pyx_v_entry->d_type == DT_SOCK);
 
264
        if (__pyx_2) {
 
265
          __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n__socket); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; goto __pyx_L4;}
 
266
          Py_DECREF(__pyx_v_type);
 
267
          __pyx_v_type = __pyx_4;
 
268
          __pyx_4 = 0;
 
269
          goto __pyx_L11;
 
270
        }
 
271
        __pyx_7 = (__pyx_v_entry->d_type == DT_CHR);
 
272
        if (__pyx_7) {
 
273
          __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__chardev); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; goto __pyx_L4;}
 
274
          Py_DECREF(__pyx_v_type);
 
275
          __pyx_v_type = __pyx_3;
 
276
          __pyx_3 = 0;
 
277
          goto __pyx_L11;
 
278
        }
 
279
        __pyx_2 = (__pyx_v_entry->d_type == DT_BLK);
 
280
        if (__pyx_2) {
 
281
          __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n__block); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; goto __pyx_L4;}
 
282
          Py_DECREF(__pyx_v_type);
 
283
          __pyx_v_type = __pyx_5;
 
284
          __pyx_5 = 0;
 
285
          goto __pyx_L11;
 
286
        }
 
287
        /*else*/ {
 
288
          __pyx_6 = __Pyx_GetName(__pyx_m, __pyx_n__unknown); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; goto __pyx_L4;}
 
289
          Py_DECREF(__pyx_v_type);
 
290
          __pyx_v_type = __pyx_6;
 
291
          __pyx_6 = 0;
 
292
        }
 
293
        __pyx_L11:;
 
294
 
 
295
        /* "/home/robertc/source/baz/readdir/bzrlib/readdir.pyx":126 */
 
296
        __pyx_4 = PyObject_GetAttr(__pyx_v_result, __pyx_n_append); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; goto __pyx_L4;}
 
297
        __pyx_3 = PyString_FromString(__pyx_v_entry->d_name); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; goto __pyx_L4;}
 
298
        __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; goto __pyx_L4;}
 
299
        PyTuple_SET_ITEM(__pyx_5, 0, __pyx_3);
 
300
        Py_INCREF(__pyx_n_unknown);
 
301
        PyTuple_SET_ITEM(__pyx_5, 1, __pyx_n_unknown);
 
302
        __pyx_3 = 0;
 
303
        __pyx_6 = PyTuple_New(1); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; goto __pyx_L4;}
 
304
        PyTuple_SET_ITEM(__pyx_6, 0, __pyx_5);
 
305
        __pyx_5 = 0;
 
306
        __pyx_3 = PyObject_CallObject(__pyx_4, __pyx_6); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; goto __pyx_L4;}
 
307
        Py_DECREF(__pyx_4); __pyx_4 = 0;
 
308
        Py_DECREF(__pyx_6); __pyx_6 = 0;
 
309
        Py_DECREF(__pyx_3); __pyx_3 = 0;
 
310
        goto __pyx_L10;
 
311
      }
 
312
      __pyx_L10:;
 
313
      __pyx_L6:;
 
314
    }
 
315
  }
 
316
  /*finally:*/ {
 
317
    int __pyx_why;
 
318
    PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
 
319
    int __pyx_exc_lineno;
 
320
    __pyx_why = 0; goto __pyx_L5;
 
321
    __pyx_L4: {
 
322
      __pyx_why = 4;
 
323
      Py_XDECREF(__pyx_5); __pyx_5 = 0;
 
324
      Py_XDECREF(__pyx_4); __pyx_4 = 0;
 
325
      Py_XDECREF(__pyx_6); __pyx_6 = 0;
 
326
      Py_XDECREF(__pyx_3); __pyx_3 = 0;
 
327
      PyErr_Fetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
 
328
      __pyx_exc_lineno = __pyx_lineno;
 
329
      goto __pyx_L5;
 
330
    }
 
331
    __pyx_L5:;
 
332
    __pyx_7 = ((-1) == closedir(__pyx_v_the_dir));
 
333
    if (__pyx_7) {
 
334
      __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_OSError); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; goto __pyx_L12;}
 
335
      __pyx_4 = PyInt_FromLong(errno); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; goto __pyx_L12;}
 
336
      __pyx_6 = PyString_FromString(strerror(errno)); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; goto __pyx_L12;}
 
337
      __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; goto __pyx_L12;}
 
338
      PyTuple_SET_ITEM(__pyx_3, 0, __pyx_4);
 
339
      PyTuple_SET_ITEM(__pyx_3, 1, __pyx_6);
 
340
      __pyx_4 = 0;
 
341
      __pyx_6 = 0;
 
342
      __pyx_4 = PyObject_CallObject(__pyx_5, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; goto __pyx_L12;}
 
343
      Py_DECREF(__pyx_5); __pyx_5 = 0;
 
344
      Py_DECREF(__pyx_3); __pyx_3 = 0;
 
345
      __Pyx_Raise(__pyx_4, 0, 0);
 
346
      Py_DECREF(__pyx_4); __pyx_4 = 0;
 
347
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; goto __pyx_L12;}
 
348
      goto __pyx_L13;
 
349
    }
 
350
    __pyx_L13:;
 
351
    goto __pyx_L14;
 
352
    __pyx_L12:;
 
353
    if (__pyx_why == 4) {
 
354
      Py_XDECREF(__pyx_exc_type);
 
355
      Py_XDECREF(__pyx_exc_value);
 
356
      Py_XDECREF(__pyx_exc_tb);
 
357
    }
 
358
    goto __pyx_L1;
 
359
    __pyx_L14:;
 
360
    switch (__pyx_why) {
 
361
      case 4: {
 
362
        PyErr_Restore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb);
 
363
        __pyx_lineno = __pyx_exc_lineno;
 
364
        __pyx_exc_type = 0;
 
365
        __pyx_exc_value = 0;
 
366
        __pyx_exc_tb = 0;
 
367
        goto __pyx_L1;
 
368
      }
 
369
    }
 
370
  }
 
371
 
 
372
  /* "/home/robertc/source/baz/readdir/bzrlib/readdir.pyx":130 */
 
373
  Py_INCREF(__pyx_v_result);
 
374
  __pyx_r = __pyx_v_result;
 
375
  goto __pyx_L0;
 
376
 
 
377
  __pyx_r = Py_None; Py_INCREF(Py_None);
 
378
  goto __pyx_L0;
 
379
  __pyx_L1:;
 
380
  Py_XDECREF(__pyx_3);
 
381
  Py_XDECREF(__pyx_4);
 
382
  Py_XDECREF(__pyx_5);
 
383
  Py_XDECREF(__pyx_6);
 
384
  __Pyx_AddTraceback("readdir.read_dir");
 
385
  __pyx_r = 0;
 
386
  __pyx_L0:;
 
387
  Py_DECREF(__pyx_v_result);
 
388
  Py_DECREF(__pyx_v_type);
 
389
  Py_DECREF(__pyx_v_path);
 
390
  return __pyx_r;
 
391
}
 
392
 
 
393
static __Pyx_InternTabEntry __pyx_intern_tab[] = {
 
394
  {&__pyx_n_OSError, "OSError"},
 
395
  {&__pyx_n__block, "_block"},
 
396
  {&__pyx_n__chardev, "_chardev"},
 
397
  {&__pyx_n__directory, "_directory"},
 
398
  {&__pyx_n__fifo, "_fifo"},
 
399
  {&__pyx_n__file, "_file"},
 
400
  {&__pyx_n__socket, "_socket"},
 
401
  {&__pyx_n__symlink, "_symlink"},
 
402
  {&__pyx_n__unknown, "_unknown"},
 
403
  {&__pyx_n_append, "append"},
 
404
  {&__pyx_n_block, "block"},
 
405
  {&__pyx_n_chardev, "chardev"},
 
406
  {&__pyx_n_directory, "directory"},
 
407
  {&__pyx_n_dot, "dot"},
 
408
  {&__pyx_n_fifo, "fifo"},
 
409
  {&__pyx_n_file, "file"},
 
410
  {&__pyx_n_ord, "ord"},
 
411
  {&__pyx_n_os, "os"},
 
412
  {&__pyx_n_socket, "socket"},
 
413
  {&__pyx_n_symlink, "symlink"},
 
414
  {&__pyx_n_sys, "sys"},
 
415
  {&__pyx_n_unknown, "unknown"},
 
416
  {0, 0}
 
417
};
 
418
 
 
419
static __Pyx_StringTabEntry __pyx_string_tab[] = {
 
420
  {&__pyx_k11p, __pyx_k11, sizeof(__pyx_k11)},
 
421
  {0, 0, 0}
 
422
};
 
423
 
 
424
static struct PyMethodDef __pyx_methods[] = {
 
425
  {"read_dir", (PyCFunction)__pyx_f_7readdir_read_dir, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7readdir_read_dir},
 
426
  {0, 0, 0, 0}
 
427
};
 
428
 
 
429
static void __pyx_init_filenames(void); /*proto*/
 
430
 
 
431
PyMODINIT_FUNC initreaddir(void); /*proto*/
 
432
PyMODINIT_FUNC initreaddir(void) {
 
433
  PyObject *__pyx_1 = 0;
 
434
  PyObject *__pyx_2 = 0;
 
435
  PyObject *__pyx_3 = 0;
 
436
  __pyx_init_filenames();
 
437
  __pyx_m = Py_InitModule4("readdir", __pyx_methods, __pyx_mdoc, 0, PYTHON_API_VERSION);
 
438
  if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; goto __pyx_L1;};
 
439
  Py_INCREF(__pyx_m);
 
440
  __pyx_b = PyImport_AddModule("__builtin__");
 
441
  if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; goto __pyx_L1;};
 
442
  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; goto __pyx_L1;};
 
443
  if (__Pyx_InternStrings(__pyx_intern_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; goto __pyx_L1;};
 
444
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; goto __pyx_L1;};
 
445
 
 
446
  /* "/home/robertc/source/baz/readdir/bzrlib/readdir.pyx":20 */
 
447
  __pyx_1 = __Pyx_Import(__pyx_n_os, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; goto __pyx_L1;}
 
448
  if (PyObject_SetAttr(__pyx_m, __pyx_n_os, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; goto __pyx_L1;}
 
449
  Py_DECREF(__pyx_1); __pyx_1 = 0;
 
450
 
 
451
  /* "/home/robertc/source/baz/readdir/bzrlib/readdir.pyx":21 */
 
452
  __pyx_1 = __Pyx_Import(__pyx_n_sys, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; goto __pyx_L1;}
 
453
  if (PyObject_SetAttr(__pyx_m, __pyx_n_sys, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; goto __pyx_L1;}
 
454
  Py_DECREF(__pyx_1); __pyx_1 = 0;
 
455
 
 
456
  /* "/home/robertc/source/baz/readdir/bzrlib/readdir.pyx":55 */
 
457
  if (PyObject_SetAttr(__pyx_m, __pyx_n__directory, __pyx_n_directory) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; goto __pyx_L1;}
 
458
 
 
459
  /* "/home/robertc/source/baz/readdir/bzrlib/readdir.pyx":56 */
 
460
  if (PyObject_SetAttr(__pyx_m, __pyx_n__chardev, __pyx_n_chardev) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; goto __pyx_L1;}
 
461
 
 
462
  /* "/home/robertc/source/baz/readdir/bzrlib/readdir.pyx":57 */
 
463
  if (PyObject_SetAttr(__pyx_m, __pyx_n__block, __pyx_n_block) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; goto __pyx_L1;}
 
464
 
 
465
  /* "/home/robertc/source/baz/readdir/bzrlib/readdir.pyx":58 */
 
466
  if (PyObject_SetAttr(__pyx_m, __pyx_n__file, __pyx_n_file) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; goto __pyx_L1;}
 
467
 
 
468
  /* "/home/robertc/source/baz/readdir/bzrlib/readdir.pyx":59 */
 
469
  if (PyObject_SetAttr(__pyx_m, __pyx_n__fifo, __pyx_n_fifo) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; goto __pyx_L1;}
 
470
 
 
471
  /* "/home/robertc/source/baz/readdir/bzrlib/readdir.pyx":60 */
 
472
  if (PyObject_SetAttr(__pyx_m, __pyx_n__symlink, __pyx_n_symlink) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; goto __pyx_L1;}
 
473
 
 
474
  /* "/home/robertc/source/baz/readdir/bzrlib/readdir.pyx":61 */
 
475
  if (PyObject_SetAttr(__pyx_m, __pyx_n__socket, __pyx_n_socket) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; goto __pyx_L1;}
 
476
 
 
477
  /* "/home/robertc/source/baz/readdir/bzrlib/readdir.pyx":62 */
 
478
  if (PyObject_SetAttr(__pyx_m, __pyx_n__unknown, __pyx_n_unknown) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; goto __pyx_L1;}
 
479
 
 
480
  /* "/home/robertc/source/baz/readdir/bzrlib/readdir.pyx":64 */
 
481
  __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ord); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; goto __pyx_L1;}
 
482
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; goto __pyx_L1;}
 
483
  Py_INCREF(__pyx_k11p);
 
484
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k11p);
 
485
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; goto __pyx_L1;}
 
486
  Py_DECREF(__pyx_1); __pyx_1 = 0;
 
487
  Py_DECREF(__pyx_2); __pyx_2 = 0;
 
488
  if (PyObject_SetAttr(__pyx_m, __pyx_n_dot, __pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; goto __pyx_L1;}
 
489
  Py_DECREF(__pyx_3); __pyx_3 = 0;
 
490
 
 
491
  /* "/home/robertc/source/baz/readdir/bzrlib/readdir.pyx":70 */
 
492
  return;
 
493
  __pyx_L1:;
 
494
  Py_XDECREF(__pyx_1);
 
495
  Py_XDECREF(__pyx_2);
 
496
  Py_XDECREF(__pyx_3);
 
497
  __Pyx_AddTraceback("readdir");
 
498
}
 
499
 
 
500
static char *__pyx_filenames[] = {
 
501
  "readdir.pyx",
 
502
};
 
503
 
 
504
/* Runtime support code */
 
505
 
 
506
static void __pyx_init_filenames(void) {
 
507
  __pyx_f = __pyx_filenames;
 
508
}
 
509
 
 
510
static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list) {
 
511
    PyObject *__import__ = 0;
 
512
    PyObject *empty_list = 0;
 
513
    PyObject *module = 0;
 
514
    PyObject *global_dict = 0;
 
515
    PyObject *empty_dict = 0;
 
516
    PyObject *list;
 
517
    __import__ = PyObject_GetAttrString(__pyx_b, "__import__");
 
518
    if (!__import__)
 
519
        goto bad;
 
520
    if (from_list)
 
521
        list = from_list;
 
522
    else {
 
523
        empty_list = PyList_New(0);
 
524
        if (!empty_list)
 
525
            goto bad;
 
526
        list = empty_list;
 
527
    }
 
528
    global_dict = PyModule_GetDict(__pyx_m);
 
529
    if (!global_dict)
 
530
        goto bad;
 
531
    empty_dict = PyDict_New();
 
532
    if (!empty_dict)
 
533
        goto bad;
 
534
    module = PyObject_CallFunction(__import__, "OOOO",
 
535
        name, global_dict, empty_dict, list);
 
536
bad:
 
537
    Py_XDECREF(empty_list);
 
538
    Py_XDECREF(__import__);
 
539
    Py_XDECREF(empty_dict);
 
540
    return module;
 
541
}
 
542
 
 
543
static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {
 
544
    PyObject *result;
 
545
    result = PyObject_GetAttr(dict, name);
 
546
    if (!result)
 
547
        PyErr_SetObject(PyExc_NameError, name);
 
548
    return result;
 
549
}
 
550
 
 
551
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
 
552
    Py_XINCREF(type);
 
553
    Py_XINCREF(value);
 
554
    Py_XINCREF(tb);
 
555
    /* First, check the traceback argument, replacing None with NULL. */
 
556
    if (tb == Py_None) {
 
557
        Py_DECREF(tb);
 
558
        tb = 0;
 
559
    }
 
560
    else if (tb != NULL && !PyTraceBack_Check(tb)) {
 
561
        PyErr_SetString(PyExc_TypeError,
 
562
            "raise: arg 3 must be a traceback or None");
 
563
        goto raise_error;
 
564
    }
 
565
    /* Next, replace a missing value with None */
 
566
    if (value == NULL) {
 
567
        value = Py_None;
 
568
        Py_INCREF(value);
 
569
    }
 
570
    #if PY_VERSION_HEX < 0x02050000
 
571
    if (!PyClass_Check(type))
 
572
    #else
 
573
    if (!PyType_Check(type))
 
574
    #endif
 
575
    {
 
576
        /* Raising an instance.  The value should be a dummy. */
 
577
        if (value != Py_None) {
 
578
            PyErr_SetString(PyExc_TypeError,
 
579
                "instance exception may not have a separate value");
 
580
            goto raise_error;
 
581
        }
 
582
        /* Normalize to raise <class>, <instance> */
 
583
        Py_DECREF(value);
 
584
        value = type;
 
585
        #if PY_VERSION_HEX < 0x02050000
 
586
            if (PyInstance_Check(type)) {
 
587
                type = (PyObject*) ((PyInstanceObject*)type)->in_class;
 
588
                Py_INCREF(type);
 
589
            }
 
590
            else {
 
591
                PyErr_SetString(PyExc_TypeError,
 
592
                    "raise: exception must be an old-style class or instance");
 
593
                goto raise_error;
 
594
            }
 
595
        #else
 
596
            type = (PyObject*) type->ob_type;
 
597
            Py_INCREF(type);
 
598
            if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
 
599
                PyErr_SetString(PyExc_TypeError,
 
600
                    "raise: exception class must be a subclass of BaseException");
 
601
                goto raise_error;
 
602
            }
 
603
        #endif
 
604
    }
 
605
    PyErr_Restore(type, value, tb);
 
606
    return;
 
607
raise_error:
 
608
    Py_XDECREF(value);
 
609
    Py_XDECREF(type);
 
610
    Py_XDECREF(tb);
 
611
    return;
 
612
}
 
613
 
 
614
static int __Pyx_InternStrings(__Pyx_InternTabEntry *t) {
 
615
    while (t->p) {
 
616
        *t->p = PyString_InternFromString(t->s);
 
617
        if (!*t->p)
 
618
            return -1;
 
619
        ++t;
 
620
    }
 
621
    return 0;
 
622
}
 
623
 
 
624
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
 
625
    while (t->p) {
 
626
        *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
 
627
        if (!*t->p)
 
628
            return -1;
 
629
        ++t;
 
630
    }
 
631
    return 0;
 
632
}
 
633
 
 
634
#include "compile.h"
 
635
#include "frameobject.h"
 
636
#include "traceback.h"
 
637
 
 
638
static void __Pyx_AddTraceback(char *funcname) {
 
639
    PyObject *py_srcfile = 0;
 
640
    PyObject *py_funcname = 0;
 
641
    PyObject *py_globals = 0;
 
642
    PyObject *empty_tuple = 0;
 
643
    PyObject *empty_string = 0;
 
644
    PyCodeObject *py_code = 0;
 
645
    PyFrameObject *py_frame = 0;
 
646
    
 
647
    py_srcfile = PyString_FromString(__pyx_filename);
 
648
    if (!py_srcfile) goto bad;
 
649
    py_funcname = PyString_FromString(funcname);
 
650
    if (!py_funcname) goto bad;
 
651
    py_globals = PyModule_GetDict(__pyx_m);
 
652
    if (!py_globals) goto bad;
 
653
    empty_tuple = PyTuple_New(0);
 
654
    if (!empty_tuple) goto bad;
 
655
    empty_string = PyString_FromString("");
 
656
    if (!empty_string) goto bad;
 
657
    py_code = PyCode_New(
 
658
        0,            /*int argcount,*/
 
659
        0,            /*int nlocals,*/
 
660
        0,            /*int stacksize,*/
 
661
        0,            /*int flags,*/
 
662
        empty_string, /*PyObject *code,*/
 
663
        empty_tuple,  /*PyObject *consts,*/
 
664
        empty_tuple,  /*PyObject *names,*/
 
665
        empty_tuple,  /*PyObject *varnames,*/
 
666
        empty_tuple,  /*PyObject *freevars,*/
 
667
        empty_tuple,  /*PyObject *cellvars,*/
 
668
        py_srcfile,   /*PyObject *filename,*/
 
669
        py_funcname,  /*PyObject *name,*/
 
670
        __pyx_lineno,   /*int firstlineno,*/
 
671
        empty_string  /*PyObject *lnotab*/
 
672
    );
 
673
    if (!py_code) goto bad;
 
674
    py_frame = PyFrame_New(
 
675
        PyThreadState_Get(), /*PyThreadState *tstate,*/
 
676
        py_code,             /*PyCodeObject *code,*/
 
677
        py_globals,          /*PyObject *globals,*/
 
678
        0                    /*PyObject *locals*/
 
679
    );
 
680
    if (!py_frame) goto bad;
 
681
    py_frame->f_lineno = __pyx_lineno;
 
682
    PyTraceBack_Here(py_frame);
 
683
bad:
 
684
    Py_XDECREF(py_srcfile);
 
685
    Py_XDECREF(py_funcname);
 
686
    Py_XDECREF(empty_tuple);
 
687
    Py_XDECREF(empty_string);
 
688
    Py_XDECREF(py_code);
 
689
    Py_XDECREF(py_frame);
 
690
}