36 LOG_ERROR(
"BUG: fileio->file not a valid file descriptor");
53 strcpy(file_access,
"r");
56 strcpy(file_access,
"w");
59 strcpy(file_access,
"w+");
62 strcpy(file_access,
"a");
65 strcpy(file_access,
"a+");
68 LOG_ERROR(
"BUG: access neither read, write nor readwrite");
76 strcat(file_access,
"b");
98 if ((file_size < 0) || (result < 0) || (result2 < 0)) {
115 tmp = malloc(
sizeof(
struct fileio));
118 tmp->
access = access_type;
155 retval = fseek(
fileio->
file, position, SEEK_SET);
171 *size_read = (retval >= 0) ? retval : 0;
173 return (retval < 0) ? retval :
ERROR_OK;
190 if (retval ==
ERROR_OK &&
sizeof(uint32_t) != size_read)
212 const void *
buffer,
size_t *size_written)
217 *size_written = (retval >= 0) ? retval : 0;
219 return (retval < 0) ? retval :
ERROR_OK;
223 size_t *size_written)
244 if (retval ==
ERROR_OK && size_written !=
sizeof(uint32_t))
#define ERROR_COMMAND_SYNTAX_ERROR
FILE * open_file_from_path(const char *file, const char *mode)
static int fileio_local_read(struct fileio *fileio, size_t size, void *buffer, size_t *size_read)
int fileio_write(struct fileio *fileio, size_t size, const void *buffer, size_t *size_written)
int fileio_seek(struct fileio *fileio, size_t position)
int fileio_write_u32(struct fileio *fileio, uint32_t data)
static int fileio_open_local(struct fileio *fileio)
int fileio_read(struct fileio *fileio, size_t size, void *buffer, size_t *size_read)
int fileio_read_u32(struct fileio *fileio, uint32_t *data)
int fileio_close(struct fileio *fileio)
int fileio_size(struct fileio *fileio, size_t *size)
FIX!!!!
int fileio_fgets(struct fileio *fileio, size_t size, void *buffer)
int fileio_feof(struct fileio *fileio)
static int fileio_close_local(struct fileio *fileio)
int fileio_open(struct fileio **fileio, const char *url, enum fileio_access access_type, enum fileio_type type)
static int fileio_local_fgets(struct fileio *fileio, size_t size, void *buffer)
static int fileio_local_write(struct fileio *fileio, size_t size, const void *buffer, size_t *size_written)
#define ERROR_FILEIO_OPERATION_FAILED
#define LOG_ERROR(expr ...)
size_t size
Size of the control block search area.
enum fileio_access access
static void h_u32_to_be(uint8_t *buf, uint32_t val)
static uint32_t be_to_h_u32(const uint8_t *buf)