MCPcopy Create free account
hub / github.com/dfranx/ImFileDialog / m_finalize

Method m_finalize

ImFileDialog.cpp:609–652  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

607 }
608
609 bool FileDialog::m_finalize(const std::string& filename)
610 {
611 bool hasResult = (!filename.empty() && m_type != IFD_DIALOG_DIRECTORY) || m_type == IFD_DIALOG_DIRECTORY;
612
613 if (hasResult) {
614 if (!m_isMultiselect || m_selections.size() <= 1) {
615 std::filesystem::path path = std::filesystem::u8path(filename);
616 if (path.is_absolute()) m_result.push_back(path);
617 else m_result.push_back(m_currentDirectory / path);
618 if (m_type == IFD_DIALOG_DIRECTORY || m_type == IFD_DIALOG_FILE) {
619 if (!std::filesystem::exists(m_result.back())) {
620 m_result.clear();
621 return false;
622 }
623 }
624 }
625 else {
626 for (const auto& sel : m_selections) {
627 if (sel.is_absolute()) m_result.push_back(sel);
628 else m_result.push_back(m_currentDirectory / sel);
629 if (m_type == IFD_DIALOG_DIRECTORY || m_type == IFD_DIALOG_FILE) {
630 if (!std::filesystem::exists(m_result.back())) {
631 m_result.clear();
632 return false;
633 }
634 }
635 }
636 }
637
638 if (m_type == IFD_DIALOG_SAVE) {
639 // add the extension
640 if (m_filterSelection < m_filterExtensions.size() && m_filterExtensions[m_filterSelection].size() > 0) {
641 if (!m_result.back().has_extension()) {
642 std::string extAdd = m_filterExtensions[m_filterSelection][0];
643 m_result.back().replace_extension(extAdd);
644 }
645 }
646 }
647 }
648
649 m_isOpen = false;
650
651 return true;
652 }
653 void FileDialog::m_parseFilter(const std::string& filter)
654 {
655 m_filter = "";

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected