meta: replace bluelib with fx
This commit is contained in:
+24
-24
@@ -1,12 +1,12 @@
|
||||
#include "tar.h"
|
||||
|
||||
#include <blue/compress/cstream.h>
|
||||
#include <fx/compression/cstream.h>
|
||||
#include <ropkg/writer.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
struct ropkg_writer {
|
||||
b_cstream *w_fp;
|
||||
fx_cstream *w_fp;
|
||||
|
||||
struct ustar_header w_file_header;
|
||||
size_t w_file_header_offset;
|
||||
@@ -15,7 +15,7 @@ struct ropkg_writer {
|
||||
|
||||
static const char zero_padding[512] = {0};
|
||||
|
||||
enum ropkg_status ropkg_writer_open(b_cstream *fp, struct ropkg_writer **out)
|
||||
enum ropkg_status ropkg_writer_open(fx_cstream *fp, struct ropkg_writer **out)
|
||||
{
|
||||
struct ropkg_writer *writer = malloc(sizeof *writer);
|
||||
if (!writer) {
|
||||
@@ -35,23 +35,23 @@ enum ropkg_status ropkg_writer_close(struct ropkg_writer *pkg)
|
||||
memset(&pkg->w_file_header, 0x0, sizeof pkg->w_file_header);
|
||||
|
||||
size_t nr_written;
|
||||
b_status status = b_cstream_write(
|
||||
fx_status status = fx_cstream_write(
|
||||
pkg->w_fp,
|
||||
&pkg->w_file_header,
|
||||
sizeof pkg->w_file_header,
|
||||
&nr_written);
|
||||
|
||||
if (!B_OK(status)) {
|
||||
if (!FX_OK(status)) {
|
||||
return ROPKG_ERR_IO_FAILURE;
|
||||
}
|
||||
|
||||
status = b_cstream_write(
|
||||
status = fx_cstream_write(
|
||||
pkg->w_fp,
|
||||
&pkg->w_file_header,
|
||||
sizeof pkg->w_file_header,
|
||||
&nr_written);
|
||||
|
||||
if (!B_OK(status)) {
|
||||
if (!FX_OK(status)) {
|
||||
return ROPKG_ERR_IO_FAILURE;
|
||||
}
|
||||
|
||||
@@ -108,12 +108,12 @@ enum ropkg_status ropkg_writer_begin_file(
|
||||
const char *path,
|
||||
const struct ropkg_writer_file_info *info)
|
||||
{
|
||||
if (b_cstream_in_compressed_section(pkg->w_fp)) {
|
||||
b_cstream_tx_bytes_uncompressed(
|
||||
if (fx_cstream_in_compressed_section(pkg->w_fp)) {
|
||||
fx_cstream_tx_bytes_uncompressed(
|
||||
pkg->w_fp,
|
||||
&pkg->w_file_header_offset);
|
||||
} else {
|
||||
b_cstream_tx_bytes(pkg->w_fp, &pkg->w_file_header_offset);
|
||||
fx_cstream_tx_bytes(pkg->w_fp, &pkg->w_file_header_offset);
|
||||
}
|
||||
|
||||
enum ropkg_status status
|
||||
@@ -123,13 +123,13 @@ enum ropkg_status ropkg_writer_begin_file(
|
||||
}
|
||||
|
||||
size_t nr_written;
|
||||
b_status status2 = b_cstream_write(
|
||||
fx_status status2 = fx_cstream_write(
|
||||
pkg->w_fp,
|
||||
&pkg->w_file_header,
|
||||
sizeof pkg->w_file_header,
|
||||
&nr_written);
|
||||
|
||||
if (!B_OK(status2)) {
|
||||
if (!FX_OK(status2)) {
|
||||
return ROPKG_ERR_IO_FAILURE;
|
||||
}
|
||||
|
||||
@@ -142,25 +142,25 @@ enum ropkg_status ropkg_writer_begin_file(
|
||||
|
||||
enum ropkg_status ropkg_writer_end_file(struct ropkg_writer *pkg)
|
||||
{
|
||||
b_status status;
|
||||
fx_status status;
|
||||
size_t written, file_length, pos;
|
||||
if (b_cstream_in_compressed_section(pkg->w_fp)) {
|
||||
b_cstream_tx_bytes_uncompressed(pkg->w_fp, &pos);
|
||||
if (fx_cstream_in_compressed_section(pkg->w_fp)) {
|
||||
fx_cstream_tx_bytes_uncompressed(pkg->w_fp, &pos);
|
||||
} else {
|
||||
b_cstream_tx_bytes(pkg->w_fp, &pos);
|
||||
fx_cstream_tx_bytes(pkg->w_fp, &pos);
|
||||
}
|
||||
|
||||
file_length
|
||||
= pos - pkg->w_file_header_offset - sizeof pkg->w_file_header;
|
||||
|
||||
size_t required_padding = 512 - (file_length % 512);
|
||||
status = b_cstream_write(
|
||||
status = fx_cstream_write(
|
||||
pkg->w_fp,
|
||||
zero_padding,
|
||||
required_padding,
|
||||
&written);
|
||||
|
||||
if (!B_OK(status)) {
|
||||
if (!FX_OK(status)) {
|
||||
return ROPKG_ERR_IO_FAILURE;
|
||||
}
|
||||
|
||||
@@ -170,16 +170,16 @@ enum ropkg_status ropkg_writer_end_file(struct ropkg_writer *pkg)
|
||||
sizeof pkg->w_file_header.tar_filesize);
|
||||
refresh_header_checksum(&pkg->w_file_header);
|
||||
|
||||
status = b_cstream_set_cursor_position(
|
||||
status = fx_cstream_set_cursor_position(
|
||||
pkg->w_fp,
|
||||
pkg->w_file_header_offset);
|
||||
if (B_OK(status)) {
|
||||
b_cstream_write(
|
||||
if (FX_OK(status)) {
|
||||
fx_cstream_write(
|
||||
pkg->w_fp,
|
||||
&pkg->w_file_header,
|
||||
sizeof pkg->w_file_header,
|
||||
&written);
|
||||
b_cstream_restore_cursor_position(pkg->w_fp);
|
||||
fx_cstream_restore_cursor_position(pkg->w_fp);
|
||||
}
|
||||
|
||||
return ROPKG_SUCCESS;
|
||||
@@ -191,8 +191,8 @@ enum ropkg_status ropkg_writer_write(
|
||||
size_t len,
|
||||
size_t *nr_written)
|
||||
{
|
||||
b_status status = b_cstream_write(pkg->w_fp, p, len, nr_written);
|
||||
if (!B_OK(status)) {
|
||||
fx_status status = fx_cstream_write(pkg->w_fp, p, len, nr_written);
|
||||
if (!FX_OK(status)) {
|
||||
return ROPKG_ERR_IO_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user