path, err = nfd.open(filter, init) -- lets you pick a single file
paths, err = nfd.openMany(filter, init) -- lets you pick multiple files
path, err = nfd.save(filter, init) -- lets you save to a single file
where:
-
filter (string, optional): A weird DSL for filetypes you probably shouldn't emulate. it supports type subgroups (so like jpg files are "jpg,jpeg" and so on) but doesn't let you name them. defaults to all files.
-
init (string, optional): The initial path the file chooser should suggest. Normally this is a directory, but for save() you can suggest an initial filename like "/my/path/untitled.file". defaults to the working directory.
-
path can be the path the user picked, or
false
if the user selected cancel, ornil
if there was an error. This means thatif path then
works for checking success butif not path then
doesn't work for checking failure, so I dunno about this design choice in particular. -
paths is the same, but instead of a path string it returns a table of path strings.
-
err is the error message if there is one. hitting cancel returns an error message, too, so assert works for prototype code (you should probably let the user cancel!).
What this doesn't support:
- titlebar
- save vs save as
- Naming the type of file you want ("Image files" vs. "Sound files" etc.)