| 1467 | } |
| 1468 | |
| 1469 | std::string CommandCreate::readRawFile(const std::filesystem::path& filepath) { |
| 1470 | std::string result; |
| 1471 | InputStream inputStream(filepath.string(), *this); |
| 1472 | |
| 1473 | inputStream->seekg(0, std::ios::end); |
| 1474 | if (inputStream->fail()) |
| 1475 | fatal(rc::IO_FAILURE, "Failed to seek file \"{}\": {}.", filepath.generic_string(), errnoMessage()); |
| 1476 | |
| 1477 | const auto size = inputStream->tellg(); |
| 1478 | inputStream->seekg(0); |
| 1479 | if (inputStream->fail()) |
| 1480 | fatal(rc::IO_FAILURE, "Failed to seek file \"{}\": {}.", filepath.generic_string(), errnoMessage()); |
| 1481 | |
| 1482 | result.resize(size); |
| 1483 | inputStream->read(result.data(), size); |
| 1484 | if (inputStream->fail()) |
| 1485 | fatal(rc::IO_FAILURE, "Failed to read file \"{}\": {}.", filepath.generic_string(), errnoMessage()); |
| 1486 | |
| 1487 | return result; |
| 1488 | } |
| 1489 | |
| 1490 | void CommandCreate::executeCreate() { |
| 1491 | const auto warningFn = [this](const std::string& w) { this->warning(w); }; |