From cdccc69c62579b0c13b35fad0728079652b8f3c9 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Tue, 31 Jan 2023 11:21:30 +0100 Subject: Move library source into src sub-directory Signed-off-by: David Oberhollenzer --- bin/sqfsdiff/extract.c | 58 -------------------------------------------------- 1 file changed, 58 deletions(-) delete mode 100644 bin/sqfsdiff/extract.c (limited to 'bin/sqfsdiff/extract.c') diff --git a/bin/sqfsdiff/extract.c b/bin/sqfsdiff/extract.c deleted file mode 100644 index f2072d4..0000000 --- a/bin/sqfsdiff/extract.c +++ /dev/null @@ -1,58 +0,0 @@ -/* SPDX-License-Identifier: GPL-3.0-or-later */ -/* - * extract.c - * - * Copyright (C) 2019 David Oberhollenzer - */ -#include "sqfsdiff.h" - -static int extract(sqfs_data_reader_t *data, const sqfs_inode_generic_t *inode, - const char *prefix, const char *path, size_t block_size) -{ - char *ptr, *temp; - ostream_t *fp; - - temp = alloca(strlen(prefix) + strlen(path) + 2); - sprintf(temp, "%s/%s", prefix, path); - - ptr = strrchr(temp, '/'); - *ptr = '\0'; - if (mkdir_p(temp)) - return -1; - *ptr = '/'; - - fp = ostream_open_file(temp, OSTREAM_OPEN_OVERWRITE | - OSTREAM_OPEN_SPARSE); - if (fp == NULL) { - perror(temp); - return -1; - } - - if (sqfs_data_reader_dump(path, data, inode, fp, block_size)) { - sqfs_drop(fp); - return -1; - } - - ostream_flush(fp); - sqfs_drop(fp); - return 0; -} - -int extract_files(sqfsdiff_t *sd, const sqfs_inode_generic_t *old, - const sqfs_inode_generic_t *new, - const char *path) -{ - if (old != NULL) { - if (extract(sd->sqfs_old.data, old, "old", - path, sd->sqfs_old.super.block_size)) - return -1; - } - - if (new != NULL) { - if (extract(sd->sqfs_new.data, new, "new", - path, sd->sqfs_new.super.block_size)) - return -1; - } - - return 0; -} -- cgit v1.2.3