summaryrefslogtreecommitdiff
path: root/lib/sqfshelper/sqfs_reader.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sqfshelper/sqfs_reader.c')
-rw-r--r--lib/sqfshelper/sqfs_reader.c73
1 files changed, 0 insertions, 73 deletions
diff --git a/lib/sqfshelper/sqfs_reader.c b/lib/sqfshelper/sqfs_reader.c
deleted file mode 100644
index b947cf7..0000000
--- a/lib/sqfshelper/sqfs_reader.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/* SPDX-License-Identifier: GPL-3.0-or-later */
-/*
- * sqfs_reader.c
- *
- * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
- */
-#include "config.h"
-
-#include "highlevel.h"
-
-#include <string.h>
-#include <unistd.h>
-#include <fcntl.h>
-
-int sqfs_reader_open(sqfs_reader_t *rd, const char *filename)
-{
- sqfs_compressor_config_t cfg;
-
- memset(rd, 0, sizeof(*rd));
-
- rd->file = sqfs_open_file(filename, SQFS_FILE_OPEN_READ_ONLY);
- if (rd->file == NULL)
- return -1;
-
- if (sqfs_super_read(&rd->super, rd->file))
- goto fail_fd;
-
- if (!sqfs_compressor_exists(rd->super.compression_id)) {
- fprintf(stderr, "%s: unknown compressor used.\n", filename);
- goto fail_fd;
- }
-
- sqfs_compressor_config_init(&cfg, rd->super.compression_id,
- rd->super.block_size,
- SQFS_COMP_FLAG_UNCOMPRESS);
-
- rd->cmp = sqfs_compressor_create(&cfg);
- if (rd->cmp == NULL)
- goto fail_fd;
-
- if (rd->super.flags & SQFS_FLAG_COMPRESSOR_OPTIONS) {
- if (rd->cmp->read_options(rd->cmp, rd->file))
- goto fail_cmp;
- }
-
- if (deserialize_fstree(&rd->fs, &rd->super, rd->cmp, rd->file))
- goto fail_cmp;
-
- fstree_gen_file_list(&rd->fs);
-
- rd->data = data_reader_create(rd->file, &rd->super, rd->cmp);
- if (rd->data == NULL)
- goto fail_fs;
-
- return 0;
-fail_fs:
- fstree_cleanup(&rd->fs);
-fail_cmp:
- rd->cmp->destroy(rd->cmp);
-fail_fd:
- rd->file->destroy(rd->file);
- memset(rd, 0, sizeof(*rd));
- return -1;
-}
-
-void sqfs_reader_close(sqfs_reader_t *rd)
-{
- data_reader_destroy(rd->data);
- fstree_cleanup(&rd->fs);
- rd->cmp->destroy(rd->cmp);
- rd->file->destroy(rd->file);
- memset(rd, 0, sizeof(*rd));
-}