|
game_launcher 1.1.0
Modern Linux game launcher with Steam / Proton / Wine integration
|
Provides file download functionality with progress tracking. More...
#include <file_download_service.h>
Public Types | |
| using | CompletionCallback = std::function<void(const DownloadResult&)> |
| using | ProgressCallback = std::function<void(const DownloadProgress&)> |
Static Public Member Functions | |
| static std::string | calculateChecksum (const std::string &filePath, const std::string &type) |
| Calculate file checksum. | |
| static void | cancel () |
| Cancel the current download operation. | |
| static DownloadResult | download (const DownloadRequest &request, const ProgressCallback &progressCallback=nullptr) |
| Download a file with optional progress tracking. | |
| static void | downloadAsync (const DownloadRequest &request, const CompletionCallback &onComplete, const ProgressCallback &onProgress=nullptr) |
| Download a file asynchronously. | |
| static std::vector< DownloadResult > | downloadBatch (const std::vector< DownloadRequest > &requests, ProgressCallback progressCallback=nullptr) |
| Download multiple files sequentially. | |
| static void | downloadBatchAsync (const std::vector< DownloadRequest > &requests, const std::function< void(std::vector< DownloadResult >)> &onComplete, const ProgressCallback &onProgress=nullptr) |
| Download multiple files asynchronously. | |
| static uint64_t | getRemoteFileSize (const std::string &url) |
| Get file size from URL without downloading. | |
| static bool | isDownloading () |
| Check if a download is currently in progress. | |
| static bool | isUrlAccessible (const std::string &url) |
| Check if URL is accessible. | |
| static bool | verifyChecksum (const std::string &filePath, const std::string &expected, const std::string &type) |
| Verify file checksum. | |
Provides file download functionality with progress tracking.
Uses curl command-line for downloads, following the existing pattern in the codebase. Supports progress callbacks, resume, and checksums.
Definition at line 77 of file file_download_service.h.
| using FileDownloadService::CompletionCallback = std::function<void(const DownloadResult&)> |
Definition at line 81 of file file_download_service.h.
| using FileDownloadService::ProgressCallback = std::function<void(const DownloadProgress&)> |
Definition at line 80 of file file_download_service.h.
|
static |
Calculate file checksum.
| filePath | Path to the file |
| type | Checksum type: "md5" or "sha256" |
Definition at line 565 of file file_download_service.cpp.
References Logger::error(), and ShellUtils::escapeArg().
Referenced by verifyChecksum().
|
static |
Cancel the current download operation.
Definition at line 530 of file file_download_service.cpp.
References Logger::info().
Referenced by InstallationExecutor::cancel().
|
static |
Download a file with optional progress tracking.
| request | Download configuration |
| progressCallback | Called periodically with progress updates |
Definition at line 119 of file file_download_service.cpp.
References DownloadRequest::allowResume, DownloadProgress::bytesDownloaded, DownloadResult::bytesDownloaded, DownloadRequest::checksumType, DownloadResult::checksumVerified, DownloadProgress::currentFile, Logger::debug(), Logger::error(), DownloadResult::errorMessage, ShellUtils::escapeArg(), DownloadRequest::expectedChecksum, DownloadRequest::headers, DownloadResult::httpStatusCode, Logger::info(), DownloadRequest::localPath, DownloadResult::localPath, DownloadProgress::percentComplete, DownloadProgress::speedBytesPerSec, DownloadResult::success, DownloadRequest::timeoutSeconds, DownloadProgress::totalBytes, DownloadRequest::url, and verifyChecksum().
Referenced by downloadAsync(), and downloadBatch().
|
static |
Download a file asynchronously.
| request | Download configuration |
| onComplete | Called when download finishes |
| onProgress | Called periodically with progress updates |
Definition at line 493 of file file_download_service.cpp.
References download().
|
static |
Download multiple files sequentially.
| requests | List of download requests |
| progressCallback | Called with aggregate progress |
Definition at line 427 of file file_download_service.cpp.
References DownloadProgress::bytesDownloaded, DownloadResult::bytesDownloaded, download(), DownloadResult::errorMessage, getRemoteFileSize(), DownloadProgress::percentComplete, DownloadProgress::statusMessage, DownloadResult::success, and DownloadProgress::totalBytes.
Referenced by downloadBatchAsync().
|
static |
Download multiple files asynchronously.
| requests | List of download requests |
| onComplete | Called when all downloads finish |
| onProgress | Called with aggregate progress |
Definition at line 509 of file file_download_service.cpp.
References downloadBatch().
|
static |
Get file size from URL without downloading.
| url | URL to check |
Definition at line 625 of file file_download_service.cpp.
References ShellUtils::escapeArg().
Referenced by downloadBatch().
|
static |
Check if a download is currently in progress.
Definition at line 536 of file file_download_service.cpp.
|
static |
Check if URL is accessible.
| url | URL to check |
Definition at line 664 of file file_download_service.cpp.
References ShellUtils::escapeArg().
|
static |
Verify file checksum.
| filePath | Path to the file |
| expected | Expected checksum value |
| type | Checksum type: "md5" or "sha256" |
Definition at line 545 of file file_download_service.cpp.
References calculateChecksum().
Referenced by download().