What it does
fs_utils
Filesystem helpers for the desktop UI's virtual filesystem. Lists a
directory in DesktopConfig.VFS (or an override) and resolves the
display icon for a single entry. Stateless wrappers over the static
config tree.
Exports
M.listDirectory(path: string, vfs: VfsTree?) -> { VfsEntry }— return a new array of entries atpath, sorted directories-first then by name. Empty array if the path isn't present.M.resolveEntryIcon(entry: VfsEntry, config: DesktopConfigLike?) -> string— pick the best icon path for an entry: directicon_srcwins, otherwise the entry'sworld/app_idis looked up viafindShortcut, otherwise the default folder/file icon.
Types:
VfsEntry = { name, kind, icon_src?, content?, world?, app_id? }VfsTree = { [string]: { VfsEntry } }DesktopConfigLike = { VFS, ICON_FOLDER, ICON_FILE, findShortcut }
Usage
local FsUtils = require("@builtin::modules.fs_utils")
local entries = FsUtils.listDirectory("/apps")
for _, entry in ipairs(entries) do
local icon = FsUtils.resolveEntryIcon(entry)
print(entry.name, entry.kind, icon)
end
Notes
listDirectoryalways returns a fresh array (shallow copy of the config row) — callers can mutate the result without affecting the sharedDesktopConfig.VFS.- Sort order is stable:
direntries come before non-dir, then alphabetical byname. resolveEntryIconusesDesktopConfig.findShortcut(or the override), which is a linear scan — fine for the current ~9-entry shortcut list.
Discussion
Scoped to this part · feeds back into the world's score.
Sign in to post.sign in
No comments yet. Be the first.