libsqsh v1.5.1
Loading...
Searching...
No Matches
list_dir.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 != 2) {
17 printf("Usage: %s <sqsh-file>\n", argv[0]);
18 return 1;
19 }
20 struct SqshArchive *archive = sqsh_archive_open(argv[1], NULL, NULL);
21 assert(archive != NULL);
22
23 char **dir_list = sqsh_easy_directory_list(archive, "/", NULL);
24 assert(dir_list != NULL);
25
26 for (int i = 0; dir_list[i] != NULL; i++) {
27 puts(dir_list[i]);
28 }
29
30 free(dir_list);
31 sqsh_archive_close(archive);
32 return 0;
33}
int main(int argc, char *argv[])
Definition list_dir.c:15
char ** sqsh_easy_directory_list(struct SqshArchive *archive, const char *path, int *err)
retrieves the contents of a directory as a list of file names
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.