@@ -20,22 +20,20 @@ def scanfs(file) -> dict:
2020 print (f"[Warn] Current { line_num } : { filepath } there are too many schools ({ len (other )} )." )
2121 return filesystem_config
2222
23- def scan_dir (folder ) -> list :
24- allfiles = ['/' , '/lost+found' ]
25- if os .name == 'nt' :
26- yield os .path .basename (folder ).replace ('\\ ' , '' )
27- elif os .name == 'posix' :
28- yield os .path .basename (folder ).replace ('/' , '' )
29- else :
30- return ''
31- for root , dirs , files in os .walk (folder , topdown = True ):
32- for dir_ in dirs :
33- yield os .path .join (root , dir_ ).replace (folder , os .path .basename (folder )).replace ('\\ ' , '/' )
34- for file in files :
35- yield os .path .join (root , file ).replace (folder , os .path .basename (folder )).replace ('\\ ' , '/' )
36- for rv in allfiles :
37- yield rv
38-
23+ def scan_dir (folder ):
24+ base = os .path .basename (os .path .normpath (folder ))
25+ yield base
26+ yield '/'
27+ yield f'{ base } /lost+found'
28+ for root , dirs , files in os .walk (folder ):
29+ rel_root = os .path .relpath (root , folder )
30+ rel_root = '' if rel_root == '.' else rel_root
31+ for d in dirs :
32+ path = os .path .join (base , rel_root , d )
33+ yield path .replace ('\\ ' , '/' )
34+ for f in files :
35+ path = os .path .join (base , rel_root , f )
36+ yield path .replace ('\\ ' , '/' )
3937
4038def islink (file ) -> str and None :
4139 if os .name == 'nt' :
0 commit comments