slowly transitioning to a more efficient way of interacting with sealed packages

This commit is contained in:
Chris Punches
2025-04-06 19:42:17 -04:00
parent 7ebc3ebad3
commit 9b3c86aa93
13 changed files with 1090 additions and 6 deletions

View File

@@ -0,0 +1,43 @@
/**
* @file archive_reader.hpp
* @brief Functions for in-memory archive reading and verification
*/
#pragma once
#include <string>
#include <vector>
#include <map>
#include <archive.h>
#include <archive_entry.h>
#include <unistd.h>
#include <cstring>
#include <cstdlib>
#include <fcntl.h>
#include "checksums.hpp"
extern "C" {
/**
* Extracts a specific file from a package file (gzipped tarball)
*
* @param package_file_path Path to the package file (.dpm)
* @param file_path_in_archive Path of the file to extract within the archive
* @param data Pointer to buffer pointer - will be allocated by function
* @param data_size Pointer to size variable that will receive file size
* @return true on success, false on failure
*/
bool get_file_from_package_file(const char* package_file_path, const char* file_path_in_archive, unsigned char** data, size_t* data_size);
/**
* Extracts a specific file from an in-memory archive (gzipped tarball)
*
* @param archive_data Pointer to the archive data in memory
* @param archive_data_size Size of the archive data in memory
* @param file_path_in_archive Path of the file to extract within the archive
* @param result_data Pointer to buffer pointer - will be allocated by function
* @param result_data_size Pointer to size variable that will receive file size
* @return true on success, false on failure
*/
bool get_file_from_memory_loaded_archive(const unsigned char* archive_data, const size_t archive_data_size,
const char* file_path_in_archive,
unsigned char** result_data, size_t* result_data_size);
}