|
QGroundControl
Ground Control Station for MAVLink Drones
|
Classes | |
| struct | ArchiveEntry |
| Metadata for a single entry in an archive. More... | |
| struct | ArchiveStats |
| Summary statistics for an archive. More... | |
Typedefs | |
| using | ProgressCallback = std::function< bool(qint64 bytesProcessed, qint64 totalBytes)> |
| using | EntryFilter = std::function< bool(const ArchiveEntry &entry)> |
Enumerations | |
| enum class | Error { None , FileNotFound , PermissionDenied , InvalidArchive , UnsupportedFormat , SizeLimitExceeded , Cancelled , FileNotInArchive , IoError , InternalError } |
| Error codes for decompression operations. More... | |
| enum class | Format { Auto , ZIP , SEVENZ , GZIP , XZ , ZSTD , BZIP2 , LZ4 , TAR , TAR_GZ , TAR_XZ , TAR_ZSTD , TAR_BZ2 , TAR_LZ4 } |
| Archive and compression format types (for decompression) More... | |
| enum class | CompressionLevel { None = 0 , Fast = 1 , Default = 6 , Best = 9 } |
Functions | |
| Error | lastError () |
| Get the error code from the last operation (thread-local) | |
| QString | lastErrorString () |
| Get a human-readable error message from the last operation (thread-local) | |
| QString | errorName (Error error) |
| Get a human-readable name for an error code. | |
| QString | detectedFormatName () |
| QString | detectedFilterName () |
| static bool | validateFileInput (const QString &filePath, Format &format) |
| static bool | validateArchiveInput (const QString &archivePath, Format &format) |
| Validate archive input: file exists, format detected, and is archive format. | |
| static bool | validateDeviceInput (QIODevice *device) |
| Validate device input for streaming operations. | |
| static void | captureFormatInfo () |
| Capture format detection info from QGClibarchive after an operation. | |
| static Format | detectFormatFromExtension (const QString &filePath) |
| Extension-based format detection (internal helper) | |
| Format | detectFormat (const QString &filePath, bool useContentFallback) |
| Format | detectFormatFromFile (const QString &filePath) |
| Format | detectFormatFromData (const QByteArray &data) |
| QString | formatExtension (Format format) |
| Get file extension for a format. | |
| QString | formatName (Format format) |
| Get human-readable name for a format. | |
| bool | isArchiveFormat (Format format) |
| Check if format is an archive (contains multiple files) | |
| bool | isCompressionFormat (Format format) |
| Check if format is a compression format (single stream) | |
| QString | strippedPath (const QString &filePath) |
| bool | decompressFile (const QString &inputPath, const QString &outputPath, Format format, ProgressCallback progress, qint64 maxDecompressedBytes) |
| QString | decompressIfNeeded (const QString &filePath, const QString &outputPath, bool removeOriginal) |
| QByteArray | decompressData (const QByteArray &data, Format format, qint64 maxDecompressedBytes) |
| bool | extractArchive (const QString &archivePath, const QString &outputDirectoryPath, Format format, ProgressCallback progress, qint64 maxDecompressedBytes) |
| bool | extractArchiveAtomic (const QString &archivePath, const QString &outputDirectoryPath, Format format, ProgressCallback progress, qint64 maxDecompressedBytes) |
| bool | extractArchiveFiltered (const QString &archivePath, const QString &outputDirectoryPath, EntryFilter filter, ProgressCallback progress, qint64 maxDecompressedBytes) |
| QStringList | listArchive (const QString &archivePath, Format format) |
| QList< ArchiveEntry > | listArchiveDetailed (const QString &archivePath, Format format) |
| ArchiveStats | getArchiveStats (const QString &archivePath, Format format) |
| bool | validateArchive (const QString &archivePath, Format format) |
| bool | fileExists (const QString &archivePath, const QString &fileName, Format format) |
| bool | extractFile (const QString &archivePath, const QString &fileName, const QString &outputPath, Format format) |
| QByteArray | extractFileData (const QString &archivePath, const QString &fileName, Format format) |
| bool | extractFiles (const QString &archivePath, const QStringList &fileNames, const QString &outputDirectoryPath, Format format) |
| bool | extractByPattern (const QString &archivePath, const QStringList &patterns, const QString &outputDirectoryPath, QStringList *extractedFiles, Format format) |
| bool | decompressFromDevice (QIODevice *device, const QString &outputPath, ProgressCallback progress, qint64 maxDecompressedBytes) |
| QByteArray | decompressFromDevice (QIODevice *device, qint64 maxDecompressedBytes) |
| bool | extractFromDevice (QIODevice *device, const QString &outputDirectoryPath, ProgressCallback progress, qint64 maxDecompressedBytes) |
| QByteArray | extractFileDataFromDevice (QIODevice *device, const QString &fileName) |
| QByteArray | compress (const QByteArray &data, CompressionLevel level) |
| QByteArray | uncompress (const QByteArray &data) |
| QByteArray | compressData (const QByteArray &data, CompressionLevel level, int minSize) |
| QByteArray | uncompressData (const QByteArray &data, qint64 maxDecompressedSize) |
| bool | isDataCompressed (const QByteArray &data) |
| Check if data has the compressed framing header. | |
| int | lastCompressionRatio () |
| Compression ratio from the last compressData() call (thread-local, percentage of original size). | |
| QByteArray | readFile (const QString &filePath, QString *errorString=nullptr, qint64 maxBytes=0) |
| Read file contents, transparently decompressing .gz/.xz/.zst/.bz2/.lz4 files. | |
| QString | computeFileHash (const QString &filePath, QCryptographicHash::Algorithm algorithm=QCryptographicHash::Sha256) |
| Hash file contents post-decompression. | |
| bool | looksLikeCompressedData (const QByteArray &data) |
| QJsonDocument | parseCompressedJson (const QByteArray &data, QJsonParseError *error=nullptr) |
| Parse JSON from data that may be compressed. Auto-detects gzip/xz/zstd/bzip2/lz4. | |
| bool | isCompressedFile (const QString &filePath) |
| Check if file path indicates a compressed file (.gz, .xz, .zst) | |
| bool | isArchiveFile (const QString &filePath) |
| Check if file path indicates an archive file (.zip, .tar, .tar.gz, etc.) | |
Variables | |
| static constexpr quint8 | kHeaderUncompressed = 0x00 |
| static constexpr quint8 | kHeaderCompressed = 0x01 |
| static thread_local int | s_lastCompressionRatio = 100 |
| constexpr quint32 | kDefaultFilePermissions = 0644 |
| Default Unix permissions for extracted files (rw-r–r–) | |
Unified decompression interface for archives and single-file compression Uses libarchive for all operations (ZIP, GZIP, XZ, ZSTD, TAR, etc.) NOTE: This module is decompression-only; QGC does not create compressed files
| using QGCCompression::EntryFilter = typedef std::function<bool(const ArchiveEntry &entry)> |
Entry filter callback for selective extraction Called for each entry before extraction; return true to extract, false to skip
| entry | Metadata for the archive entry |
Definition at line 53 of file QGCCompressionTypes.h.
| using QGCCompression::ProgressCallback = typedef std::function<bool(qint64 bytesProcessed, qint64 totalBytes)> |
Progress callback for long-running operations
| bytesProcessed | Bytes processed so far |
| totalBytes | Total bytes to process (0 if unknown) |
Definition at line 21 of file QGCCompressionTypes.h.
|
strong |
| Enumerator | |
|---|---|
| None | |
| Fast | |
| Default | |
| Best | |
Definition at line 315 of file QGCCompression.h.
|
strong |
Error codes for decompression operations.
Definition at line 23 of file QGCCompression.h.
|
strong |
Archive and compression format types (for decompression)
Definition at line 50 of file QGCCompression.h.
|
static |
Capture format detection info from QGClibarchive after an operation.
Definition at line 260 of file QGCCompression.cc.
References captureFormatInfo(), QGClibarchive::lastDetectedFilterName(), and QGClibarchive::lastDetectedFormatName().
Referenced by captureFormatInfo(), decompressData(), decompressFile(), decompressFromDevice(), decompressFromDevice(), extractArchive(), extractArchiveAtomic(), extractArchiveFiltered(), extractFileDataFromDevice(), and extractFromDevice().
| QByteArray QGCCompression::compress | ( | const QByteArray & | data, |
| CompressionLevel | level = CompressionLevel::Default |
||
| ) |
Compress data using qCompress (4-byte size header + zlib payload).
| data | Raw data to compress |
| level | Compression level |
Definition at line 909 of file QGCCompression.cc.
References compress().
Referenced by compress().
| QByteArray QGCCompression::compressData | ( | const QByteArray & | data, |
| CompressionLevel | level = CompressionLevel::Default, |
||
| int | minSize = 256 |
||
| ) |
Compress data in memory with a framing header byte. Returns header(1) + payload. If compression doesn't reduce size, returns uncompressed with header.
| data | Raw data to compress |
| level | Compression level |
| minSize | Minimum data size to attempt compression (smaller data returned uncompressed) |
Definition at line 930 of file QGCCompression.cc.
References compressData(), kHeaderCompressed, kHeaderUncompressed, and s_lastCompressionRatio.
Referenced by compressData().
| QString QGCCompression::computeFileHash | ( | const QString & | filePath, |
| QCryptographicHash::Algorithm | algorithm | ||
| ) |
Hash file contents post-decompression.
Definition at line 1023 of file QGCCompression.cc.
References QGCArchiveDeviceBase::close(), QGCFileHelper::computeFileHash(), computeFileHash(), isCompressedFile(), and QGCDecompressDevice::open().
Referenced by computeFileHash().
| QByteArray QGCCompression::decompressData | ( | const QByteArray & | data, |
| Format | format = Format::Auto, |
||
| qint64 | maxDecompressedBytes = 0 |
||
| ) |
Decompress data in memory
| data | Compressed input data |
| format | Compression format (Auto = detect from magic bytes) |
| maxDecompressedBytes | Maximum decompressed size in bytes (0 = unlimited) |
Definition at line 620 of file QGCCompression.cc.
References captureFormatInfo(), decompressData(), QGClibarchive::decompressDataFromMemory(), detectFormatFromData(), formatName, and isCompressionFormat().
Referenced by decompressData(), and parseCompressedJson().
| bool QGCCompression::decompressFile | ( | const QString & | inputPath, |
| const QString & | outputPath = QString(), |
||
| Format | format = Format::Auto, |
||
| ProgressCallback | progress = nullptr, |
||
| qint64 | maxDecompressedBytes = 0 |
||
| ) |
Decompress a single file
| inputPath | Path to compressed file (or Qt resource path :/) |
| outputPath | Path for decompressed output (if empty, strips compression extension) |
| format | Compression format (Auto = detect from inputPath) |
| progress | Optional progress callback (return false to cancel) |
| maxDecompressedBytes | Maximum decompressed size in bytes (0 = unlimited) |
Definition at line 555 of file QGCCompression.cc.
References captureFormatInfo(), decompressFile(), QGClibarchive::decompressSingleFile(), extractArchive(), formatExtension(), formatName, isArchiveFormat(), isCompressionFormat(), and validateFileInput().
Referenced by decompressFile(), QGCCompressionJob::decompressFile(), QGCCompressionJob::decompressFileAsync(), and decompressIfNeeded().
| bool QGCCompression::decompressFromDevice | ( | QIODevice * | device, |
| const QString & | outputPath, | ||
| ProgressCallback | progress = nullptr, |
||
| qint64 | maxDecompressedBytes = 0 |
||
| ) |
Decompress from QIODevice to file Enables streaming decompression from QNetworkReply, QBuffer, etc.
| device | QIODevice to read from (must be open and readable) |
| outputPath | Output file path |
| progress | Optional progress callback |
| maxDecompressedBytes | Maximum decompressed size in bytes (0 = unlimited) |
Definition at line 842 of file QGCCompression.cc.
References captureFormatInfo(), QGClibarchive::decompressFromDevice(), decompressFromDevice(), and validateDeviceInput().
Referenced by decompressFromDevice(), and decompressFromDevice().
| QByteArray QGCCompression::decompressFromDevice | ( | QIODevice * | device, |
| qint64 | maxDecompressedBytes = 0 |
||
| ) |
Decompress from QIODevice to memory
| device | QIODevice to read from (must be open and readable) |
| maxDecompressedBytes | Maximum decompressed size in bytes (0 = unlimited) |
Definition at line 857 of file QGCCompression.cc.
References captureFormatInfo(), QGClibarchive::decompressDataFromDevice(), decompressFromDevice(), and validateDeviceInput().
| QString QGCCompression::decompressIfNeeded | ( | const QString & | filePath, |
| const QString & | outputPath = QString(), |
||
| bool | removeOriginal = false |
||
| ) |
Decompress file if it's a compressed format, otherwise return original path
| filePath | Input file (may or may not be compressed) |
| outputPath | Output path (if empty, uses strippedPath) |
| removeOriginal | Remove compressed file after successful decompression (default: false) |
Definition at line 597 of file QGCCompression.cc.
References decompressFile(), decompressIfNeeded(), isCompressedFile(), and strippedPath().
Referenced by decompressIfNeeded().
| QString QGCCompression::detectedFilterName | ( | ) |
Get the detected compression filter name from the last operation (thread-local) Returns names like "gzip", "xz", "zstd", "bzip2", "none", etc. Empty string if no filter was detected
Definition at line 197 of file QGCCompression.cc.
References detectedFilterName().
Referenced by detectedFilterName().
| QString QGCCompression::detectedFormatName | ( | ) |
Get the detected archive format name from the last operation (thread-local) Returns names like "ZIP 2.0", "POSIX ustar", "RAW", etc. Empty string if no format was detected
Definition at line 192 of file QGCCompression.cc.
References detectedFormatName().
Referenced by detectedFormatName().
| Format QGCCompression::detectFormat | ( | const QString & | filePath, |
| bool | useContentFallback = true |
||
| ) |
Detect format from file path (extension-based, with content fallback) First tries extension-based detection; if that fails, reads file content and uses magic bytes and Qt MIME detection as fallback
| filePath | Path to file |
| useContentFallback | If true (default), read file content when extension fails |
Definition at line 320 of file QGCCompression.cc.
References detectFormat(), detectFormatFromExtension(), detectFormatFromFile(), QGCFileHelper::exists(), and formatName.
Referenced by detectFormat(), isArchiveFile(), isCompressedFile(), strippedPath(), and validateFileInput().
| Format QGCCompression::detectFormatFromData | ( | const QByteArray & | data | ) |
Detect format from data (magic bytes + MIME detection)
| data | Raw file data (at least first 512 bytes recommended) |
Definition at line 370 of file QGCCompression.cc.
References detectFormatFromData(), and formatName.
Referenced by decompressData(), detectFormatFromData(), detectFormatFromFile(), and looksLikeCompressedData().
|
static |
Extension-based format detection (internal helper)
Definition at line 270 of file QGCCompression.cc.
References detectFormatFromExtension().
Referenced by detectFormat(), and detectFormatFromExtension().
| Format QGCCompression::detectFormatFromFile | ( | const QString & | filePath | ) |
Detect format from file content only (ignores extension) Reads file and uses magic bytes + Qt MIME detection
| filePath | Path to file |
Definition at line 339 of file QGCCompression.cc.
References detectFormatFromData(), detectFormatFromFile(), formatName, and QGCFileHelper::isQtResource().
Referenced by detectFormat(), and detectFormatFromFile().
| QString QGCCompression::errorName | ( | Error | error | ) |
Get a human-readable name for an error code.
Definition at line 165 of file QGCCompression.cc.
References error, and errorName().
Referenced by errorName(), and lastErrorString().
| bool QGCCompression::extractArchive | ( | const QString & | archivePath, |
| const QString & | outputDirectoryPath, | ||
| Format | format = Format::Auto, |
||
| ProgressCallback | progress = nullptr, |
||
| qint64 | maxDecompressedBytes = 0 |
||
| ) |
Extract an archive to a directory
| archivePath | Path to archive file (or Qt resource path :/) |
| outputDirectoryPath | Output directory path |
| format | Archive format (Auto = detect from archivePath) |
| progress | Optional progress callback (return false to cancel) |
| maxDecompressedBytes | Maximum total decompressed size in bytes (0 = unlimited) |
Definition at line 653 of file QGCCompression.cc.
References captureFormatInfo(), QGClibarchive::extractAnyArchive(), extractArchive(), formatName, and validateArchiveInput().
Referenced by decompressFile(), extractArchive(), QGCCompressionJob::extractArchive(), and QGCCompressionJob::extractArchiveAsync().
| bool QGCCompression::extractArchiveAtomic | ( | const QString & | archivePath, |
| const QString & | outputDirectoryPath, | ||
| Format | format = Format::Auto, |
||
| ProgressCallback | progress = nullptr, |
||
| qint64 | maxDecompressedBytes = 0 |
||
| ) |
Extract an archive to a directory atomically (all-or-nothing) Uses staged extraction and an atomic directory swap on success. If extraction or commit fails, the pre-existing output directory is restored.
| archivePath | Path to archive file (or Qt resource path :/) |
| outputDirectoryPath | Output directory path |
| format | Archive format (Auto = detect from archivePath) |
| progress | Optional progress callback (return false to cancel) |
| maxDecompressedBytes | Maximum total decompressed size in bytes (0 = unlimited) |
Definition at line 672 of file QGCCompression.cc.
References captureFormatInfo(), extractArchiveAtomic(), QGClibarchive::extractArchiveAtomic(), formatName, and validateArchiveInput().
Referenced by extractArchiveAtomic(), and QGCCompressionJob::extractArchiveAtomic().
| bool QGCCompression::extractArchiveFiltered | ( | const QString & | archivePath, |
| const QString & | outputDirectoryPath, | ||
| EntryFilter | filter, | ||
| ProgressCallback | progress = nullptr, |
||
| qint64 | maxDecompressedBytes = 0 |
||
| ) |
Extract an archive with per-entry filtering
| archivePath | Path to archive file (or Qt resource path :/) |
| outputDirectoryPath | Output directory path |
| filter | Callback to decide which entries to extract (return true to extract) |
| progress | Optional progress callback (return false to cancel) |
| maxDecompressedBytes | Maximum total decompressed size in bytes (0 = unlimited) |
Definition at line 691 of file QGCCompression.cc.
References captureFormatInfo(), extractArchiveFiltered(), QGClibarchive::extractWithFilter(), and validateArchiveInput().
Referenced by extractArchiveFiltered().
| bool QGCCompression::extractByPattern | ( | const QString & | archivePath, |
| const QStringList & | patterns, | ||
| const QString & | outputDirectoryPath, | ||
| QStringList * | extractedFiles = nullptr, |
||
| Format | format = Format::Auto |
||
| ) |
Extract files matching glob patterns from an archive Supports wildcards: * (any chars), ? (single char), [...] (char class)
| archivePath | Path to archive file (or Qt resource path :/) |
| patterns | Glob patterns to match (e.g., "*.json", "subdir/*", "file.txt") |
| outputDirectoryPath | Output directory (files extracted with their archive names) |
| extractedFiles | Optional output list of files that were extracted |
| format | Archive format (Auto = detect from archivePath) |
Definition at line 820 of file QGCCompression.cc.
References QGClibarchive::extractByPattern(), extractByPattern(), and validateArchiveInput().
Referenced by extractByPattern().
| bool QGCCompression::extractFile | ( | const QString & | archivePath, |
| const QString & | fileName, | ||
| const QString & | outputPath = QString(), |
||
| Format | format = Format::Auto |
||
| ) |
Extract a single file from an archive to disk
| archivePath | Path to archive file (or Qt resource path :/) |
| fileName | Name of file inside archive (as shown by listArchive) |
| outputPath | Output file path (if empty, extracts to current directory) |
| format | Archive format (Auto = detect from archivePath) |
Definition at line 779 of file QGCCompression.cc.
References extractFile(), QGClibarchive::extractSingleFile(), and validateArchiveInput().
Referenced by QGCCompressionJob::extractFile(), and extractFile().
| QByteArray QGCCompression::extractFileData | ( | const QString & | archivePath, |
| const QString & | fileName, | ||
| Format | format = Format::Auto |
||
| ) |
Extract a single file from an archive directly to memory
| archivePath | Path to archive file (or Qt resource path :/) |
| fileName | Name of file inside archive (as shown by listArchive) |
| format | Archive format (Auto = detect from archivePath) |
Definition at line 794 of file QGCCompression.cc.
References extractFileData(), QGClibarchive::extractFileToMemory(), and validateArchiveInput().
Referenced by extractFileData().
| QByteArray QGCCompression::extractFileDataFromDevice | ( | QIODevice * | device, |
| const QString & | fileName | ||
| ) |
Extract a single file from archive device to memory
| device | QIODevice to read from (must be open and readable) |
| fileName | Name of file inside archive |
Definition at line 886 of file QGCCompression.cc.
References captureFormatInfo(), extractFileDataFromDevice(), QGClibarchive::extractFileDataFromDevice(), and validateDeviceInput().
Referenced by extractFileDataFromDevice().
| bool QGCCompression::extractFiles | ( | const QString & | archivePath, |
| const QStringList & | fileNames, | ||
| const QString & | outputDirectoryPath, | ||
| Format | format = Format::Auto |
||
| ) |
Extract multiple files from an archive in one pass
| archivePath | Path to archive file (or Qt resource path :/) |
| fileNames | Names of files inside archive |
| outputDirectoryPath | Output directory (files extracted with their archive names) |
| format | Archive format (Auto = detect from archivePath) |
Definition at line 807 of file QGCCompression.cc.
References extractFiles(), QGClibarchive::extractMultipleFiles(), and validateArchiveInput().
Referenced by QGCCompressionJob::extractFiles(), and extractFiles().
| bool QGCCompression::extractFromDevice | ( | QIODevice * | device, |
| const QString & | outputDirectoryPath, | ||
| ProgressCallback | progress = nullptr, |
||
| qint64 | maxDecompressedBytes = 0 |
||
| ) |
Extract archive from QIODevice to directory
| device | QIODevice to read from (must be open and readable) |
| outputDirectoryPath | Output directory path |
| progress | Optional progress callback |
| maxDecompressedBytes | Maximum total decompressed size in bytes (0 = unlimited) |
Definition at line 871 of file QGCCompression.cc.
References captureFormatInfo(), QGClibarchive::extractFromDevice(), extractFromDevice(), and validateDeviceInput().
Referenced by extractFromDevice().
| bool QGCCompression::fileExists | ( | const QString & | archivePath, |
| const QString & | fileName, | ||
| Format | format = Format::Auto |
||
| ) |
Check if a file exists in an archive without extracting
| archivePath | Path to archive file (or Qt resource path :/) |
| fileName | Name of file to check for (as shown by listArchive) |
| format | Archive format (Auto = detect from archivePath) |
Definition at line 767 of file QGCCompression.cc.
References fileExists(), QGClibarchive::fileExistsInArchive(), and validateArchiveInput().
Referenced by fileExists().
| QString QGCCompression::formatExtension | ( | Format | format | ) |
Get file extension for a format.
Definition at line 435 of file QGCCompression.cc.
References formatExtension().
Referenced by decompressFile(), formatExtension(), and strippedPath().
| QString QGCCompression::formatName | ( | Format | format | ) |
Get human-readable name for a format.
Definition at line 470 of file QGCCompression.cc.
| ArchiveStats QGCCompression::getArchiveStats | ( | const QString & | archivePath, |
| Format | format = Format::Auto |
||
| ) |
Get summary statistics for an archive without extracting
| archivePath | Path to archive file (or Qt resource path :/) |
| format | Archive format (Auto = detect from archivePath) |
Definition at line 750 of file QGCCompression.cc.
References QGClibarchive::getArchiveStats(), getArchiveStats(), and validateArchiveInput().
Referenced by getArchiveStats().
|
inline |
Check if file path indicates an archive file (.zip, .tar, .tar.gz, etc.)
Definition at line 108 of file QGCCompression.h.
References detectFormat(), and isArchiveFormat().
Referenced by FTPController::browseArchive(), QGCMapEngineManager::importArchive(), and PlanMasterController::loadFromArchive().
| bool QGCCompression::isArchiveFormat | ( | Format | format | ) |
Check if format is an archive (contains multiple files)
Definition at line 505 of file QGCCompression.cc.
References isArchiveFormat().
Referenced by decompressFile(), isArchiveFile(), isArchiveFormat(), and validateArchiveInput().
|
inline |
Check if file path indicates a compressed file (.gz, .xz, .zst)
Definition at line 103 of file QGCCompression.h.
References detectFormat(), and isCompressionFormat().
Referenced by computeFileHash(), decompressIfNeeded(), and readFile().
| bool QGCCompression::isCompressionFormat | ( | Format | format | ) |
Check if format is a compression format (single stream)
Definition at line 522 of file QGCCompression.cc.
References isCompressionFormat().
Referenced by decompressData(), decompressFile(), isCompressedFile(), isCompressionFormat(), looksLikeCompressedData(), and strippedPath().
| bool QGCCompression::isDataCompressed | ( | const QByteArray & | data | ) |
Check if data has the compressed framing header.
Definition at line 994 of file QGCCompression.cc.
References isDataCompressed(), and kHeaderCompressed.
Referenced by isDataCompressed().
| int QGCCompression::lastCompressionRatio | ( | ) |
Compression ratio from the last compressData() call (thread-local, percentage of original size).
Definition at line 999 of file QGCCompression.cc.
References lastCompressionRatio(), and s_lastCompressionRatio.
Referenced by lastCompressionRatio().
| Error QGCCompression::lastError | ( | ) |
Get the error code from the last operation (thread-local)
Definition at line 152 of file QGCCompression.cc.
References lastError().
Referenced by lastError().
| QString QGCCompression::lastErrorString | ( | ) |
Get a human-readable error message from the last operation (thread-local)
Definition at line 157 of file QGCCompression.cc.
References errorName(), and lastErrorString().
Referenced by lastErrorString().
| QStringList QGCCompression::listArchive | ( | const QString & | archivePath, |
| Format | format = Format::Auto |
||
| ) |
List contents of an archive without extracting
| archivePath | Path to archive file (or Qt resource path :/) |
| format | Archive format (Auto = detect from archivePath) |
Definition at line 714 of file QGCCompression.cc.
References listArchive(), QGClibarchive::listArchiveEntries(), and validateArchiveInput().
Referenced by listArchive().
| QList< ArchiveEntry > QGCCompression::listArchiveDetailed | ( | const QString & | archivePath, |
| Format | format = Format::Auto |
||
| ) |
List contents of an archive with detailed metadata
| archivePath | Path to archive file (or Qt resource path :/) |
| format | Archive format (Auto = detect from archivePath) |
Definition at line 731 of file QGCCompression.cc.
References listArchiveDetailed(), QGClibarchive::listArchiveEntriesDetailed(), and validateArchiveInput().
Referenced by listArchiveDetailed().
| bool QGCCompression::looksLikeCompressedData | ( | const QByteArray & | data | ) |
Quick check whether data begins with a recognized compression magic (gzip / xz / zstd / bzip2 / lz4). Wraps detectFormatFromData + isCompressionFormat.
Definition at line 1063 of file QGCCompression.cc.
References detectFormatFromData(), isCompressionFormat(), and looksLikeCompressedData().
Referenced by looksLikeCompressedData(), and parseCompressedJson().
| QJsonDocument QGCCompression::parseCompressedJson | ( | const QByteArray & | data, |
| QJsonParseError * | error | ||
| ) |
Parse JSON from data that may be compressed. Auto-detects gzip/xz/zstd/bzip2/lz4.
Definition at line 1068 of file QGCCompression.cc.
References decompressData(), error, looksLikeCompressedData(), and parseCompressedJson().
Referenced by TerrainTileCopernicus::getJsonFromData(), JsonParsing::isJsonFile(), JsonParsing::openInternalQGCJsonFile(), and parseCompressedJson().
| QByteArray QGCCompression::readFile | ( | const QString & | filePath, |
| QString * | errorString, | ||
| qint64 | maxBytes | ||
| ) |
Read file contents, transparently decompressing .gz/.xz/.zst/.bz2/.lz4 files.
Definition at line 1004 of file QGCCompression.cc.
References QGCArchiveDeviceBase::close(), errorString, isCompressedFile(), QGCDecompressDevice::open(), readFile(), and QGCFileHelper::readFile().
Referenced by FirmwarePlugin::cacheParameterMetaDataFile(), JsonParsing::isJsonFile(), JsonParsing::openInternalQGCJsonFile(), readFile(), and ParameterMetaData::versionFromMetaDataFile().
| QString QGCCompression::strippedPath | ( | const QString & | filePath | ) |
Get path with compression extension stripped (.gz, .xz, .zst removed) Returns original path if not a compressed file format
Definition at line 536 of file QGCCompression.cc.
References detectFormat(), formatExtension(), isCompressionFormat(), and strippedPath().
Referenced by decompressIfNeeded(), and strippedPath().
| QByteArray QGCCompression::uncompress | ( | const QByteArray & | data | ) |
Decompress data using qUncompress (expects 4-byte size header + zlib payload).
| data | Compressed data in qCompress format |
Definition at line 917 of file QGCCompression.cc.
References uncompress().
Referenced by uncompress().
| QByteArray QGCCompression::uncompressData | ( | const QByteArray & | data, |
| qint64 | maxDecompressedSize = 64LL *1024 *1024 |
||
| ) |
Decompress data produced by compressData().
| data | Header byte + payload (as produced by compressData) |
| maxDecompressedSize | Maximum allowed decompressed size (0 = no limit) |
Definition at line 960 of file QGCCompression.cc.
References kHeaderCompressed, kHeaderUncompressed, and uncompressData().
Referenced by uncompressData().
| bool QGCCompression::validateArchive | ( | const QString & | archivePath, |
| Format | format = Format::Auto |
||
| ) |
Validate an archive's integrity without extracting
| archivePath | Path to archive file |
| format | Archive format (Auto = detect from archivePath) |
Definition at line 758 of file QGCCompression.cc.
References QGClibarchive::validateArchive(), validateArchive(), and validateArchiveInput().
Referenced by validateArchive().
|
static |
Validate archive input: file exists, format detected, and is archive format.
Definition at line 232 of file QGCCompression.cc.
References formatName, isArchiveFormat(), validateArchiveInput(), and validateFileInput().
Referenced by extractArchive(), extractArchiveAtomic(), extractArchiveFiltered(), extractByPattern(), extractFile(), extractFileData(), extractFiles(), fileExists(), getArchiveStats(), listArchive(), listArchiveDetailed(), validateArchive(), and validateArchiveInput().
|
static |
Validate device input for streaming operations.
Definition at line 246 of file QGCCompression.cc.
References validateDeviceInput().
Referenced by decompressFromDevice(), decompressFromDevice(), extractFileDataFromDevice(), extractFromDevice(), and validateDeviceInput().
|
static |
Validate file input: check existence and detect format
| filePath | Path to validate |
| format | Format to use/detect (modified if Auto) |
Definition at line 210 of file QGCCompression.cc.
References detectFormat(), QGCFileHelper::exists(), and validateFileInput().
Referenced by decompressFile(), validateArchiveInput(), and validateFileInput().
|
constexpr |
Default Unix permissions for extracted files (rw-r–r–)
Definition at line 28 of file QGCCompressionTypes.h.
|
staticconstexpr |
Definition at line 926 of file QGCCompression.cc.
Referenced by compressData(), isDataCompressed(), and uncompressData().
|
staticconstexpr |
Definition at line 925 of file QGCCompression.cc.
Referenced by compressData(), and uncompressData().
|
static |
Definition at line 928 of file QGCCompression.cc.
Referenced by compressData(), and lastCompressionRatio().