From 411f659fe0140bacbd56f8503cda269816d4a887 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Sat, 7 Nov 2020 16:04:40 +0100 Subject: Cleanup: libcommon: try to split up some of the larger files The sqsf_writer is moved to a separate header, as well as the compressor related stuff. The statistics function is moved into the writer code, as this is the only place that actually uses it. The writer code itself is split up into a hand full of file in their own subdirectory. Signed-off-by: David Oberhollenzer --- lib/common/writer/cleanup.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 lib/common/writer/cleanup.c (limited to 'lib/common/writer/cleanup.c') diff --git a/lib/common/writer/cleanup.c b/lib/common/writer/cleanup.c new file mode 100644 index 0000000..16e846b --- /dev/null +++ b/lib/common/writer/cleanup.c @@ -0,0 +1,40 @@ +/* SPDX-License-Identifier: GPL-3.0-or-later */ +/* + * cleanup.c + * + * Copyright (C) 2019 David Oberhollenzer + */ +#include "simple_writer.h" + +#include + +void sqfs_writer_cleanup(sqfs_writer_t *sqfs, int status) +{ + if (sqfs->xwr != NULL) + sqfs_destroy(sqfs->xwr); + + sqfs_destroy(sqfs->dirwr); + sqfs_destroy(sqfs->dm); + sqfs_destroy(sqfs->im); + sqfs_destroy(sqfs->idtbl); + sqfs_destroy(sqfs->data); + sqfs_destroy(sqfs->blkwr); + sqfs_destroy(sqfs->fragtbl); + sqfs_destroy(sqfs->cmp); + fstree_cleanup(&sqfs->fs); + sqfs_destroy(sqfs->outfile); + + if (status != EXIT_SUCCESS) { +#if defined(_WIN32) || defined(__WINDOWS__) + WCHAR *path = path_to_windows(sqfs->filename); + + if (path != NULL) + DeleteFileW(path); + + free(path); +#else + unlink(sqfs->filename); +#endif + } +} + -- cgit v1.2.3