diff options
Diffstat (limited to 'src/file_null.c')
| -rw-r--r-- | src/file_null.c | 275 |
1 files changed, 275 insertions, 0 deletions
diff --git a/src/file_null.c b/src/file_null.c new file mode 100644 index 0000000..75684d8 --- /dev/null +++ b/src/file_null.c @@ -0,0 +1,275 @@ +#include <bh/internal/file.h> + +/** + * \defgroup file File IO + * + * File input/output API + * \{ + */ + +/** + * Creates new file object with specified \a path to file. + * + * \param path Path to the file + * + * \return On success, returns new file object. + * \return On failure, returns null pointer. + */ +bh_file_t *bh_file_new(const char *path) +{ + (void)path; + return NULL; +} + +/** + * Frees the \a file object. + * + * Before freeing the file object, this function ensures that underlying file + * was closed. + * + * \param file Pointer to the file object + */ +void bh_file_free(bh_file_t *file) +{ + (void)file; +} + +/** + * Initializes the \a file object with specified \a path to file. + * + * \param file Pointer to the file object + * \param path Path to the file + * + * \return On success, returns zero. + * \return On failure, returns error code. + */ +int bh_file_init(bh_file_t *file, + const char *path) +{ + (void)file; + (void)path; + return BH_NO_IMPL; +} + +/** + * Destroyes the \a file object. + * + * Before destroying the file object, this function ensures that underlying + * file was closed. + * + * \param file Pointer to the file object + */ +void bh_file_destroy(bh_file_t *file) +{ + (void)file; +} + +/** + * Opens the \a file object for specified \a mode of operation. + * + * \param file Pointer to the file object + * \param mode Bitmask determining access mode + * + * \return On success, returns zero. + * \return On failure, returns error code. + * + * \warning This function should be used in context of implementing child + * io objects (files, sockets, streaming compression, etc). + */ +int bh_file_open_base(bh_file_t *file, + int mode) +{ + (void)file; + (void)mode; + return BH_NO_IMPL; +} + +/** + * Closes the \a file object. + * + * \param file Pointer to the file object + * + * \warning This function should be used in context of implementing child + * io objects (files, sockets, streaming compression, etc). + */ +void bh_file_close_base(bh_file_t *file) +{ + (void)file; +} + +/** + * Checks if the \a file is open. + * + * \param file Pointer to the file object + * + * \return If file object is open - returns non-zero. + * \return If file object is closed - returns zero. + * + * \warning This function should be used in context of implementing child + * io objects (files, sockets, streaming compression, etc). + */ +int bh_file_is_open_base(bh_file_t *file) +{ + (void)file; + return 0; +} + +/** + * Reads up to \a size amount of bytes from the \a file object into memory + * buffer pointed by \a data pointer. + * + * \param file Pointer to the file object + * \param data Pointer to the memory buffer + * \param size Maximum number of bytes to be read + * + * \return On success, returns number of bytes successfuly read. + * \return On failure, returns zero. + * + * \note To check for end-of-file or error see bh_io_eof and bh_io_error. + * + * \warning This function should be used in context of implementing child + * io objects (files, sockets, streaming compression, etc). + */ +size_t bh_file_read_base(bh_file_t *file, + char *data, + size_t size) +{ + (void)file; + (void)data; + (void)size; + return 0; +} + +/** + * Writes up to \a size amount of bytes to the \a file object from memory + * buffer pointed by \a data pointer. + * + * \param file Pointer to the file object + * \param data Pointer to the memory buffer + * \param size Maximum number of bytes to be read + * + * \return On success, returns number of bytes successfuly written. + * \return On failure, returns zero. + * + * \note To check for error see bh_io_error. + * + * \warning This function should be used in context of implementing child + * io objects (files, sockets, streaming compression, etc). + */ +size_t bh_file_write_base(bh_file_t *file, + const char *data, + size_t size) +{ + (void)file; + (void)data; + (void)size; + return 0; +} + +/** + * Synchronizes the \a file object (if possible). + * + * In most cases, this function causes any unwritten/buffered data to be + * written. + * + * \param file Pointer to the file object + * + * \warning This function should be used in context of implementing child + * io objects (files, sockets, streaming compression, etc). + */ +void bh_file_flush_base(bh_file_t *file) +{ + (void)file; +} + +/** + * Seeks the \a file object in the specified direction \a dir and \a offset + * (if possible). + * + * \param file Pointer to the file object + * \param offset Number of bytes to seek in specified direciton + * \param dir Seeking direction + * + * \return On success, returns zero. + * \return On failure, returns error code. + * + * \warning This function should be used in context of implementing child + * io objects (files, sockets, streaming compression, etc). + */ +int bh_file_seek_base(bh_file_t *file, + bh_off_t off, + int dir) +{ + (void)file; + (void)off; + (void)dir; + return BH_NO_IMPL; +} + +/** + * Returns total size of the \a file object (if possible) + * + * \param file Pointer to the file object + * + * \return On success, returns total size of the file object. + * \return On failure, returns -1. + * + * \warning This function should be used in context of implementing child + * io objects (files, sockets, streaming compression, etc). + */ +bh_off_t bh_file_size_base(bh_file_t *file) +{ + (void)file; + return -1; +} + +/** + * Returns current position in the \a file object (if possible). + * + * \param file Pointer to the io object + * + * \return On success, returns current position in the file object. + * \return On failure, returns -1. + * + * \warning This function should be used in context of implementing child + * io objects (files, sockets, streaming compression, etc). + */ +bh_off_t bh_file_tell_base(bh_file_t *file) +{ + (void)file; + return -1; +} + +/** + * Returns available number of bytes to be read from the \a file object. + * + * \param file Pointer to the file object + * + * \return On success, returns number of available bytes to be read. + * \return On failure, returns zero. + * + * \warning This function should be used in context of implementing child + * io objects (files, sockets, streaming compression, etc). + */ +bh_off_t bh_file_available_base(bh_file_t *file) +{ + (void)file; + return 0; +} + +/** + * Clears error of the \a file object. + * + * \param file Pointer to the file object + * + * \warning This function should be used in context of implementing child + * io objects (files, sockets, streaming compression, etc). + */ +void bh_file_clear_base(bh_file_t *file) +{ + (void)file; +} + +/** + * \} + */ |
