| 174 | namespace { |
| 175 | |
| 176 | void exportBase64() { |
| 177 | fs::openFileBrowser(fs::DialogMode::Save, {}, [](const auto &path) { |
| 178 | TaskManager::createTask("hex.ui.common.processing", TaskManager::NoProgress, [path](auto &) { |
| 179 | wolv::io::File outputFile(path, wolv::io::File::Mode::Create); |
| 180 | if (!outputFile.isValid()) { |
| 181 | TaskManager::doLater([] { |
| 182 | ui::ToastError::open("hex.builtin.menu.file.export.error.create_file"_lang); |
| 183 | }); |
| 184 | return; |
| 185 | } |
| 186 | |
| 187 | auto provider = ImHexApi::Provider::get(); |
| 188 | std::vector<u8> bytes(5_MiB); |
| 189 | for (u64 address = 0; address < provider->getActualSize(); address += bytes.size()) { |
| 190 | bytes.resize(std::min<u64>(bytes.size(), provider->getActualSize() - address)); |
| 191 | provider->read(provider->getBaseAddress() + address, bytes.data(), bytes.size()); |
| 192 | |
| 193 | outputFile.writeVector(crypt::encode64(bytes)); |
| 194 | } |
| 195 | }); |
| 196 | }); |
| 197 | } |
| 198 | |
| 199 | void exportSelectionToFile() { |
| 200 | fs::openFileBrowser(fs::DialogMode::Save, {}, [](const auto &path) { |
nothing calls this directly
no test coverage detected