mirror of
https://github.com/J-D-K/JKSV.git
synced 2026-03-22 01:34:13 -05:00
67 lines
1.9 KiB
C++
67 lines
1.9 KiB
C++
#pragma once
|
|
#include "fslib.hpp"
|
|
|
|
#include <minizip/unzip.h>
|
|
#include <string_view>
|
|
|
|
namespace fs
|
|
{
|
|
class MiniUnzip final
|
|
{
|
|
public:
|
|
MiniUnzip() = default;
|
|
|
|
/// @brief Constructor that c
|
|
MiniUnzip(const fslib::Path &path);
|
|
|
|
/// @brief Closes the unzFile.
|
|
~MiniUnzip();
|
|
|
|
/// @brief Returns whether or not the unzFile was successfully opened.
|
|
bool is_open() const;
|
|
|
|
/// @brief Attempts to open the path passed as a ZIP file.
|
|
bool open(const fslib::Path &path);
|
|
|
|
/// @brief Closes the unzfile.
|
|
void close();
|
|
|
|
/// @brief Attempts to go to the next file. Returns false at the end.
|
|
bool next_file();
|
|
|
|
/// @brief Closes the currently open file.
|
|
bool close_current_file();
|
|
|
|
/// @brief Attempts to locate a file with filename in the ZIP.
|
|
bool locate_file(std::string_view filename);
|
|
|
|
/// @brief Resets to the beginning file.
|
|
bool reset();
|
|
|
|
/// @brief Reads from the currently open file to the buffer passed.
|
|
ssize_t read(void *buffer, size_t bufferSize);
|
|
|
|
/// @brief Returns the name of the current file.
|
|
const char *get_filename();
|
|
|
|
/// @brief Returns the compressed size of the currently open file.
|
|
uint64_t get_compressed_size() const;
|
|
|
|
/// @brief Returns the uncompressed size of the the currently open file.
|
|
uint64_t get_uncompressed_size() const;
|
|
|
|
private:
|
|
/// @brief Underlying unzFile.
|
|
unzFile m_unz{};
|
|
|
|
/// @brief Saves whether or not opening the file was successful.
|
|
bool m_isOpen{};
|
|
|
|
/// @brief Info for the current file.
|
|
unz_file_info64 m_fileInfo{};
|
|
|
|
/// @brief Buffer containing the current file's name.
|
|
char m_filename[FS_MAX_PATH]{};
|
|
};
|
|
}
|