Parolin 0.7.9 6796
Console (soon DLLs) to do a tar like job
Loading...
Searching...
No Matches
file_io.h
Go to the documentation of this file.
1
2//
5//
6// Author: Lasse Collin
7//
8// This file has been put into the public domain.
9// You can do whatever you want with this file.
10//
12
13// Some systems have suboptimal BUFSIZ. Use a bit bigger value on them.
14// We also need that IO_BUFFER_SIZE is a multiple of 8 (sizeof(uint64_t))
15#if BUFSIZ <= 1024
16# define IO_BUFFER_SIZE 8192
17#else
18# define IO_BUFFER_SIZE (BUFSIZ & ~7U)
19#endif
20
21
27typedef union {
29 uint32_t u32[IO_BUFFER_SIZE / sizeof(uint32_t)];
30 uint64_t u64[IO_BUFFER_SIZE / sizeof(uint64_t)];
31} io_buf;
32
33
34typedef struct {
37 const char *src_name;
38
41 char *dest_name;
42
44 int src_fd;
45
48
50 bool src_eof;
51
55
58
62
67
69 struct stat src_st;
70
72 struct stat dest_st;
73
74} file_pair;
75
76
78extern void io_init(void);
79
80
81#ifndef TUKLIB_DOSLIKE
85extern void io_write_to_user_abort_pipe(void);
86#endif
87
88
90extern void io_no_sparse(void);
91
92
93#ifdef ENABLE_SANDBOX
95extern void io_allow_sandbox(void);
96#endif
97
98
100extern file_pair *io_open_src(const char *src_name);
101
102
104extern bool io_open_dest(file_pair *pair);
105
106
114extern void io_close(file_pair *pair, bool success);
115
116
126extern size_t io_read(file_pair *pair, io_buf *buf, size_t size);
127
128
139extern void io_fix_src_pos(file_pair *pair, size_t rewind_size);
140
141
152extern bool io_seek_src(file_pair *pair, uint64_t pos);
153
154
168extern bool io_pread(file_pair *pair, io_buf *buf, size_t size, uint64_t pos);
169
170
179extern bool io_write(file_pair *pair, const io_buf *buf, size_t size);
char buf[N_BUF]
Definition spewG.c:36
Definition file_io.h:34
int dest_fd
File descriptor of the target file.
Definition file_io.h:47
off_t dest_pending_sparse
Definition file_io.h:66
bool dest_try_sparse
Definition file_io.h:61
bool flush_needed
For –flush-timeout: True when flushing is needed.
Definition file_io.h:57
const char * src_name
Definition file_io.h:37
bool src_eof
True once end of the source file has been detected.
Definition file_io.h:50
char * dest_name
Definition file_io.h:41
int src_fd
File descriptor of the source file.
Definition file_io.h:44
bool src_has_seen_input
Definition file_io.h:54
Definition file_io.h:27
size_t size
Definition platform.h:559
void io_no_sparse(void)
Disable creation of sparse files when decompressing.
Definition file_io.c:151
file_pair * io_open_src(const char *src_name)
Open the source file.
Definition file_io.c:760
void io_write_to_user_abort_pipe(void)
Write a byte to user_abort_pipe[1].
Definition file_io.c:135
bool io_pread(file_pair *pair, io_buf *buf, size_t size, uint64_t pos)
Read from source file from given offset to a buffer.
Definition file_io.c:1234
bool io_write(file_pair *pair, const io_buf *buf, size_t size)
Writes a buffer to the destination file.
Definition file_io.c:1320
void io_init(void)
Initialize the I/O module.
Definition file_io.c:95
bool io_open_dest(file_pair *pair)
Open the destination file.
Definition file_io.c:1016
void io_close(file_pair *pair, bool success)
Closes the file descriptors and frees possible allocated memory.
Definition file_io.c:1077
void io_fix_src_pos(file_pair *pair, size_t rewind_size)
Fix the position in src_fd.
Definition file_io.c:1126
bool io_seek_src(file_pair *pair, uint64_t pos)
Seek to the given absolute position in the source file.
Definition file_io.c:1211
#define IO_BUFFER_SIZE
Definition file_io.h:16
size_t io_read(file_pair *pair, io_buf *buf, size_t size)
Reads from the source file to a buffer.
Definition file_io.c:1141
unsigned char u8
Definition harness.c:16
uint64_t u64
Definition zstd_decompress.c:63
uint32_t u32
Definition zstd_decompress.c:62