libropkg: convert pkg writer to use bluelib compression streams
This commit is contained in:
@@ -1,53 +0,0 @@
|
||||
#ifndef ROPKG_COMPRESS_H_
|
||||
#define ROPKG_COMPRESS_H_
|
||||
|
||||
#include <ropkg/misc.h>
|
||||
#include <ropkg/status.h>
|
||||
#include <stddef.h>
|
||||
|
||||
struct ropkg_compression_function;
|
||||
struct ropkg_compression_stream;
|
||||
|
||||
enum ropkg_compression_stream_mode {
|
||||
ROPKG_COMPRESSION_MODE_COMPRESS = 0,
|
||||
ROPKG_COMPRESSION_MODE_DECOMPRESS,
|
||||
};
|
||||
|
||||
enum ropkg_compression_stream_op {
|
||||
ROPKG_COMPRESSION_OP_CONTINUE = 0,
|
||||
ROPKG_COMPRESSION_OP_END,
|
||||
};
|
||||
|
||||
enum ropkg_compression_type {
|
||||
ROPKG_COMPRESSION_NONE = 0,
|
||||
ROPKG_COMPRESSION_ZSTD,
|
||||
};
|
||||
|
||||
ROPKG_API const struct ropkg_compression_function *
|
||||
ropkg_compression_function_for_type(enum ropkg_compression_type type);
|
||||
|
||||
ROPKG_API enum ropkg_status ropkg_compression_function_get_buffer_size(
|
||||
const struct ropkg_compression_function *func,
|
||||
enum ropkg_compression_stream_mode mode,
|
||||
size_t *in_buffer_size,
|
||||
size_t *out_buffer_size);
|
||||
ROPKG_API const char *ropkg_compression_function_get_file_extension(
|
||||
const struct ropkg_compression_function *func);
|
||||
|
||||
ROPKG_API enum ropkg_status ropkg_compression_stream_open(
|
||||
const struct ropkg_compression_function *func,
|
||||
void *in_buffer,
|
||||
size_t in_max,
|
||||
void *out_buffer,
|
||||
size_t out_max,
|
||||
enum ropkg_compression_stream_mode mode,
|
||||
struct ropkg_compression_stream **out);
|
||||
ROPKG_API enum ropkg_status ropkg_compression_stream_process(
|
||||
struct ropkg_compression_stream *stream,
|
||||
size_t in_size,
|
||||
enum ropkg_compression_stream_op op,
|
||||
size_t *out_size);
|
||||
ROPKG_API enum ropkg_status ropkg_compression_stream_close(
|
||||
struct ropkg_compression_stream *stream);
|
||||
|
||||
#endif
|
||||
@@ -1,58 +0,0 @@
|
||||
#ifndef ROPKG_STREAM_H_
|
||||
#define ROPKG_STREAM_H_
|
||||
|
||||
#include <ropkg/misc.h>
|
||||
#include <ropkg/status.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
|
||||
struct ropkg_stream;
|
||||
struct ropkg_compression_function;
|
||||
|
||||
enum ropkg_stream_mode {
|
||||
ROPKG_STREAM_READ,
|
||||
ROPKG_STREAM_WRITE,
|
||||
};
|
||||
|
||||
ROPKG_API enum ropkg_status ropkg_stream_open(
|
||||
FILE *fp,
|
||||
const struct ropkg_compression_function *func,
|
||||
enum ropkg_stream_mode mode,
|
||||
struct ropkg_stream **out);
|
||||
ROPKG_API enum ropkg_status ropkg_stream_close(struct ropkg_stream *stream);
|
||||
|
||||
ROPKG_API enum ropkg_status ropkg_stream_begin_compressed_section(
|
||||
struct ropkg_stream *stream);
|
||||
ROPKG_API enum ropkg_status ropkg_stream_end_compressed_section(
|
||||
struct ropkg_stream *stream,
|
||||
size_t *out_nr_written_compressed,
|
||||
size_t *out_nr_written_uncompressed);
|
||||
|
||||
ROPKG_API enum ropkg_status ropkg_stream_read(
|
||||
struct ropkg_stream *stream,
|
||||
void *p,
|
||||
size_t len,
|
||||
size_t *nr_read);
|
||||
ROPKG_API enum ropkg_status ropkg_stream_write(
|
||||
struct ropkg_stream *stream,
|
||||
const void *p,
|
||||
size_t len,
|
||||
size_t *nr_written);
|
||||
|
||||
ROPKG_API size_t ropkg_stream_get_cursor_position(struct ropkg_stream *stream);
|
||||
ROPKG_API enum ropkg_status ropkg_stream_set_cursor_position(
|
||||
struct ropkg_stream *stream,
|
||||
size_t pos);
|
||||
ROPKG_API enum ropkg_status ropkg_stream_restore_cursor_position(
|
||||
struct ropkg_stream *stream);
|
||||
|
||||
ROPKG_API bool ropkg_stream_is_in_compressed_section(
|
||||
struct ropkg_stream *stream);
|
||||
|
||||
ROPKG_API size_t ropkg_stream_get_nr_written(struct ropkg_stream *stream);
|
||||
ROPKG_API size_t
|
||||
ropkg_stream_get_nr_written_compressed(struct ropkg_stream *stream);
|
||||
ROPKG_API size_t
|
||||
ropkg_stream_get_nr_written_uncompressed(struct ropkg_stream *stream);
|
||||
|
||||
#endif
|
||||
@@ -10,14 +10,14 @@
|
||||
#define ROPKG_PATH_META "meta.tar"
|
||||
|
||||
struct ropkg_writer;
|
||||
struct ropkg_stream;
|
||||
struct b_cstream;
|
||||
|
||||
struct ropkg_writer_file_info {
|
||||
size_t f_length;
|
||||
};
|
||||
|
||||
ROPKG_API enum ropkg_status ropkg_writer_open(
|
||||
struct ropkg_stream *fp,
|
||||
struct b_cstream *fp,
|
||||
struct ropkg_writer **out);
|
||||
ROPKG_API enum ropkg_status ropkg_writer_close(struct ropkg_writer *pkg);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user