MCPcopy Create free account
hub / github.com/78/tenbox / FindImageFile

Function FindImageFile

src/daemon/cloud_tunnel.cpp:358–371  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

356}
357
358std::string FindImageFile(const image_source::ImageEntry& image, const std::string& cache_dir,
359 const std::string& kind) {
360 for (const auto& file : image.files) {
361 const auto& name = file.name;
362 const bool is_kernel = name == "vmlinuz" || name.rfind("vmlinuz", 0) == 0 || name.rfind("Image", 0) == 0;
363 const bool is_initrd = name.rfind("initrd", 0) == 0 || name.rfind("initramfs", 0) == 0;
364 const bool is_disk = name.find(".qcow2") != std::string::npos || name.find("rootfs") != std::string::npos;
365 if ((kind == "kernel" && is_kernel) || (kind == "initrd" && is_initrd) ||
366 (kind == "disk" && is_disk)) {
367 return (std::filesystem::path(cache_dir) / name).string();
368 }
369 }
370 return {};
371}
372
373std::string RandomWsKey() {
374 static constexpr char chars[] =

Callers 1

CreateVmMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected