| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #ifndef ASSMPQ_MPQ_H_ | ||
| 2 | #define ASSMPQ_MPQ_H_ | ||
| 3 | |||
| 4 | #include <vector> | ||
| 5 | #include <filesystem> | ||
| 6 | #include <expected> | ||
| 7 | |||
| 8 | #include "assets_mpq_importer/mpq_library_export.hpp" | ||
| 9 | #include "assmpq.hpp" | ||
| 10 | |||
| 11 | namespace assmpq::mpq { | ||
| 12 | |||
| 13 | /// @brief Represents an entry for a file within an MPQ archive | ||
| 14 | /// @details Contains the filename and size information for a file stored in an MPQ archive | ||
| 15 | struct FileEntry { | ||
| 16 | 4 | std::string filename; | |
| 17 | 4 | std::streamsize size = 0; | |
| 18 | |||
| 19 |
2/4✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
|
12 | bool operator==(const FileEntry& other) const = default; |
| 20 | }; | ||
| 21 | |||
| 22 | using ArchiveEntries = std::vector<FileEntry>; | ||
| 23 | |||
| 24 | /** | ||
| 25 | * @brief Lists files in an MPQ archive | ||
| 26 | * @param archive_path Path to the MPQ archive file | ||
| 27 | * @param mask Optional filter mask for file names (default: "") | ||
| 28 | * @return Expected containing a vector of FileEntry objects or an error message | ||
| 29 | * @details Retrieves a list of files contained in the specified Blizzard MPQ archive. | ||
| 30 | * If a mask is provided, only files matching the mask will be returned. | ||
| 31 | */ | ||
| 32 | [[nodiscard]] MPQ_LIBRARY_EXPORT auto list_mpq_files(const std::filesystem::path& archive_path, const std::string& mask = "") | ||
| 33 | -> std::expected<ArchiveEntries, ErrorMessage>; | ||
| 34 | |||
| 35 | /** | ||
| 36 | * @brief Extracts a file from an MPQ archive | ||
| 37 | * @param archive_path Path to the MPQ archive file | ||
| 38 | * @param filename Name of the file to extract from the archive | ||
| 39 | * @return Expected containing the file data as a byte vector or an error message | ||
| 40 | * @details Extracts the specified file from the Blizzard MPQ archive and returns its contents | ||
| 41 | * as a vector of bytes. If extraction fails, an error message is returned. | ||
| 42 | */ | ||
| 43 | [[nodiscard]] MPQ_LIBRARY_EXPORT auto extract_mpq_file(const std::filesystem::path& archive_path, const std::string& filename) | ||
| 44 | -> std::expected<FileData, ErrorMessage>; | ||
| 45 | |||
| 46 | } // namespace assmpq::mpq | ||
| 47 | |||
| 48 | #endif /// ASSMPQ_MPQ_H_ | ||
| 49 |