summaryrefslogtreecommitdiff
path: root/src/helper
diff options
context:
space:
mode:
Diffstat (limited to 'src/helper')
-rw-r--r--src/helper/fileio.c23
-rw-r--r--src/helper/fileio.h1
2 files changed, 24 insertions, 0 deletions
diff --git a/src/helper/fileio.c b/src/helper/fileio.c
index b0ad446e..3ee0b18b 100644
--- a/src/helper/fileio.c
+++ b/src/helper/fileio.c
@@ -284,6 +284,29 @@ int fileio_read_u32(fileio_t *fileio, u32 *data)
return ERROR_OK;
}
+int fileio_local_fgets(fileio_t *fileio, u32 size, u8 *buffer)
+{
+ fileio_local_t *fileio_local = fileio->location_private;
+
+ if( fgets(buffer, size, fileio_local->file) == NULL)
+ return ERROR_FILEIO_OPERATION_FAILED;
+
+ return ERROR_OK;
+}
+
+int fileio_fgets(fileio_t *fileio, u32 size, u8 *buffer)
+{
+ switch (fileio->location)
+ {
+ case FILEIO_LOCAL:
+ return fileio_local_fgets(fileio, size, buffer);
+ break;
+ default:
+ ERROR("BUG: should never get here");
+ exit(-1);
+ }
+}
+
int fileio_local_write(fileio_t *fileio, u32 size, u8 *buffer, u32 *size_written)
{
fileio_local_t *fileio_local = fileio->location_private;
diff --git a/src/helper/fileio.h b/src/helper/fileio.h
index 5c0a88da..20e5c629 100644
--- a/src/helper/fileio.h
+++ b/src/helper/fileio.h
@@ -79,6 +79,7 @@ typedef struct fileio_local_s
extern int fileio_write(fileio_t *fileio, u32 size, u8 *buffer, u32 *size_written);
extern int fileio_read(fileio_t *fileio, u32 size, u8 *buffer, u32 *size_read);
+extern int fileio_fgets(fileio_t *fileio, u32 size, u8 *buffer);
extern int fileio_seek(fileio_t *fileio, u32 position);
extern int fileio_close(fileio_t *fileio);
extern int fileio_open(fileio_t *fileio, char *url, enum fileio_access access, enum fileio_type type);