Show More
@@ -101,11 +101,21 b" def is_hidden(abs_path, abs_root=''):" | |||||
101 | inside_root = abs_path[len(abs_root):] |
|
101 | inside_root = abs_path[len(abs_root):] | |
102 | if any(part.startswith('.') for part in inside_root.split(os.sep)): |
|
102 | if any(part.startswith('.') for part in inside_root.split(os.sep)): | |
103 | return True |
|
103 | return True | |
|
104 | ||||
|
105 | # check that path can be listed | |||
|
106 | try: | |||
|
107 | os.listdir(abs_path) | |||
|
108 | except Exception: | |||
|
109 | return True | |||
104 |
|
110 | |||
105 | # check UF_HIDDEN on any location up to root |
|
111 | # check UF_HIDDEN on any location up to root | |
106 | path = abs_path |
|
112 | path = abs_path | |
107 | while path and path.startswith(abs_root) and path != abs_root: |
|
113 | while path and path.startswith(abs_root) and path != abs_root: | |
108 | st = os.stat(path) |
|
114 | try: | |
|
115 | # may fail on Windows junctions | |||
|
116 | st = os.stat(path) | |||
|
117 | except Exception: | |||
|
118 | return True | |||
109 | if getattr(st, 'st_flags', 0) & UF_HIDDEN: |
|
119 | if getattr(st, 'st_flags', 0) & UF_HIDDEN: | |
110 | return True |
|
120 | return True | |
111 | path = os.path.dirname(path) |
|
121 | path = os.path.dirname(path) |
General Comments 0
You need to be logged in to leave comments.
Login now