F.E.I.S/src/file_dialogs.cpp
Stepland be7219ad3d IT COMPILES
IIIIIT COMPIIIIIIILES
2022-04-09 00:54:06 +02:00

37 lines
952 B
C++

#include "file_dialogs.hpp"
#include <cstring>
namespace feis {
std::optional<std::filesystem::path> save_file_dialog() {
char const* options[1] = {"*.memon"};
return convert_char_array(tinyfd_saveFileDialog(
"Save File",
nullptr,
1,
options,
nullptr
));
};
std::optional<std::filesystem::path> open_file_dialog() {
return convert_char_array(tinyfd_openFileDialog(
"Open File",
nullptr,
0,
nullptr,
nullptr,
false
));
};
std::optional<std::filesystem::path> convert_char_array(const char* utf8_path) {
if (utf8_path == nullptr) {
return {};
} else {
const auto u8string_path = std::u8string{utf8_path, utf8_path+std::strlen(utf8_path)};
return std::filesystem::path{u8string_path};
}
}
}