mirror of
https://github.com/SteamDeckHomebrew/decky-loader.git
synced 2026-06-13 12:15:09 +03:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 82397cc5d1 | |||
| 75b43746a0 |
+14
-14
@@ -181,30 +181,30 @@ class Utilities:
|
||||
await service_stop(helpers.REMOTE_DEBUGGER_UNIT)
|
||||
return True
|
||||
|
||||
async def filepicker_ls(self, path, include_files=True):
|
||||
async def filepicker_ls(self, path, include_files : bool = True, max : int = 1000, page : int = 1):
|
||||
# def sorter(file): # Modification time
|
||||
# if os.path.isdir(os.path.join(path, file)) or os.path.isfile(os.path.join(path, file)):
|
||||
# return os.path.getmtime(os.path.join(path, file))
|
||||
# return 0
|
||||
# file_names = sorted(os.listdir(path), key=sorter, reverse=True) # TODO provide more sort options
|
||||
file_names = sorted(os.listdir(path)) # Alphabetical
|
||||
|
||||
files = []
|
||||
realpath = os.path.realpath(path)
|
||||
files, folders = [], []
|
||||
|
||||
for file in file_names:
|
||||
full_path = os.path.join(path, file)
|
||||
is_dir = os.path.isdir(full_path)
|
||||
for x in os.scandir(realpath):
|
||||
if x.is_dir():
|
||||
folders.append(x)
|
||||
elif include_files:
|
||||
files.append(x)
|
||||
|
||||
if is_dir or include_files:
|
||||
files.append({
|
||||
"isdir": is_dir,
|
||||
"name": file,
|
||||
"realpath": os.path.realpath(full_path)
|
||||
})
|
||||
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 {
|
||||
"realpath": os.path.realpath(path),
|
||||
"files": files
|
||||
"realpath": realpath,
|
||||
"files": all[(page-1)*max:(page)*max],
|
||||
"total": len(all)
|
||||
}
|
||||
|
||||
# Based on https://stackoverflow.com/a/46422554/13174603
|
||||
|
||||
Reference in New Issue
Block a user