|
game_launcher 1.1.0
Modern Linux game launcher with Steam / Proton / Wine integration
|
Service for verifying game file integrity. More...
#include <file_verification_service.h>
Classes | |
| struct | Impl |
Public Types | |
| using | ProgressCallback = std::function<void(const VerificationProgress&)> |
Public Member Functions | |
| FileVerificationService () | |
| ~FileVerificationService () | |
| void | cancelVerification (const std::string &gameId) |
| Cancel an ongoing verification. | |
| void | clearCache (const std::string &gameId="") |
| Clear verification cache. | |
| GameManifest | generateManifest (const std::string &gameId, const std::filesystem::path &gamePath, const std::string &checksumType="sha256", const ProgressCallback &progressCallback=nullptr) |
| Generate a manifest for a game installation. | |
| std::optional< GameVerificationResult > | getCachedResult (const std::string &gameId) const |
| Get cached verification result. | |
| std::filesystem::path | getManifestPath (const std::string &gameId) const |
| Get default manifest path for a game. | |
| bool | isVerifying (const std::string &gameId) const |
| Check if verification is in progress. | |
| std::optional< GameManifest > | loadManifest (const std::filesystem::path &path) |
| Load a manifest from file. | |
| std::optional< GameManifest > | loadSteamManifest (uint32_t appId, uint32_t depotId=0) |
| Load Steam depot manifest for a game. | |
| bool | saveManifest (const GameManifest &manifest, const std::filesystem::path &path) |
| Save a manifest to file. | |
| void | setCacheValidity (int seconds) |
| Set cache validity duration. | |
| FileVerificationResult | verifyFile (const std::filesystem::path &basePath, const FileVerificationResult &expected) |
| Verify a single file. | |
| GameVerificationResult | verifyGame (const std::string &gameId, const std::filesystem::path &gamePath, const ProgressCallback &progressCallback=nullptr) |
| Verify a game's file integrity. | |
| std::future< GameVerificationResult > | verifyGameAsync (const std::string &gameId, const std::filesystem::path &gamePath, const ProgressCallback &progressCallback=nullptr) |
| Verify a game asynchronously. | |
| GameVerificationResult | verifySteamGame (uint32_t appId, const std::filesystem::path &gamePath, const ProgressCallback &progressCallback=nullptr) |
| Verify a Steam game using depot manifests. | |
Static Public Member Functions | |
| static std::string | calculateChecksum (const std::filesystem::path &path, const std::string &type) |
| Calculate checksum of a file. | |
Service for verifying game file integrity.
Provides methods for verifying game installations against manifests or generating new manifests for games.
Definition at line 199 of file file_verification_service.h.
| using FileVerificationService::ProgressCallback = std::function<void(const VerificationProgress&)> |
Definition at line 202 of file file_verification_service.h.
| FileVerificationService::FileVerificationService | ( | ) |
Definition at line 108 of file file_verification_service.cpp.
| FileVerificationService::~FileVerificationService | ( | ) |
Definition at line 118 of file file_verification_service.cpp.
|
static |
Calculate checksum of a file.
| path | File path |
| type | Checksum type ("md5", "sha1", "sha256") |
Definition at line 131 of file file_verification_service.cpp.
References Logger::error().
Referenced by generateManifest(), and verifyFile().
| void FileVerificationService::cancelVerification | ( | const std::string & | gameId | ) |
Cancel an ongoing verification.
| gameId | Game ID |
Definition at line 547 of file file_verification_service.cpp.
References Logger::info().
| void FileVerificationService::clearCache | ( | const std::string & | gameId = "" | ) |
Clear verification cache.
| gameId | Game ID (empty = clear all) |
Definition at line 869 of file file_verification_service.cpp.
References Logger::info().
| GameManifest FileVerificationService::generateManifest | ( | const std::string & | gameId, |
| const std::filesystem::path & | gamePath, | ||
| const std::string & | checksumType = "sha256", | ||
| const ProgressCallback & | progressCallback = nullptr ) |
Generate a manifest for a game installation.
| gameId | Game ID |
| gamePath | Path to game installation |
| checksumType | Checksum algorithm ("md5", "sha1", "sha256") |
| progressCallback | Progress updates |
Definition at line 638 of file file_verification_service.cpp.
References VerificationProgress::bytesProcessed, calculateChecksum(), FileVerificationResult::checksumType, GameManifest::checksumType, GameManifest::created, VerificationProgress::currentFile, Logger::error(), FileVerificationResult::expectedChecksum, FileVerificationResult::expectedSize, GameManifest::files, VerificationProgress::filesProcessed, GameManifest::gameId, Logger::info(), FileVerificationResult::path, VerificationProgress::percentComplete, VerificationProgress::state, VerificationProgress::totalBytes, VerificationProgress::totalFiles, and VerificationProgress::VerifyingFiles.
Referenced by verifyGame().
| std::optional< GameVerificationResult > FileVerificationService::getCachedResult | ( | const std::string & | gameId | ) | const |
Get cached verification result.
| gameId | Game ID |
Definition at line 847 of file file_verification_service.cpp.
| fs::path FileVerificationService::getManifestPath | ( | const std::string & | gameId | ) | const |
Get default manifest path for a game.
| gameId | Game ID |
Definition at line 837 of file file_verification_service.cpp.
Referenced by verifyGame().
| bool FileVerificationService::isVerifying | ( | const std::string & | gameId | ) | const |
Check if verification is in progress.
| gameId | Game ID |
Definition at line 558 of file file_verification_service.cpp.
| std::optional< GameManifest > FileVerificationService::loadManifest | ( | const std::filesystem::path & | path | ) |
Load a manifest from file.
| path | Manifest file path |
Definition at line 785 of file file_verification_service.cpp.
References FileVerificationResult::checksumType, GameManifest::checksumType, GameManifest::created, Logger::error(), FileVerificationResult::expectedChecksum, FileVerificationResult::expectedSize, GameManifest::files, GameManifest::gameId, Logger::info(), FileVerificationResult::path, and GameManifest::version.
Referenced by verifyGame().
| std::optional< GameManifest > FileVerificationService::loadSteamManifest | ( | uint32_t | appId, |
| uint32_t | depotId = 0 ) |
Load Steam depot manifest for a game.
| appId | Steam app ID |
| depotId | Depot ID (0 = auto-detect main depot) |
Definition at line 602 of file file_verification_service.cpp.
References Logger::debug().
Referenced by verifySteamGame().
| bool FileVerificationService::saveManifest | ( | const GameManifest & | manifest, |
| const std::filesystem::path & | path ) |
Save a manifest to file.
| manifest | Manifest to save |
| path | Output path |
Definition at line 736 of file file_verification_service.cpp.
References GameManifest::checksumType, GameManifest::created, Logger::error(), GameManifest::files, GameManifest::gameId, Logger::info(), and GameManifest::version.
| void FileVerificationService::setCacheValidity | ( | int | seconds | ) |
Set cache validity duration.
| seconds | Cache validity in seconds (0 = no caching) |
Definition at line 885 of file file_verification_service.cpp.
| FileVerificationResult FileVerificationService::verifyFile | ( | const std::filesystem::path & | basePath, |
| const FileVerificationResult & | expected ) |
Verify a single file.
| basePath | Game-install root the manifest's relative path is anchored to. The path-traversal containment check rejects manifests whose canonical resolved path escapes this base via .. segments, absolute paths, or symlinks. |
| expected | Expected verification record (relative path, size, sha256/sha1/md5 — whichever the manifest specifies). |
Definition at line 206 of file file_verification_service.cpp.
References FileVerificationResult::actualChecksum, FileVerificationResult::actualSize, calculateChecksum(), FileVerificationResult::checksumType, Logger::error(), FileVerificationResult::expectedChecksum, FileVerificationResult::expectedSize, Invalid, Missing, FileVerificationResult::path, SizeMismatch, FileVerificationResult::status, Valid, and FileVerificationResult::verificationTimeMs.
| GameVerificationResult FileVerificationService::verifyGame | ( | const std::string & | gameId, |
| const std::filesystem::path & | gamePath, | ||
| const ProgressCallback & | progressCallback = nullptr ) |
Verify a game's file integrity.
| gameId | Game ID |
| gamePath | Path to game installation |
| progressCallback | Progress updates |
Definition at line 467 of file file_verification_service.cpp.
References VerificationProgress::errorMessage, VerificationProgress::Failed, GameVerificationResult::gameId, GameVerificationResult::gameName, GameVerificationResult::gamePath, generateManifest(), getManifestPath(), Logger::info(), GameVerificationResult::invalidFiles, GameManifest::isValid(), VerificationProgress::LoadingManifest, loadManifest(), GameVerificationResult::missingFiles, VerificationProgress::state, and GameVerificationResult::validFiles.
Referenced by verifyGameAsync(), and verifySteamGame().
| std::future< GameVerificationResult > FileVerificationService::verifyGameAsync | ( | const std::string & | gameId, |
| const std::filesystem::path & | gamePath, | ||
| const ProgressCallback & | progressCallback = nullptr ) |
Verify a game asynchronously.
| gameId | Game ID |
| gamePath | Path to game installation |
| progressCallback | Progress updates |
Definition at line 540 of file file_verification_service.cpp.
References verifyGame().
| GameVerificationResult FileVerificationService::verifySteamGame | ( | uint32_t | appId, |
| const std::filesystem::path & | gamePath, | ||
| const ProgressCallback & | progressCallback = nullptr ) |
Verify a Steam game using depot manifests.
| appId | Steam app ID |
| gamePath | Path to game installation |
| progressCallback | Progress updates |
Definition at line 570 of file file_verification_service.cpp.
References Logger::info(), GameManifest::isValid(), loadSteamManifest(), and verifyGame().