ECP-VELOC Components
User documentation for all components
shuffile_io.h File Reference

some I/O utilities More...

Go to the source code of this file.

Functions

Basic File I/O
mode_t shuffile_getmode (int read, int write, int execute)
 
int shuffile_open (const char *file, int flags,...)
 
int shuffile_close (const char *file, int fd)
 
int shuffile_file_lock_read (const char *file, int fd)
 
int shuffile_file_lock_write (const char *file, int fd)
 
int shuffile_file_unlock (const char *file, int fd)
 
int shuffile_open_with_lock (const char *file, int flags, mode_t mode)
 
int shuffile_close_with_unlock (const char *file, int fd)
 
int shuffile_lseek (const char *file, int fd, off_t pos, int whence)
 
ssize_t shuffile_read (const char *file, int fd, void *buf, size_t size)
 
ssize_t shuffile_write (const char *file, int fd, const void *buf, size_t size)
 
ssize_t shuffile_read_attempt (const char *file, int fd, void *buf, size_t size)
 
ssize_t shuffile_write_attempt (const char *file, int fd, const void *buf, size_t size)
 
ssize_t shuffile_read_line (const char *file, int fd, char *buf, size_t size)
 
ssize_t shuffile_writef (const char *file, int fd, const char *format,...)
 
int shuffile_read_pad_n (int n, const char **files, int *fds, char *buf, unsigned long count, unsigned long offset, unsigned long *filesizes)
 
int shuffile_write_pad_n (int n, const char **files, int *fds, char *buf, unsigned long count, unsigned long offset, unsigned long *filesizes)
 
int shuffile_stat (const char *file, struct stat *statbuf)
 
unsigned long shuffile_file_size (const char *file)
 
int shuffile_file_exists (const char *file)
 
int shuffile_file_is_readable (const char *file)
 
int shuffile_file_is_writeable (const char *file)
 
int shuffile_file_unlink (const char *file)
 
int shuffile_crc32 (const char *filename, uLong *crc)
 
Directory functions
int shuffile_mkdir (const char *dir, mode_t mode)
 
int shuffile_rmdir (const char *dir)
 
int shuffile_getcwd (char *buf, size_t size)
 
File Copy Functions
int shuffile_file_copy (const char *src_file, const char *dst_file, unsigned long buf_size, uLong *crc)
 
File compression functions
int shuffile_compress_in_place (const char *file_src, const char *file_dst, unsigned long block_size, int level)
 
int shuffile_uncompress_in_place (const char *file_src, const char *file_dst)
 
int shuffile_compress (const char *file_src, const char *file_dst, unsigned long block_size, int level)
 
int shuffile_uncompress (const char *file_src, const char *file_dst)
 

Function Documentation

◆ shuffile_close()

int shuffile_close ( const char *  file,
int  fd 
)

close file with an fsync

◆ shuffile_close_with_unlock()

int shuffile_close_with_unlock ( const char *  file,
int  fd 
)

unlocks the specified file descriptor and then closes the file

◆ shuffile_compress()

int shuffile_compress ( const char *  file_src,
const char *  file_dst,
unsigned long  block_size,
int  level 
)

compress the specified file using blocks of size block_size and store as file_dst

◆ shuffile_compress_in_place()

int shuffile_compress_in_place ( const char *  file_src,
const char *  file_dst,
unsigned long  block_size,
int  level 
)

compress the specified file using blocks of size block_size and store as file_dst

◆ shuffile_crc32()

int shuffile_crc32 ( const char *  filename,
uLong *  crc 
)

opens, reads, and computes the crc32 value for the given filename

◆ shuffile_file_copy()

int shuffile_file_copy ( const char *  src_file,
const char *  dst_file,
unsigned long  buf_size,
uLong *  crc 
)

◆ shuffile_file_exists()

int shuffile_file_exists ( const char *  file)

tests whether the file or directory exists

◆ shuffile_file_is_readable()

int shuffile_file_is_readable ( const char *  file)

tests whether the file or directory is readable

◆ shuffile_file_is_writeable()

int shuffile_file_is_writeable ( const char *  file)

tests whether the file or directory is writeable

◆ shuffile_file_lock_read()

int shuffile_file_lock_read ( const char *  file,
int  fd 
)

get and release file locks

◆ shuffile_file_lock_write()

int shuffile_file_lock_write ( const char *  file,
int  fd 
)

◆ shuffile_file_size()

unsigned long shuffile_file_size ( const char *  file)

given a filename, return number of bytes in file

◆ shuffile_file_unlink()

int shuffile_file_unlink ( const char *  file)

delete a file

◆ shuffile_file_unlock()

int shuffile_file_unlock ( const char *  file,
int  fd 
)

◆ shuffile_getcwd()

int shuffile_getcwd ( char *  buf,
size_t  size 
)

write current working directory to buf

◆ shuffile_getmode()

mode_t shuffile_getmode ( int  read,
int  write,
int  execute 
)

returns user's current mode as determine by his umask

◆ shuffile_lseek()

int shuffile_lseek ( const char *  file,
int  fd,
off_t  pos,
int  whence 
)

seek file descriptor to specified position

◆ shuffile_mkdir()

int shuffile_mkdir ( const char *  dir,
mode_t  mode 
)

recursively create directory and subdirectories

◆ shuffile_open()

int shuffile_open ( const char *  file,
int  flags,
  ... 
)

open file with specified flags and mode, retry open a few times on failure

◆ shuffile_open_with_lock()

int shuffile_open_with_lock ( const char *  file,
int  flags,
mode_t  mode 
)

opens specified file and waits on for an exclusive lock before returning the file descriptor

◆ shuffile_read()

ssize_t shuffile_read ( const char *  file,
int  fd,
void *  buf,
size_t  size 
)

reliable read from opened file descriptor (retries, if necessary, until hard error)

◆ shuffile_read_attempt()

ssize_t shuffile_read_attempt ( const char *  file,
int  fd,
void *  buf,
size_t  size 
)

make a good attempt to read from file (retries, if necessary, return error if fail)

◆ shuffile_read_line()

ssize_t shuffile_read_line ( const char *  file,
int  fd,
char *  buf,
size_t  size 
)

read line from file into buf with given size

◆ shuffile_read_pad_n()

int shuffile_read_pad_n ( int  n,
const char **  files,
int *  fds,
char *  buf,
unsigned long  count,
unsigned long  offset,
unsigned long *  filesizes 
)

logically concatenate n opened files and read count bytes from this logical file into buf starting from offset, pad with zero on end if missing data

◆ shuffile_rmdir()

int shuffile_rmdir ( const char *  dir)

remove directory

◆ shuffile_stat()

int shuffile_stat ( const char *  file,
struct stat *  statbuf 
)

given a filename, return stat info

◆ shuffile_uncompress()

int shuffile_uncompress ( const char *  file_src,
const char *  file_dst 
)

uncompress the specified file and store as file_dst

◆ shuffile_uncompress_in_place()

int shuffile_uncompress_in_place ( const char *  file_src,
const char *  file_dst 
)

uncompress the specified file and store as file_dst

◆ shuffile_write()

ssize_t shuffile_write ( const char *  file,
int  fd,
const void *  buf,
size_t  size 
)

reliable write to opened file descriptor (retries, if necessary, until hard error)

◆ shuffile_write_attempt()

ssize_t shuffile_write_attempt ( const char *  file,
int  fd,
const void *  buf,
size_t  size 
)

make a good attempt to write to file (retries, if necessary, return error if fail)

◆ shuffile_write_pad_n()

int shuffile_write_pad_n ( int  n,
const char **  files,
int *  fds,
char *  buf,
unsigned long  count,
unsigned long  offset,
unsigned long *  filesizes 
)

write to an array of open files with known filesizes and treat them as one single large file

◆ shuffile_writef()

ssize_t shuffile_writef ( const char *  file,
int  fd,
const char *  format,
  ... 
)

write a formatted string to specified file descriptor