aboutsummaryrefslogtreecommitdiff
path: root/src/xz/file_io.h
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2010-01-24 22:46:11 +0200
committerLasse Collin <lasse.collin@tukaani.org>2010-01-24 22:46:11 +0200
commitdf254ce03be016e217b511e7acd5d493f9929ca5 (patch)
tree8f4b899baead57de436606aa37b0bd139909402f /src/xz/file_io.h
parentSet LC_NUMERIC=C when --robot is used. (diff)
downloadxz-df254ce03be016e217b511e7acd5d493f9929ca5.tar.xz
Add io_pread().
It will be used by --list.
Diffstat (limited to 'src/xz/file_io.h')
-rw-r--r--src/xz/file_io.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/xz/file_io.h b/src/xz/file_io.h
index 58bf7b5e..94d4c174 100644
--- a/src/xz/file_io.h
+++ b/src/xz/file_io.h
@@ -23,6 +23,7 @@
/// Use an union to make sure that the buffer is properly aligned.
typedef union {
uint8_t u8[IO_BUFFER_SIZE];
+ uint32_t u32[IO_BUFFER_SIZE / sizeof(uint32_t)];
uint64_t u64[IO_BUFFER_SIZE / sizeof(uint64_t)];
} io_buf;
@@ -97,6 +98,22 @@ extern void io_close(file_pair *pair, bool success);
extern size_t io_read(file_pair *pair, io_buf *buf, size_t size);
+/// \brief Read from source file from given offset to a buffer
+///
+/// This is remotely similar to standard pread(). This uses lseek() though,
+/// so the read offset is changed on each call.
+///
+/// \param pair Seekable source file
+/// \param buf Destination buffer
+/// \param size Amount of data to read
+/// \param pos Offset relative to the beginning of the file,
+/// from which the data should be read.
+///
+/// \return On success, false is returned. On error, error message
+/// is printed and true is returned.
+extern bool io_pread(file_pair *pair, io_buf *buf, size_t size, off_t pos);
+
+
/// \brief Writes a buffer to the destination file
///
/// \param pair File pair having the destination file open for writing