diff --git a/src/nostalgia/studio/lib/filedialog.hpp b/src/nostalgia/studio/lib/filedialog.hpp index 3d5c6404..41410172 100644 --- a/src/nostalgia/studio/lib/filedialog.hpp +++ b/src/nostalgia/studio/lib/filedialog.hpp @@ -14,17 +14,10 @@ struct FDFilterItem { #else using String = ox::Vector; #endif - String name; - String spec; + String name{}; + String spec{}; constexpr FDFilterItem() noexcept = default; - inline FDFilterItem(ox::CRStringView pName, ox::CRStringView pSpec) noexcept { - name.resize(pName.len() + 1); - memcpy(name.data(), pName.data(), pName.len()); - name.back().value = 0; - spec.resize(pSpec.len() + 1); - memcpy(spec.data(), pSpec.data(), pSpec.len()); - spec.back().value = 0; - } + FDFilterItem(ox::CRStringView pName, ox::CRStringView pSpec) noexcept; }; ox::Result saveFile(const ox::Vector &exts) noexcept; diff --git a/src/nostalgia/studio/lib/filedialog_nfd.cpp b/src/nostalgia/studio/lib/filedialog_nfd.cpp index 0e6e5673..a5d18fae 100644 --- a/src/nostalgia/studio/lib/filedialog_nfd.cpp +++ b/src/nostalgia/studio/lib/filedialog_nfd.cpp @@ -6,12 +6,18 @@ #include #include -#include #include "filedialog.hpp" namespace nostalgia::studio { +FDFilterItem::FDFilterItem(ox::CRStringView pName, ox::CRStringView pSpec) noexcept { + name.resize(pName.len() + 1); + ox_strncpy(name.data(), pName.data(), pName.len()); + spec.resize(pSpec.len() + 1); + ox_strncpy(spec.data(), pSpec.data(), pSpec.len()); +} + static ox::Result toResult(nfdresult_t r, const NFD::UniquePathN &path) noexcept { switch (r) { case NFD_OKAY: { @@ -30,7 +36,7 @@ static ox::Result toResult(nfdresult_t r, const NFD::UniquePathN &pa } ox::Result saveFile(const ox::Vector &filters) noexcept { - NFD::Guard guard; + const NFD::Guard guard; NFD::UniquePathN path; ox::Vector filterItems(filters.size()); for (auto i = 0u; const auto &f : filters) { @@ -42,7 +48,7 @@ ox::Result saveFile(const ox::Vector &filters) noexcep } ox::Result chooseDirectory() noexcept { - NFD::Guard guard; + const NFD::Guard guard; NFD::UniquePathN path; return toResult(NFD::PickFolder(path), path); }