-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathreadme_example.c
More file actions
35 lines (29 loc) · 788 Bytes
/
readme_example.c
File metadata and controls
35 lines (29 loc) · 788 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/**
* @author Enno Boland (mail@eboland.de)
* @file readme_example.c
*/
#include <assert.h>
#include <sqsh.h>
#include <stdio.h>
#include <stdlib.h>
int
main(int argc, char *argv[]) {
(void)argc;
(void)argv;
struct SqshArchive *archive =
sqsh_archive_open("/path/to/archive.squashfs", NULL, NULL);
assert(archive != NULL);
uint8_t *contents = sqsh_easy_file_content(archive, "/path/to/file", NULL);
assert(contents != NULL);
const size_t size = sqsh_easy_file_size2(archive, "/path/to/file", NULL);
fwrite(contents, 1, size, stdout);
free(contents);
char **files = sqsh_easy_directory_list(archive, "/path/to/dir", NULL);
assert(files != NULL);
for (int i = 0; files[i] != NULL; i++) {
puts(files[i]);
}
free(files);
sqsh_archive_close(archive);
return 0;
}