1 /***************************************************************************
2 * Copyright (C) 2007 by Dominic Rath *
3 * Dominic.Rath@gmx.de *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
23 #define FILEIO_MAX_ERROR_STRING (128)
30 #include <sys/types.h>
45 * Possible future enhancements:
56 FILEIO_READ, /* open for reading, position at beginning */
57 FILEIO_WRITE, /* open for writing, position at beginning */
58 FILEIO_READWRITE, /* open for writing, position at beginning, allow reading */
59 FILEIO_APPEND, /* open for writing, position at end */
60 FILEIO_APPENDREAD, /* open for writing, position at end, allow reading */
63 typedef struct fileio_s
66 char error_str[FILEIO_MAX_ERROR_STRING];
68 enum fileio_type type;
69 enum fileio_location location;
70 enum fileio_access access;
71 void *location_private;
74 typedef struct fileio_local_s
79 extern int fileio_write(fileio_t *fileio, u32 size, u8 *buffer, u32 *size_written);
80 extern int fileio_read(fileio_t *fileio, u32 size, u8 *buffer, u32 *size_read);
81 extern int fileio_fgets(fileio_t *fileio, u32 size, u8 *buffer);
82 extern int fileio_seek(fileio_t *fileio, u32 position);
83 extern int fileio_close(fileio_t *fileio);
84 extern int fileio_open(fileio_t *fileio, char *url, enum fileio_access access, enum fileio_type type);
85 extern int fileio_read_u32(fileio_t *fileio, u32 *data);
86 extern int fileio_write_u32(fileio_t *fileio, u32 data);
88 #define ERROR_FILEIO_LOCATION_UNKNOWN (-1200)
89 #define ERROR_FILEIO_NOT_FOUND (-1201)
90 #define ERROR_FILEIO_OPERATION_FAILED (-1202)
91 #define ERROR_FILEIO_ACCESS_NOT_SUPPORTED (-1203)
92 #define ERROR_FILEIO_RESOURCE_TYPE_UNKNOWN (-1204)
93 #define ERROR_FILEIO_OPERATION_NOT_SUPPORTED (-1205)