Files
opu/src/core/include/openpu/archive.hpp
T
yann64andClaude Opus 5.5 384aaf78c6 gtk: interface GTK4, préférences, versions, traductions, licence MIT
- interface gtkmm-4 : véhicules, ajout par VIN, mises à jour, dossier,
  téléchargement avec reprise et arrêt, choix de la clé, confirmation,
  écriture avec progression, fin avec guide d'installation ; travail
  dans un thread, résultats renvoyés via Glib::Dispatcher
- préférences : dossier de téléchargement, langue (système par défaut),
  recherche automatique de nouvelle version d'OpenPU
- recherche de nouvelle version (releases GitHub, format tags Gitea
  accepté) avec ouverture de la page dans le navigateur ;
  openpu-cli app-update
- versions : project(VERSION) + git describe régénéré à chaque build,
  openpu-cli --version, À propos, User-Agent, CHANGELOG, tools/release.sh
  (étiquette annotée, push vers tous les remotes, release GitHub)
- traductions gettext : textes anglais, fr.po complet (96 chaînes),
  extracteur de secours sans xgettext
- core : module job (téléchargement licence/fw/carte), liens des guides
  PDF, ordre des véhicules conservé (ordered_json)
- licence MIT (LICENSE, en-têtes SPDX) ; dépôt principal sur GitHub
- validé dans WSLg : parcours complet jusqu'à l'écriture d'une clé loop
  (FAT32 propre, fichiers téléchargés supprimés)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WDASLCiN764v685boRVYar
2026-11-28 19:54:04 +01:00

51 lines
1.9 KiB
C++

// SPDX-License-Identifier: MIT
#pragma once
#include "openpu/cancel.hpp"
#include <cstdint>
#include <filesystem>
#include <functional>
#include <stdexcept>
#include <string>
namespace openpu {
struct ArchiveProgress {
std::uint64_t processed = 0; ///< bytes of the archive consumed so far
std::uint64_t total = 0; ///< archive size
std::uint64_t entries = 0; ///< entries seen so far
std::string current; ///< entry being processed
};
using ArchiveProgressCallback = std::function<void(const ArchiveProgress&)>;
class ArchiveError : public std::runtime_error {
public:
enum class Kind {
Corrupt, ///< the archive is damaged or not a tar: delete it and download again
Io, ///< cannot read the archive or write the destination (full / removed drive...)
};
ArchiveError(Kind kind, const std::string& what) : std::runtime_error(what), kind_(kind) {}
Kind kind() const noexcept { return kind_; }
private:
Kind kind_;
};
/// Reads every entry of a tar archive, without writing anything, to check its integrity.
void verifyTar(const std::filesystem::path& archive, const ArchiveProgressCallback& onProgress = {},
const CancelToken* cancel = nullptr);
/// Extracts a tar archive below `destination` (typically the USB stick root).
/// Entries named UpdateInfo.xml (any directory) are skipped, as in the official application.
/// Absolute paths, `..` components and links escaping the destination are refused; owners and
/// permissions are not restored (the target is FAT32).
void extractTar(const std::filesystem::path& archive, const std::filesystem::path& destination,
const ArchiveProgressCallback& onProgress = {}, const CancelToken* cancel = nullptr);
/// Sum of the uncompressed sizes of the regular files of an archive that extractTar would write.
std::uint64_t tarPayloadSize(const std::filesystem::path& archive);
} // namespace openpu