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>
44 FILEIO_READ, /* open for reading, position at beginning */
45 FILEIO_WRITE, /* open for writing, position at beginning */
46 FILEIO_READWRITE, /* open for writing, position at beginning, allow reading */
47 FILEIO_APPEND, /* open for writing, position at end */
48 FILEIO_APPENDREAD, /* open for writing, position at end, allow reading */
51 typedef struct fileio_s
55 enum fileio_type type;
56 enum fileio_access access;
60 extern int fileio_write(fileio_t *fileio, u32 size, u8 *buffer, u32 *size_written);
61 extern int fileio_read(fileio_t *fileio, u32 size, u8 *buffer, u32 *size_read);
62 extern int fileio_fgets(fileio_t *fileio, u32 size, char *buffer);
63 extern int fileio_seek(fileio_t *fileio, u32 position);
64 extern int fileio_close(fileio_t *fileio);
65 extern int fileio_open(fileio_t *fileio, char *url, enum fileio_access access, enum fileio_type type);
66 extern int fileio_read_u32(fileio_t *fileio, u32 *data);
67 extern int fileio_write_u32(fileio_t *fileio, u32 data);
69 #define ERROR_FILEIO_LOCATION_UNKNOWN (-1200)
70 #define ERROR_FILEIO_NOT_FOUND (-1201)
71 #define ERROR_FILEIO_OPERATION_FAILED (-1202)
72 #define ERROR_FILEIO_ACCESS_NOT_SUPPORTED (-1203)
73 #define ERROR_FILEIO_RESOURCE_TYPE_UNKNOWN (-1204)
74 #define ERROR_FILEIO_OPERATION_NOT_SUPPORTED (-1205)