Loading...
Searching...
No Matches
tar_archive.h
1#pragma once
2
3#include <stdbool.h>
4#include <stdint.h>
5#include <storage/storage.h>
6
7#ifdef __cplusplus
8extern "C" {
9#endif
10
11typedef struct TarArchive TarArchive;
12
13typedef struct Storage Storage;
14
17typedef enum {
18 TarOpenModeRead = 'r',
19 TarOpenModeWrite = 'w',
20 /* read-only heatshrink compressed tar */
21 TarOpenModeReadHeatshrink = 'h',
22} TarOpenMode;
23
31TarOpenMode tar_archive_get_mode_for_path(const char* path);
32
39TarArchive* tar_archive_alloc(Storage* storage);
40
49bool tar_archive_open(TarArchive* archive, const char* path, TarOpenMode mode);
50
55void tar_archive_free(TarArchive* archive);
56
57typedef void (*TarArchiveNameConverter)(FuriString*);
58
59/* High-level API - assumes archive is open */
60
69bool tar_archive_unpack_to(
70 TarArchive* archive,
71 const char* destination,
72 TarArchiveNameConverter converter);
73
83bool tar_archive_add_file(
84 TarArchive* archive,
85 const char* fs_file_path,
86 const char* archive_fname,
87 const int32_t file_size);
88
97bool tar_archive_add_dir(TarArchive* archive, const char* fs_full_path, const char* path_prefix);
98
105int32_t tar_archive_get_entries_count(TarArchive* archive);
106
115bool tar_archive_get_read_progress(TarArchive* archive, int32_t* processed, int32_t* total);
116
125bool tar_archive_unpack_file(
126 TarArchive* archive,
127 const char* archive_fname,
128 const char* destination);
129
136typedef bool (*tar_unpack_file_cb)(const char* name, bool is_directory, void* context);
137
143void tar_archive_set_file_callback(TarArchive* archive, tar_unpack_file_cb callback, void* context);
144
145/* Low-level API */
146
154bool tar_archive_dir_add_element(TarArchive* archive, const char* dirpath);
155
164bool tar_archive_file_add_header(TarArchive* archive, const char* path, const int32_t data_len);
165
174bool tar_archive_file_add_data_block(
175 TarArchive* archive,
176 const uint8_t* data_block,
177 const int32_t block_len);
178
185bool tar_archive_file_finalize(TarArchive* archive);
186
196bool tar_archive_store_data(
197 TarArchive* archive,
198 const char* path,
199 const uint8_t* data,
200 const int32_t data_len);
201
208bool tar_archive_finalize(TarArchive* archive);
209
210#ifdef __cplusplus
211}
212#endif
APIs for working with storages, directories and files.
Definition string.c:4
Definition storage_i.h:23
Definition tar_archive.c:31