add ignore_hidden_files and fix '.' and './' will cause problems in path/name

This commit is contained in:
2021-09-08 22:14:14 +08:00
parent 0dc05ef23b
commit 40b73ee929
3 changed files with 68 additions and 10 deletions

View File

@@ -21,12 +21,13 @@ def copy_file(loc: str, dest: str, name: str, prog: str):
print(f'{prog}: Copyed {loc}({name}) -> {r}')
def listdirs(loc: str):
def listdirs(loc: str, ignore_hidden_files: bool = True):
bl = listdir(loc)
r = []
for i in bl:
if i.startswith('.'):
continue
if ignore_hidden_files or i == '.' or i == '..':
continue
p = join(loc, i)
if isfile(p):
r.append(p)