libsqsh v1.5.1
Loading...
Searching...
No Matches
read_file.c
Go to the documentation of this file.
1
9#include <assert.h>
10#include <sqsh.h>
11#include <stdio.h>
12#include <stdlib.h>
13
14int
15main(int argc, char *argv[]) {
16 if (argc != 3) {
17 printf("Usage: %s <sqsh-file> <path>\n", argv[0]);
18 return 1;
19 }
20 struct SqshArchive *archive = sqsh_archive_open(argv[1], NULL, NULL);
21 assert(archive != NULL);
22
23 uint8_t *content = sqsh_easy_file_content(archive, argv[2], NULL);
24 assert(content != NULL);
25 size_t size = sqsh_easy_file_size2(archive, argv[2], NULL);
26
27 fwrite(content, size, 1, stdout);
28
29 free(content);
30 sqsh_archive_close(archive);
31 return 0;
32}
int main(int argc, char *argv[])
Definition read_file.c:15
uint64_t sqsh_easy_file_size2(struct SqshArchive *archive, const char *path, int *err)
retrieves the size of a file.
uint8_t * sqsh_easy_file_content(struct SqshArchive *archive, const char *path, int *err)
retrieves the content of a file.
SQSH_NO_UNUSED struct SqshArchive * sqsh_archive_open(const void *source, const struct SqshConfig *config, int *err)
initializes a archive context in heap.
int sqsh_archive_close(struct SqshArchive *archive)
Frees the resources used by a Sqsh instance.