Flipper Zero Firmware
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
57/* High-level API - assumes archive is open */
58
67bool tar_archive_unpack_to(
68 TarArchive* archive,
69 const char* destination,
70 Storage_name_converter converter);
71
81bool tar_archive_add_file(
82 TarArchive* archive,
83 const char* fs_file_path,
84 const char* archive_fname,
85 const int32_t file_size);
86
95bool tar_archive_add_dir(TarArchive* archive, const char* fs_full_path, const char* path_prefix);
96
103int32_t tar_archive_get_entries_count(TarArchive* archive);
104
113bool tar_archive_get_read_progress(TarArchive* archive, int32_t* processed, int32_t* total);
114
123bool tar_archive_unpack_file(
124 TarArchive* archive,
125 const char* archive_fname,
126 const char* destination);
127
134typedef bool (*tar_unpack_file_cb)(const char* name, bool is_directory, void* context);
135
141void tar_archive_set_file_callback(TarArchive* archive, tar_unpack_file_cb callback, void* context);
142
143/* Low-level API */
144
152bool tar_archive_dir_add_element(TarArchive* archive, const char* dirpath);
153
162bool tar_archive_file_add_header(TarArchive* archive, const char* path, const int32_t data_len);
163
172bool tar_archive_file_add_data_block(
173 TarArchive* archive,
174 const uint8_t* data_block,
175 const int32_t block_len);
176
183bool tar_archive_file_finalize(TarArchive* archive);
184
194bool tar_archive_store_data(
195 TarArchive* archive,
196 const char* path,
197 const uint8_t* data,
198 const int32_t data_len);
199
206bool tar_archive_finalize(TarArchive* archive);
207
208#ifdef __cplusplus
209}
210#endif
APIs for working with storages, directories and files.
Definition storage_i.h:23
Definition tar_archive.c:31