summaryrefslogtreecommitdiff
path: root/lib/sqfshelper/data_writer.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-10-07 13:54:24 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-10-07 13:54:24 +0200
commit1fad07ce86fc2a506c59501d7fb7c7d7481525f6 (patch)
tree6ba41c514e2ddc692cb95a0fb2070dd222897c7c /lib/sqfshelper/data_writer.c
parent5597dca9c6053cd19104e18d88edb199b32e3743 (diff)
Rename libsqfshelper to libcommon
That is IMO less confusing and express what it is (i.e. what it has become) more clearly, i.e. common code shared by the utilities. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/sqfshelper/data_writer.c')
-rw-r--r--lib/sqfshelper/data_writer.c55
1 files changed, 0 insertions, 55 deletions
diff --git a/lib/sqfshelper/data_writer.c b/lib/sqfshelper/data_writer.c
deleted file mode 100644
index 36de154..0000000
--- a/lib/sqfshelper/data_writer.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/* SPDX-License-Identifier: GPL-3.0-or-later */
-/*
- * data_writer.c
- *
- * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
- */
-#include "common.h"
-#include "util.h"
-
-static sqfs_u8 buffer[4096];
-
-int write_data_from_file(const char *filename, sqfs_data_writer_t *data,
- sqfs_inode_generic_t *inode, sqfs_file_t *file,
- int flags)
-{
- sqfs_u64 filesz, offset;
- size_t diff;
- int ret;
-
- ret = sqfs_data_writer_begin_file(data, inode, flags);
- if (ret) {
- sqfs_perror(filename, "beginning file data blocks", ret);
- return -1;
- }
-
- sqfs_inode_get_file_size(inode, &filesz);
-
- for (offset = 0; offset < filesz; offset += diff) {
- if (filesz - offset > sizeof(buffer)) {
- diff = sizeof(buffer);
- } else {
- diff = filesz - offset;
- }
-
- ret = file->read_at(file, offset, buffer, diff);
- if (ret) {
- sqfs_perror(filename, "reading file range", ret);
- return -1;
- }
-
- ret = sqfs_data_writer_append(data, buffer, diff);
- if (ret) {
- sqfs_perror(filename, "packing file data", ret);
- return -1;
- }
- }
-
- ret = sqfs_data_writer_end_file(data);
- if (ret) {
- sqfs_perror(filename, "finishing file data", ret);
- return -1;
- }
-
- return 0;
-}