68 lines
1.6 KiB
C
68 lines
1.6 KiB
C
/**
|
|
* Copyright (c) 2023 Dominic Masters
|
|
*
|
|
* This software is released under the MIT License.
|
|
* https://opensource.org/licenses/MIT
|
|
*/
|
|
|
|
#pragma once
|
|
#include "asset/asset.h"
|
|
#include <archive.h>
|
|
#include <archive_entry.h>
|
|
|
|
#define ASSET_BUFFER_SIZE 32768
|
|
#define ASSET_PATH_MAX 1024
|
|
|
|
extern FILE *ASSET_FILE;
|
|
extern struct archive *ASSET_ARCHIVE;
|
|
extern struct archive_entry *ASSET_ENTRY;
|
|
extern uint8_t ASSET_ARCHIVE_BUFFER[ASSET_BUFFER_SIZE];
|
|
extern char_t ASSET_PATH_CURRENT[ASSET_PATH_MAX];
|
|
|
|
/**
|
|
* Internal read method provided to libarchive api.
|
|
*
|
|
* @param archive The archive to read from.
|
|
* @param data The data to read into.
|
|
* @param buffer The buffer to read from.
|
|
* @return The amount of data read.
|
|
*/
|
|
ssize_t assetArchiveRead(
|
|
struct archive *archive,
|
|
void *data,
|
|
const void **buffer
|
|
);
|
|
|
|
/**
|
|
* Internal seek method provided to libarchive api.
|
|
*
|
|
* @param archive The archive to seek in.
|
|
* @param data The data to seek in.
|
|
* @param offset Offset bytes to seek.
|
|
* @param whence Relative to whence to seek.
|
|
* @return The new position.
|
|
*/
|
|
int64_t assetArchiveSeek(
|
|
struct archive *archive,
|
|
void *data,
|
|
int64_t offset,
|
|
int32_t whence
|
|
);
|
|
|
|
/**
|
|
* Internal open method provided to libarchive api.
|
|
*
|
|
* @param archive The archive to open.
|
|
* @param data The data to open.
|
|
* @return The result of the open.
|
|
*/
|
|
int32_t assetArchiveOpen(struct archive *a, void *data);
|
|
|
|
/**
|
|
* Internal close method provided to libarchive api.
|
|
*
|
|
* @param archive The archive to close.
|
|
* @param data The data to close.
|
|
* @return The result of the close.
|
|
*/
|
|
int32_t assetArchiveClose(struct archive *a, void *data); |