mirror of
https://github.com/J-D-K/JKSV.git
synced 2026-09-08 18:45:14 -05:00
Add MiniZip wrapper
This commit is contained in:
@@ -9,4 +9,7 @@ namespace error
|
||||
|
||||
/// @brief Logs and returns if an fslib function fails.
|
||||
bool fslib(bool result, const std::source_location &location = std::source_location::current());
|
||||
|
||||
/// @brief Returns whether or not the pointer passed is null. Records the location in which this occurred.
|
||||
bool is_null(const void *pointer, const std::source_location &location = std::source_location::current());
|
||||
}
|
||||
|
||||
43
include/fs/MiniZip.hpp
Normal file
43
include/fs/MiniZip.hpp
Normal file
@@ -0,0 +1,43 @@
|
||||
#pragma once
|
||||
#include "fslib.hpp"
|
||||
|
||||
#include <minizip/zip.h>
|
||||
#include <string_view>
|
||||
|
||||
namespace fs
|
||||
{
|
||||
class MiniZip
|
||||
{
|
||||
public:
|
||||
MiniZip() = default;
|
||||
|
||||
/// @brief Constructor. Calls open upon construction;
|
||||
/// @param path
|
||||
MiniZip(const fslib::Path &path);
|
||||
|
||||
/// @brief Closes the zipFile.
|
||||
~MiniZip();
|
||||
|
||||
/// @brief Opens a Zip file at path
|
||||
bool open(const fslib::Path &path);
|
||||
|
||||
/// @brief Manual call for closing the zipFile.
|
||||
void close();
|
||||
|
||||
/// @brief Opens a new file with filename as the path.
|
||||
bool open_new_file(std::string_view filename, bool trimPath = false, size_t trimPlaces = 0);
|
||||
|
||||
/// @brief Closes the currently open file in the Zip.
|
||||
bool close_current_file();
|
||||
|
||||
/// @brief Attempts to write the buffer passed to the currently opened file.
|
||||
bool write(const void *buffer, size_t dataSize);
|
||||
|
||||
private:
|
||||
/// @brief Stores whether or not the zipFile was opened successfully.
|
||||
bool m_isOpen{};
|
||||
|
||||
/// @brief Underlying ZIP file.
|
||||
zipFile m_zip{};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user