src/xz/io.h File Reference

I/O types and functions. More...


Data Structures

struct  file_pair

Defines

#define IO_BUFFER_SIZE   8192

Functions

void io_init (void)
 Initialize the I/O module.
file_pair * io_open (const char *src_name)
 Opens a file pair.
void io_close (file_pair *pair, bool success)
 Closes the file descriptors and frees possible allocated memory.
size_t io_read (file_pair *pair, uint8_t *buf, size_t size)
 Reads from the source file to a buffer.
bool io_write (const file_pair *pair, const uint8_t *buf, size_t size)
 Writes a buffer to the destination file.


Detailed Description

I/O types and functions.


Function Documentation

void io_init ( void   ) 

Initialize the I/O module.

file_pair* io_open ( const char *  src_name  ) 

void io_close ( file_pair *  pair,
bool  success 
)

Closes the file descriptors and frees possible allocated memory.

The success argument determines if source or destination file gets unlinked:

  • false: The destination file is unlinked.
  • true: The source file is unlinked unless writing to stdout or --keep was used.

References io_close_dest(), io_close_src(), io_copy_attrs(), signals_block(), and signals_unblock().

size_t io_read ( file_pair *  pair,
uint8_t *  buf,
size_t  size 
)

Reads from the source file to a buffer.

Parameters:
pair File pair having the source file open for reading
buf Destination buffer to hold the read data
size Size of the buffer; assumed be smaller than SSIZE_MAX
Returns:
On success, number of bytes read is returned. On end of file zero is returned and pair->src_eof set to true. On error, SIZE_MAX is returned and error message printed.

References user_abort.

bool io_write ( const file_pair *  pair,
const uint8_t *  buf,
size_t  size 
)

Writes a buffer to the destination file.

Parameters:
pair File pair having the destination file open for writing
buf Buffer containing the data to be written
size Size of the buffer; assumed be smaller than SSIZE_MAX
Returns:
On success, zero is returned. On error, -1 is returned and error message printed.

References user_abort.


Generated on Wed May 25 10:35:47 2011 for XZ Utils by  doxygen 1.5.5