Show More
@@ -1,13 +1,14 b'' | |||||
1 |
import os |
|
1 | import os | |
|
2 | import stat as _stat | |||
2 |
|
3 | |||
3 | def _mode_to_kind(mode): |
|
4 | def _mode_to_kind(mode): | |
4 | if stat.S_ISREG(mode): return stat.S_IFREG |
|
5 | if _stat.S_ISREG(mode): return _stat.S_IFREG | |
5 | if stat.S_ISDIR(mode): return stat.S_IFDIR |
|
6 | if _stat.S_ISDIR(mode): return _stat.S_IFDIR | |
6 | if stat.S_ISLNK(mode): return stat.S_IFLNK |
|
7 | if _stat.S_ISLNK(mode): return _stat.S_IFLNK | |
7 | if stat.S_ISBLK(mode): return stat.S_IFBLK |
|
8 | if _stat.S_ISBLK(mode): return _stat.S_IFBLK | |
8 | if stat.S_ISCHR(mode): return stat.S_IFCHR |
|
9 | if _stat.S_ISCHR(mode): return _stat.S_IFCHR | |
9 | if stat.S_ISFIFO(mode): return stat.S_IFIFO |
|
10 | if _stat.S_ISFIFO(mode): return _stat.S_IFIFO | |
10 | if stat.S_ISSOCK(mode): return stat.S_IFSOCK |
|
11 | if _stat.S_ISSOCK(mode): return _stat.S_IFSOCK | |
11 | return mode |
|
12 | return mode | |
12 |
|
13 | |||
13 | def listdir(path, stat=False, skip=None): |
|
14 | def listdir(path, stat=False, skip=None): | |
@@ -30,7 +31,7 b' def listdir(path, stat=False, skip=None)' | |||||
30 | names.sort() |
|
31 | names.sort() | |
31 | for fn in names: |
|
32 | for fn in names: | |
32 | st = os.lstat(prefix + fn) |
|
33 | st = os.lstat(prefix + fn) | |
33 | if fn == skip and stat.S_ISDIR(st.st_mode): |
|
34 | if fn == skip and _stat.S_ISDIR(st.st_mode): | |
34 | return [] |
|
35 | return [] | |
35 | if stat: |
|
36 | if stat: | |
36 | result.append((fn, _mode_to_kind(st.st_mode), st)) |
|
37 | result.append((fn, _mode_to_kind(st.st_mode), st)) |
General Comments 0
You need to be logged in to leave comments.
Login now