psxdma: Fix endian issue in gpuInterrupt()
[pcsx_rearmed.git] / deps / libretro-common / include / streams / file_stream.h
CommitLineData
3719602c
PC
1/* Copyright (C) 2010-2020 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 <stdio.h>
27#include <stdint.h>
28#include <stdlib.h>
29#include <stddef.h>
30
31#include <sys/types.h>
32
33#include <libretro.h>
34#include <retro_common_api.h>
35#include <retro_inline.h>
36#include <boolean.h>
37
38#include <stdarg.h>
39#include <vfs/vfs_implementation.h>
40
41#define FILESTREAM_REQUIRED_VFS_VERSION 2
42
43RETRO_BEGIN_DECLS
44
45typedef struct RFILE RFILE;
46
47#define FILESTREAM_REQUIRED_VFS_VERSION 2
48
49void filestream_vfs_init(const struct retro_vfs_interface_info* vfs_info);
50
51int64_t filestream_get_size(RFILE *stream);
52
53int64_t filestream_truncate(RFILE *stream, int64_t length);
54
55/**
56 * filestream_open:
57 * @path : path to file
58 * @mode : file mode to use when opening (read/write)
59 * @bufsize : optional buffer size (-1 or 0 to use default)
60 *
61 * Opens a file for reading or writing, depending on the requested mode.
62 * @return A pointer to an RFILE if opened successfully, otherwise NULL.
63 **/
64RFILE* filestream_open(const char *path, unsigned mode, unsigned hints);
65
66int64_t filestream_seek(RFILE *stream, int64_t offset, int seek_position);
67
68int64_t filestream_read(RFILE *stream, void *data, int64_t len);
69
70int64_t filestream_write(RFILE *stream, const void *data, int64_t len);
71
72int64_t filestream_tell(RFILE *stream);
73
74void filestream_rewind(RFILE *stream);
75
76int filestream_close(RFILE *stream);
77
78/**
79 * filestream_read_file:
80 * @path : path to file.
81 * @buf : buffer to allocate and read the contents of the
82 * file into. Needs to be freed manually.
83 * @len : optional output integer containing bytes read.
84 *
85 * Read the contents of a file into @buf.
86 *
87 * @return Non-zero on success.
88 */
89int64_t filestream_read_file(const char *path, void **buf, int64_t *len);
90
91char* filestream_gets(RFILE *stream, char *s, size_t len);
92
93int filestream_getc(RFILE *stream);
94
95int filestream_vscanf(RFILE *stream, const char* format, va_list *args);
96
97int filestream_scanf(RFILE *stream, const char* format, ...);
98
99int filestream_eof(RFILE *stream);
100
101/**
102 * filestream_write_file:
103 * @path : path to file.
104 * @data : contents to write to the file.
105 * @size : size of the contents.
106 *
107 * Writes data to a file.
108 *
109 * @return true on success, otherwise false.
110 **/
111bool filestream_write_file(const char *path, const void *data, int64_t size);
112
113int filestream_putc(RFILE *stream, int c);
114
115int filestream_vprintf(RFILE *stream, const char* format, va_list args);
116
117int filestream_printf(RFILE *stream, const char* format, ...);
118
119int filestream_error(RFILE *stream);
120
121int filestream_flush(RFILE *stream);
122
123int filestream_delete(const char *path);
124
125int filestream_rename(const char *old_path, const char *new_path);
126
127const char* filestream_get_path(RFILE *stream);
128
129bool filestream_exists(const char *path);
130
131/**
132 * filestream_getline:
133 *
134 * Returned pointer must be freed by the caller.
135 **/
136char* filestream_getline(RFILE *stream);
137
138libretro_vfs_implementation_file* filestream_get_vfs_handle(RFILE *stream);
139
140RETRO_END_DECLS
141
142#endif