| 79 | } |
| 80 | |
| 81 | void apply_format_extension(ExportDialogState& st) { |
| 82 | if (st.user_edited_path) { |
| 83 | return; |
| 84 | } |
| 85 | |
| 86 | std::string path(st.path_buf.data()); |
| 87 | const std::string_view target = extension_for(st.format); |
| 88 | |
| 89 | if (ends_with(path, kPngExt) || ends_with(path, kOctExt)) { |
| 90 | const std::string_view current = |
| 91 | ends_with(path, kPngExt) ? kPngExt : kOctExt; |
| 92 | if (current != target) { |
| 93 | path.resize(path.size() - current.size()); |
| 94 | path += target; |
| 95 | } |
| 96 | } else { |
| 97 | path += target; |
| 98 | } |
| 99 | |
| 100 | set_path_buf(st.path_buf, path); |
| 101 | } |
| 102 | |
| 103 | void open_export_dialog(ExportDialogState& st, |
| 104 | const std::string& buffer_name, |