2022-09-28 20:13:12 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <storage/storage.h>
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
ResourceManifestEntryTypeUnknown = 0,
|
2023-01-06 09:31:17 +03:00
|
|
|
ResourceManifestEntryTypeVersion,
|
|
|
|
ResourceManifestEntryTypeTimestamp,
|
2022-09-28 20:13:12 +03:00
|
|
|
ResourceManifestEntryTypeDirectory,
|
|
|
|
ResourceManifestEntryTypeFile,
|
|
|
|
} ResourceManifestEntryType;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
ResourceManifestEntryType type;
|
2022-10-05 18:15:23 +03:00
|
|
|
FuriString* name;
|
2022-09-28 20:13:12 +03:00
|
|
|
uint32_t size;
|
|
|
|
uint8_t hash[16];
|
|
|
|
} ResourceManifestEntry;
|
|
|
|
|
|
|
|
typedef struct ResourceManifestReader ResourceManifestReader;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Initialize resource manifest reader
|
|
|
|
* @param storage Storage API pointer
|
|
|
|
* @return allocated object
|
|
|
|
*/
|
|
|
|
ResourceManifestReader* resource_manifest_reader_alloc(Storage* storage);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Release resource manifest reader
|
|
|
|
* @param resource_manifest allocated object
|
|
|
|
*/
|
|
|
|
void resource_manifest_reader_free(ResourceManifestReader* resource_manifest);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Initialize resource manifest reader iteration
|
|
|
|
* @param resource_manifest allocated object
|
|
|
|
* @param filename manifest file name
|
|
|
|
* @return true if file opened
|
|
|
|
*/
|
|
|
|
bool resource_manifest_reader_open(ResourceManifestReader* resource_manifest, const char* filename);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Read next file/dir entry from manifest
|
|
|
|
* @param resource_manifest allocated object
|
|
|
|
* @return entry or NULL if end of file
|
|
|
|
*/
|
|
|
|
ResourceManifestEntry* resource_manifest_reader_next(ResourceManifestReader* resource_manifest);
|
|
|
|
|
2023-01-06 09:31:17 +03:00
|
|
|
/** Read previous file/dir entry from manifest
|
|
|
|
*
|
|
|
|
* You must be at the end of the manifest to use this function.
|
|
|
|
* Intended to be used after reaching end with resource_manifest_reader_next
|
|
|
|
*
|
|
|
|
* @param resource_manifest Pointer to the ResourceManifestReader instance
|
|
|
|
*
|
|
|
|
* @return entry or NULL if end of file
|
|
|
|
*/
|
|
|
|
ResourceManifestEntry*
|
|
|
|
resource_manifest_reader_previous(ResourceManifestReader* resource_manifest);
|
|
|
|
|
2022-09-28 20:13:12 +03:00
|
|
|
#ifdef __cplusplus
|
|
|
|
} // extern "C"
|
|
|
|
#endif
|