Expand description
Files and URLs the app is asked to open: from the command line, from the file manager (a
double-click on a document of an associated type, a drop on the Dock icon) and from a second
launch forwarded by crate::single_instance. They all arrive in one queue, OpenFiles.
- Command line (every platform):
OpenFiles::push_argsat startup. - macOS: Finder sends
odoc(open documents) andGURL(open URL) Apple events, at launch and while running, instead of passing arguments.OpenFiles::listen_osinstalls handlers for them; call it on the main thread before the event loop starts, so the launch documents are not missed. It works alongside any windowing library: it uses the Apple event manager, not the application delegate. - Windows and Linux: the file manager starts the app with the files as arguments; a second
launch while one runs is forwarded with
crate::single_instance.
File associations themselves are declared when the app is packaged (CFBundleDocumentTypes
in Info.plist, registry ProgIDs, .desktop MimeType=), not at run time.
Structs§
- Open
Files - The queue of things to open.
- Open
Sender - A handle that queues into an
OpenFilesfrom any thread.
Enums§
- Opened
- Something to open.
Constants§
- MAX_
ITEMS - At most this many entries are taken from one launch or event.
- MAX_LEN
- Longest accepted argument or URL.
Functions§
- classify
- Classify one string: a URL (
file:URLs become paths) or a path resolved againstcwd. - file_
url_ to_ path - A
file:URL as a path (file:///Users/a/My%20Doc.txt). Only local (file:///orfile://localhost/) URLs. - from_
args - What to open from command-line arguments (without the program name): flags (
-x,--x, macOS’-psn_…) are skipped, everything after--is taken literally, relative paths are resolved againstcwd. Non-UTF-8 arguments are taken as paths.