NVBIO
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Functions
hfile.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include "htslib/hfile.h"
#include "hfile_internal.h"
#include <sys/socket.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>

Go to the source code of this file.

Classes

struct  hFILE_fd
 
struct  hFILE_mem
 

Functions

hFILEhfile_init (size_t struct_size, const char *mode, size_t capacity)
 
void hfile_destroy (hFILE *fp)
 
int hgetc2 (hFILE *fp)
 
ssize_t hpeek (hFILE *fp, void *buffer, size_t nbytes)
 
ssize_t hread2 (hFILE *fp, void *destv, size_t nbytes, size_t nread)
 
int hflush (hFILE *fp)
 
int hputc2 (int c, hFILE *fp)
 
ssize_t hwrite2 (hFILE *fp, const void *srcv, size_t totalbytes, size_t ncopied)
 
int hputs2 (const char *text, size_t totalbytes, size_t ncopied, hFILE *fp)
 
off_t hseek (hFILE *fp, off_t offset, int whence)
 
int hclose (hFILE *fp)
 
void hclose_abruptly (hFILE *fp)
 
hFILEhdopen (int fd, const char *mode)
 
int hfile_oflags (const char *mode)
 
hFILEhopen (const char *fname, const char *mode)
 

Function Documentation

int hclose ( hFILE fp)

Flush (for output streams) and close the stream

Returns
0 if successful, or EOF (with errno set) if an error occurred.

Definition at line 269 of file hfile.c.

void hclose_abruptly ( hFILE fp)

Close the stream, without flushing or propagating errors For use while cleaning up after an error only. Preserves errno.

Definition at line 284 of file hfile.c.

hFILE* hdopen ( int  fd,
const char *  mode 
)

Associate a stream with an existing open file descriptor

Returns
An hFILE pointer, or NULL (with errno set) if an error occurred. For socket descriptors (on Windows), mode should contain 's'.

Definition at line 407 of file hfile.c.

void hfile_destroy ( hFILE fp)

Definition at line 89 of file hfile.c.

hFILE* hfile_init ( size_t  struct_size,
const char *  mode,
size_t  capacity 
)

Definition at line 64 of file hfile.c.

int hfile_oflags ( const char *  mode)

Definition at line 425 of file hfile.c.

int hflush ( hFILE fp)

For writing streams, flush buffered output to the underlying stream

Returns
0 if successful, or EOF if an error occurred.

Definition at line 200 of file hfile.c.

int hgetc2 ( hFILE fp)

Definition at line 130 of file hfile.c.

hFILE* hopen ( const char *  filename,
const char *  mode 
)

Open the named file or URL as a stream

Returns
An hFILE pointer, or NULL (with errno set) if an error occurred.

Definition at line 519 of file hfile.c.

ssize_t hpeek ( hFILE fp,
void *  buffer,
size_t  nbytes 
)

Peek at characters to be read without removing them from buffers

Parameters
fpThe file stream
bufferThe buffer to which the peeked bytes will be written
nbytesThe number of bytes to peek at; limited by the size of the internal buffer, which could be as small as 4K.
Returns
The number of bytes peeked, which may be less than nbytes if EOF is encountered; or negative, if there was an I/O error. The characters peeked at remain in the stream's internal buffer, and will be returned by later hread() etc calls.

Definition at line 135 of file hfile.c.

int hputc2 ( int  c,
hFILE fp 
)

Definition at line 208 of file hfile.c.

int hputs2 ( const char *  text,
size_t  totalbytes,
size_t  ncopied,
hFILE fp 
)

Definition at line 244 of file hfile.c.

ssize_t hread2 ( hFILE fp,
void *  destv,
size_t  nbytes,
size_t  nread 
)

Definition at line 152 of file hfile.c.

off_t hseek ( hFILE fp,
off_t  offset,
int  whence 
)

Reposition the read/write stream offset

Returns
The resulting offset within the stream (as per lseek(2)), or negative if an error occurred.

Definition at line 249 of file hfile.c.

ssize_t hwrite2 ( hFILE fp,
const void *  srcv,
size_t  totalbytes,
size_t  ncopied 
)

Definition at line 217 of file hfile.c.