Add documentation, expand error handling, implement file and buffer io
This commit is contained in:
@@ -1,37 +1,80 @@
|
||||
#ifndef BHLIB_FILE_H
|
||||
#define BHLIB_FILE_H
|
||||
#ifndef BH_FILE_H
|
||||
#define BH_FILE_H
|
||||
|
||||
#include "io.h"
|
||||
|
||||
typedef struct bh_file_s bh_file_t;
|
||||
|
||||
bh_file_t *bh_file_new(const char *path,
|
||||
const char *mode);
|
||||
|
||||
bh_file_t *bh_file_new(const char *path);
|
||||
|
||||
void bh_file_free(bh_file_t *file);
|
||||
|
||||
size_t bh_file_read(bh_file_t *file,
|
||||
char *buffer,
|
||||
size_t size);
|
||||
int bh_file_open_base(bh_file_t *file,
|
||||
int mode);
|
||||
|
||||
size_t bh_file_write(bh_file_t *file,
|
||||
const char *buffer,
|
||||
size_t size);
|
||||
void bh_file_close_base(bh_file_t *file);
|
||||
|
||||
void bh_file_flush(bh_file_t *file);
|
||||
int bh_file_is_open_base(bh_file_t *file);
|
||||
|
||||
void bh_file_seek(bh_file_t *file,
|
||||
bh_off_t pos,
|
||||
int dir);
|
||||
size_t bh_file_read_base(bh_file_t *file,
|
||||
char *data,
|
||||
size_t size);
|
||||
|
||||
bh_off_t bh_file_tell(bh_file_t *file);
|
||||
size_t bh_file_write_base(bh_file_t *file,
|
||||
const char *data,
|
||||
size_t size);
|
||||
|
||||
bh_off_t bh_file_available(bh_file_t *file);
|
||||
void bh_file_flush_base(bh_file_t *file);
|
||||
|
||||
int bh_file_error(bh_file_t *file);
|
||||
int bh_file_seek_base(bh_file_t *file,
|
||||
bh_off_t pos,
|
||||
int dir);
|
||||
|
||||
int bh_file_eof(bh_file_t *file);
|
||||
bh_off_t bh_file_size_base(bh_file_t *file);
|
||||
|
||||
void bh_file_clear(bh_file_t *file);
|
||||
bh_off_t bh_file_tell_base(bh_file_t *file);
|
||||
|
||||
#endif /* BHLIB_FILE_H */
|
||||
bh_off_t bh_file_available_base(bh_file_t *file);
|
||||
|
||||
void bh_file_clear_base(bh_file_t *file);
|
||||
|
||||
#define bh_file_open(file, mode) \
|
||||
bh_io_open((bh_io_t *)(file), (mode))
|
||||
|
||||
#define bh_file_close(file) \
|
||||
bh_io_close((bh_io_t *)(file))
|
||||
|
||||
#define bh_file_is_open(file) \
|
||||
bh_io_is_open((bh_io_t *)(file))
|
||||
|
||||
#define bh_file_read(file, data, size) \
|
||||
bh_io_read((bh_io_t *)(file), (data), (size))
|
||||
|
||||
#define bh_file_write(file, data, size) \
|
||||
bh_io_write((bh_io_t *)(file), (data), (size))
|
||||
|
||||
#define bh_file_flush(file) \
|
||||
bh_io_flush((bh_io_t *)(file))
|
||||
|
||||
#define bh_file_seek(file, pos, dir) \
|
||||
bh_io_seek((bh_io_t *)(file), (pos), (dir))
|
||||
|
||||
#define bh_file_size(file) \
|
||||
bh_io_size((bh_io_t *)(file))
|
||||
|
||||
#define bh_file_tell(file) \
|
||||
bh_io_tell((bh_io_t *)(file))
|
||||
|
||||
#define bh_file_available(file) \
|
||||
bh_io_available((bh_io_t *)(file))
|
||||
|
||||
#define bh_file_clear(file) \
|
||||
bh_io_clear((bh_io_t *)(file))
|
||||
|
||||
#define bh_file_error(file) \
|
||||
bh_io_error((bh_io_t *)(file))
|
||||
|
||||
#define bh_file_eof(file) \
|
||||
bh_io_eof((bh_io_t *)(file))
|
||||
|
||||
#endif /* BH_FILE_H */
|
||||
|
||||
Reference in New Issue
Block a user