Copyright

This program is free software.  You can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.

Author

© 2013 Jörg Seebohn

Files

C-kern/api/io/reader/filereader.h

Header file FileReader.

C-kern/io/reader/filereader.c

Implementation file FileReader impl.

types

filereader_mmfile_t

typedef typeof(((filereader_t*)0)->mmfile[0]) filereader_mmfile_t

Names type filereader_t.mmfile.

static configuration

lifetime

initfile_filereader

static int initfile_filereader(
   /*out*/file_t *fd,  
   /*out*/off_t *filesize,  
   const char *filepath,  
   const struct directory_t *relative_to/*0 = > current working dir*/
)

Opens file for reading.

The caller must free all out variables even in case of error !

query

sizebuffer_filereader

size_t sizebuffer_filereader(void)

TODO: 1. read configuration value at runtime !

read

test

Offers a simple interface for reading and buffering the content of a file.
Implements FileReader.
typedef typeof(((filereader_t*)0)->mmfile[0]) filereader_mmfile_t
Names type filereader_t.mmfile.
struct { uint8_t* addr ; size_t size ; } mmfile[2]
The buffered input of the file.
static int initfile_filereader(
   /*out*/file_t *fd,  
   /*out*/off_t *filesize,  
   const char *filepath,  
   const struct directory_t *relative_to/*0 = > current working dir*/
)
Opens file for reading.
size_t sizebuffer_filereader(void)
TODO: 1.
Close