mirror of
https://github.com/SteamDeckHomebrew/decky-loader.git
synced 2026-07-11 21:11:58 +00:00
Implement feedback for filepicker optimalisations
This commit is contained in:
+12
-12
@@ -188,23 +188,23 @@ class Utilities:
|
|||||||
# return 0
|
# return 0
|
||||||
# file_names = sorted(os.listdir(path), key=sorter, reverse=True) # TODO provide more sort options
|
# file_names = sorted(os.listdir(path), key=sorter, reverse=True) # TODO provide more sort options
|
||||||
|
|
||||||
items = list(os.scandir(path))
|
realpath = os.path.realpath(path)
|
||||||
files = sorted([x for x in items if x.is_file()], key=lambda x: x.name)
|
files, folders = [], []
|
||||||
folders = sorted([x for x in items if x.is_dir()], key=lambda x: x.name)
|
|
||||||
|
|
||||||
def to_dict(entry : os.DirEntry[str], is_dir : bool):
|
for x in os.scandir(realpath):
|
||||||
return {
|
if x.is_dir():
|
||||||
"isdir": is_dir,
|
folders.append(x)
|
||||||
"name": entry.name,
|
elif include_files:
|
||||||
"realpath": os.path.realpath(entry.path)
|
files.append(x)
|
||||||
}
|
|
||||||
|
|
||||||
all = [to_dict(x, True) for x in folders] + ([to_dict(x, False) for x in files] if include_files else [])
|
files = sorted(files, key=lambda x: x.name)
|
||||||
|
folders = sorted(folders, key=lambda x: x.name)
|
||||||
|
all = [{ "isdir": x.is_dir(), "name": x.name, "realpath": x.path } for x in folders + files]
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"realpath": os.path.realpath(path),
|
"realpath": realpath,
|
||||||
"files": all[(page-1)*max:(page)*max],
|
"files": all[(page-1)*max:(page)*max],
|
||||||
"total": len(items)
|
"total": len(all)
|
||||||
}
|
}
|
||||||
|
|
||||||
# Based on https://stackoverflow.com/a/46422554/13174603
|
# Based on https://stackoverflow.com/a/46422554/13174603
|
||||||
|
|||||||
Reference in New Issue
Block a user