Debian Codegraph @

libretro-common/include/streams/file_stream.h

raw symbols SCIP
1 /* Copyright (C) 2010-2016 The RetroArch team
2 *
3 * ---------------------------------------------------------------------------------------
4 * The following license statement only applies to this file (file_stream.h).
5 * ---------------------------------------------------------------------------------------
6 *
7 * Permission is hereby granted, free of charge,
8 * to any person obtaining a copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation the rights to
10 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
11 * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
16 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 */
22
23 #ifndef __LIBRETRO_SDK_FILE_STREAM_H
24 #define __LIBRETRO_SDK_FILE_STREAM_H
25
26 #include <stdint.h>
27 #include <stddef.h>
28
29 #include <sys/types.h>
30
31 #include <retro_common.h>
32 #include <boolean.h>
33
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37
38 typedef struct RFILE RFILE;
39
40 enum
41 {
42 RFILE_MODE_READ = 0,
43 RFILE_MODE_WRITE,
44 RFILE_MODE_READ_WRITE,
45
46 /* There is no garantee these requests will be attended. */
47 RFILE_HINT_UNBUFFERED = 1<<8,
48 RFILE_HINT_MMAP = 1<<9 /* requires RFILE_MODE_READ */
49 };
50
51 RFILE *filestream_open(const char *path, unsigned mode, ssize_t len);
52
53 ssize_t filestream_seek(RFILE *stream, ssize_t offset, int whence);
54
55 ssize_t filestream_read(RFILE *stream, void *data, size_t len);
56
57 ssize_t filestream_write(RFILE *stream, const void *data, size_t len);
58
59 ssize_t filestream_tell(RFILE *stream);
60
61 void filestream_rewind(RFILE *stream);
62
63 int filestream_close(RFILE *stream);
64
65 int filestream_read_file(const char *path, void **buf, ssize_t *len);
66
67 bool filestream_write_file(const char *path, const void *data, ssize_t size);
68
69 int filestream_get_fd(RFILE *stream);
70
71 #ifdef __cplusplus
72 }
73 #endif
74
75 #endif