mirror of
https://github.com/derrod/legendary.git
synced 2025-03-21 00:17:30 +00:00
Added scan_dir
function
This is a helper function for implementing a progress indication in the moving games between disks functionality
This commit is contained in:
parent
b30e274251
commit
8a95e635cd
|
@ -1,3 +1,5 @@
|
||||||
|
import os
|
||||||
|
|
||||||
def get_boolean_choice(prompt, default=True):
|
def get_boolean_choice(prompt, default=True):
|
||||||
yn = 'Y/n' if default else 'y/N'
|
yn = 'Y/n' if default else 'y/N'
|
||||||
|
|
||||||
|
@ -89,3 +91,15 @@ def strtobool(val):
|
||||||
else:
|
else:
|
||||||
raise ValueError("invalid truth value %r" % (val,))
|
raise ValueError("invalid truth value %r" % (val,))
|
||||||
|
|
||||||
|
def scan_dir(src):
|
||||||
|
files = 0
|
||||||
|
chunks = 0
|
||||||
|
for entry in os.scandir(src):
|
||||||
|
if entry.is_dir():
|
||||||
|
cnt, sz = scan_dir(entry.path)
|
||||||
|
files += cnt
|
||||||
|
chunks += sz
|
||||||
|
else:
|
||||||
|
files += 1
|
||||||
|
chunks += entry.stat().st_size
|
||||||
|
return files, chunks
|
||||||
|
|
Loading…
Reference in a new issue