MCPcopy Create free account
hub / github.com/davidgiven/fluxengine / exportSelectionToFile

Function exportSelectionToFile

src/gui2/imhex_overrides/main_menu_items.cpp:199–223  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

197 }
198
199 void exportSelectionToFile() {
200 fs::openFileBrowser(fs::DialogMode::Save, {}, [](const auto &path) {
201 TaskManager::createTask("hex.ui.common.processing", TaskManager::NoProgress, [path](auto &task) {
202 wolv::io::File outputFile(path, wolv::io::File::Mode::Create);
203 if (!outputFile.isValid()) {
204 TaskManager::doLater([] {
205 ui::ToastError::open("hex.builtin.menu.file.export.error.create_file"_lang);
206 });
207 return;
208 }
209
210 auto provider = ImHexApi::Provider::get();
211 std::vector<u8> bytes(5_MiB);
212
213 auto selection = ImHexApi::HexEditor::getSelection();
214 for (u64 address = selection->getStartAddress(); address <= selection->getEndAddress(); address += bytes.size()) {
215 bytes.resize(std::min<u64>(bytes.size(), selection->getEndAddress() - address + 1));
216 provider->read(address, bytes.data(), bytes.size());
217
218 outputFile.writeVector(bytes);
219 task.update();
220 }
221 });
222 });
223 }
224
225 void drawExportLanguageMenu() {
226 for (const auto &formatter : ContentRegistry::DataFormatter::impl::getExportMenuEntries()) {

Callers

nothing calls this directly

Calls 5

updateMethod · 0.80
sizeMethod · 0.45
resizeMethod · 0.45
readMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected