16 nfdchar_t* outPath =
nullptr;
17 const nfdfilteritem_t* filter_list =
nullptr;
18 size_t filter_count = 0;
19 std::vector<nfdfilteritem_t> filter_items;
20 std::vector<std::string> filter_names;
21 std::vector<std::string> filter_specs;
24 filter_items.reserve(options.
filters.size());
25 filter_names.reserve(options.
filters.size());
26 filter_specs.reserve(options.
filters.size());
28 for (
const auto& filter : options.
filters) {
29 std::string label = filter.label.empty() ?
"Files" : filter.label;
30 std::string spec = filter.spec.empty() ?
"*" : filter.spec;
31 filter_names.push_back(label);
32 filter_specs.push_back(spec);
33 filter_items.push_back(
34 {filter_names.back().c_str(), filter_specs.back().c_str()});
37 filter_list = filter_items.data();
38 filter_count = filter_items.size();
42 NFD_OpenDialog(&outPath, filter_list, filter_count,
nullptr);
44 if (result == NFD_OKAY) {
45 std::string path(outPath);
46 NFD_FreePath(outPath);
80 const std::string& default_name,
const std::string& default_extension) {
81 nfdchar_t* outPath =
nullptr;
82 nfdfilteritem_t filterItem[1] = {
83 {default_extension.empty() ?
"All Files" : default_extension.c_str(),
84 default_extension.empty() ?
"*" : default_extension.c_str()}};
86 nfdresult_t result = NFD_SaveDialog(
87 &outPath, default_extension.empty() ?
nullptr : filterItem,
88 default_extension.empty() ? 0 : 1,
nullptr, default_name.c_str());
90 if (result == NFD_OKAY) {
91 std::string path(outPath);
92 NFD_FreePath(outPath);