Skip to main content

Module platform

Module platform 

Source
Expand description

The OS-specific half of the Files pane’s filesystem layer: path display form, hidden attributes, a rename that never overwrites, a delete that never follows a link, and the commands that open or reveal a path.

Deliberately depends on nothing but std, libc and windows-sys, so every cfg arm can be checked on its own.

Spec: docs/specs/SPEC_FILE_BROWSER_PANE_2026_10_01.md §9.

Constants§

DBUS_REVEAL_LIMIT
How long the file manager gets to answer ShowItems before xdg-open is tried instead. A file manager that isn’t running is started by the bus, which can take a moment.

Functions§

create_symlink
Create a symlink at link pointing at target, of the same kind as the link being copied (like, its own file type). Windows has separate file and directory links; a junction is recreated as a directory link.
dbus_show_items_command
The dbus-send call that asks the desktop’s file manager to show path selected: the session bus’s org.freedesktop.FileManager1.ShowItems, which Nautilus, Dolphin, Nemo, Thunar and the other file managers that implement the interface answer. The empty string is the startup id.
display_path
path as the frontend should see it. On Windows, canonicalize returns verbatim paths (\\?\C:\…, \\?\UNC\host\share\…); those are turned back into their ordinary forms. Elsewhere the path is unchanged.
explorer_quote
explorer.exe’s argument for display. Windows paths can’t contain ", so quoting is unambiguous, and it keeps a path with spaces or commas in one piece. A trailing backslash would escape the closing quote, so it is trimmed; a drive root (C:\) has no spaces and goes unquoted.
file_uri
path as a file:// URI, percent-encoded byte by byte: only letters, digits, -, ., _, ~ and the / separators stay as they are, so a space, #, %, , or a non-ASCII character can’t change what the URI names (and dbus-send splits its array values at a ,).
has_hidden_attribute
Whether meta (the entry’s own metadata, not a link’s target) carries the hidden or system attribute. Always false off Windows, where hidden means only a leading dot.
is_os_blocked
Whether an access error is macOS’s privacy system (TCC) refusing, rather than ordinary permissions: TCC denials are EPERM, ordinary ones EACCES (spec §9.1.1 fact 2). Rust maps both to PermissionDenied, so the raw code decides.
is_symlink_privilege_error
Whether creating a symlink failed because Windows requires Developer Mode or elevation for it (ERROR_PRIVILEGE_NOT_HELD).
open_command
The command that opens path with the OS default application, for spawn_detached (which sanitizes its environment).
open_no_follow
Open path for reading, refusing a symlink where the OS can: a copy reads the file that was listed, never what a link swapped in since points at (spec §9: never follow a link when copying).
remove_entry_no_follow
Permanently remove the entry at path without following it: a symlink (or Windows junction) is unlinked and its target kept, a directory is removed with its contents, anything else is removed as a file.
remove_file_force
Remove the regular file at path. On Windows a read-only file refuses deletion, so the attribute is cleared first when that is the refusal: a moved file’s original and a discarded partial copy both have to go.
rename_no_replace
Rename from to to, failing with AlreadyExists instead of replacing an existing to.
reveal
Show path selected in the OS file manager, the one function every reveal goes through. Windows and macOS start their file manager detached (reveal_command). Linux asks the desktop’s file manager to select the file through D-Bus and, where that isn’t there, opens the containing folder (reveal_linux).
reveal_command
The command that shows path selected in the OS file manager. On Linux this is the fallback of reveal: xdg-open has no “select”, so it opens the containing folder.
reveal_linux
The Linux half of reveal, with its two steps passed in so each can be tested alone: dbus runs the ShowItems call and says whether it worked; when it didn’t (no dbus-send, no session bus, the call failed or timed out), fallback gets the xdg-open of the containing folder, which is what Linux did before the file could be selected. A folder is opened itself (its menu rows read “Open in File Manager”), by xdg-open and without the D-Bus call, which would show its parent with the folder selected.
spawn_detached
Spawn cmd detached from srv’s own stdio, and reap it on a thread.
strip_verbatim
The string half of display_path, separate so it can be tested on any platform. Only the drive and UNC forms are rewritten; any other verbatim path (\\?\Volume{…}\) has no ordinary spelling and is left alone.
trash_unavailable_reason
Why path can’t go to the Recycle Bin, if it can’t.