Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rxi/sfd
A small C library for opening a file dialog
https://github.com/rxi/sfd
Last synced: 3 days ago
JSON representation
A small C library for opening a file dialog
- Host: GitHub
- URL: https://github.com/rxi/sfd
- Owner: rxi
- License: mit
- Created: 2017-03-12T13:57:39.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-04-19T10:10:01.000Z (7 months ago)
- Last Synced: 2024-08-01T15:30:42.095Z (3 months ago)
- Language: C
- Size: 10.7 KB
- Stars: 175
- Watchers: 9
- Forks: 15
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- AwesomeCppGameDev - sfd
README
# Simple File Dialog
A small C library for opening a file dialog on Windows and Linux.## Usage
**[sfd.c](src/sfd.c?raw=1)** and **[sfd.h](src/sfd.h?raw=1)** should be dropped
into an existing project and compiled along with it — on Windows `comdlg32`
should be linked.The library provides a function for *open* dialogs and one for *save* dialogs:
```c
sfd_Options opt = {
.title = "Open Image File",
.filter_name = "Image File",
.filter = "*.png|*.jpg",
};const char *filename = sfd_open_dialog(&opt);
if (filename) {
printf("Got file: '%s'\n", filename);
} else {
printf("Open canceled\n");
}
```Both functions accept a `sfd_Options` struct pointer with settings for
the file dialog — All fields of the `sfd_Options` struct are *optional*.| Field | Description
|-----------------|-------------------------------------------------------------
| `.title` | Title for the file dialog window
| `.path` | Default directory
| `.filter_name` | Name used to describe the file filter
| `.filter` | File filters separated by|
If the file dialog is canceled or an error occurs `NULL` is returned.
`sfd_get_error()` will return an error string in the case of an error.## License
This library is free software; you can redistribute it and/or modify it under
the terms of the MIT license. See [LICENSE](LICENSE) for details.