Replace function signatures of file_stream file functions
This commit is contained in:
parent
d19eaeaab8
commit
2e979ec537
|
@ -2640,7 +2640,8 @@ static int cheevos_iterate(coro_t* coro)
|
|||
/* Load the content into memory, or copy it over to our own buffer */
|
||||
if (!CHEEVOS_VAR_DATA)
|
||||
{
|
||||
CHEEVOS_VAR_STREAM = filestream_open(CHEEVOS_VAR_PATH, RFILE_MODE_READ, -1);
|
||||
CHEEVOS_VAR_STREAM = filestream_open(CHEEVOS_VAR_PATH,
|
||||
RFILE_MODE_READ, RFILE_HINT_NONE);
|
||||
|
||||
if (!CHEEVOS_VAR_STREAM)
|
||||
CORO_STOP();
|
||||
|
|
|
@ -3791,15 +3791,18 @@ bool config_save_file(const char *path)
|
|||
|
||||
#ifdef HAVE_LAKKA
|
||||
if (settings->bools.ssh_enable)
|
||||
filestream_close(filestream_open(LAKKA_SSH_PATH, RFILE_MODE_WRITE, -1));
|
||||
filestream_close(filestream_open(LAKKA_SSH_PATH,
|
||||
RFILE_MODE_WRITE, RFILE_HINT_NONE));
|
||||
else
|
||||
path_file_remove(LAKKA_SSH_PATH);
|
||||
if (settings->bools.samba_enable)
|
||||
filestream_close(filestream_open(LAKKA_SAMBA_PATH, RFILE_MODE_WRITE, -1));
|
||||
filestream_close(filestream_open(LAKKA_SAMBA_PATH,
|
||||
RFILE_MODE_WRITE, RFILE_HINT_NONE));
|
||||
else
|
||||
path_file_remove(LAKKA_SAMBA_PATH);
|
||||
if (settings->bools.bluetooth_enable)
|
||||
filestream_close(filestream_open(LAKKA_BLUETOOTH_PATH, RFILE_MODE_WRITE, -1));
|
||||
filestream_close(filestream_open(LAKKA_BLUETOOTH_PATH,
|
||||
RFILE_MODE_WRITE, RFILE_HINT_NONE));
|
||||
else
|
||||
path_file_remove(LAKKA_BLUETOOTH_PATH);
|
||||
#endif
|
||||
|
|
|
@ -719,7 +719,7 @@ static void gx_efb_screenshot(void)
|
|||
{
|
||||
int x, y;
|
||||
uint8_t tga_header[] = {0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x02, 0xE0, 0x01, 0x18, 0x00};
|
||||
RFILE *out = filestream_open("/screenshot.tga", RFILE_MODE_WRITE, -1);
|
||||
RFILE *out = filestream_open("/screenshot.tga", RFILE_MODE_WRITE, RFILE_HINT_NONE);
|
||||
|
||||
if (!out)
|
||||
return;
|
||||
|
|
|
@ -545,7 +545,7 @@ bool video_shader_resolve_parameters(config_file_t *conf,
|
|||
/* If that doesn't work, fallback to the old path.
|
||||
* Ideally, we'd get rid of this path sooner or later. */
|
||||
#endif
|
||||
file = filestream_open(path, RFILE_MODE_READ, -1);
|
||||
file = filestream_open(path, RFILE_MODE_READ, RFILE_HINT_NONE);
|
||||
|
||||
if (!file)
|
||||
{
|
||||
|
|
|
@ -320,7 +320,8 @@ static unsigned char check_arm_cpu_feature(const char* feature)
|
|||
{
|
||||
char line[1024];
|
||||
unsigned char status = 0;
|
||||
RFILE *fp = filestream_open("/proc/cpuinfo", RFILE_MODE_READ, -1);
|
||||
RFILE *fp = filestream_open("/proc/cpuinfo",
|
||||
RFILE_MODE_READ, RFILE_HINT_NONE);
|
||||
|
||||
if (!fp)
|
||||
return 0;
|
||||
|
|
|
@ -392,7 +392,8 @@ static config_file_t *config_file_new_internal(
|
|||
goto error;
|
||||
|
||||
conf->include_depth = depth;
|
||||
file = filestream_open(path, RFILE_MODE_READ, 0x4000);
|
||||
file = filestream_open(path,
|
||||
RFILE_MODE_READ, RFILE_HINT_NONE);
|
||||
|
||||
if (!file)
|
||||
{
|
||||
|
|
|
@ -410,7 +410,7 @@ bool path_file_exists(const char *path)
|
|||
if (!path || !*path)
|
||||
return false;
|
||||
|
||||
dummy = filestream_open(path, RFILE_MODE_READ, -1);
|
||||
dummy = filestream_open(path, RFILE_MODE_READ, RFILE_HINT_NONE);
|
||||
|
||||
if (!dummy)
|
||||
return false;
|
||||
|
|
|
@ -215,7 +215,7 @@ bool rbmp_save_image(
|
|||
unsigned pitch, enum rbmp_source_type type)
|
||||
{
|
||||
bool ret = false;
|
||||
RFILE *file = filestream_open(filename, RFILE_MODE_WRITE, -1);
|
||||
RFILE *file = filestream_open(filename, RFILE_MODE_WRITE, RFILE_HINT_NONE);
|
||||
if (!file)
|
||||
return false;
|
||||
|
||||
|
|
|
@ -227,7 +227,7 @@ static bool rpng_save_image(const char *path,
|
|||
void *stream = NULL;
|
||||
uint32_t total_in = 0;
|
||||
uint32_t total_out = 0;
|
||||
RFILE *file = filestream_open(path, RFILE_MODE_WRITE, -1);
|
||||
RFILE *file = filestream_open(path, RFILE_MODE_WRITE, RFILE_HINT_NONE);
|
||||
if (!file)
|
||||
GOTO_END_ERROR();
|
||||
|
||||
|
|
|
@ -419,7 +419,7 @@ rxml_document_t *rxml_load_document(const char *path)
|
|||
char *new_memory_buffer = NULL;
|
||||
const char *mem_ptr = NULL;
|
||||
long len = 0;
|
||||
RFILE *file = filestream_open(path, RFILE_MODE_READ, -1);
|
||||
RFILE *file = filestream_open(path, RFILE_MODE_READ, RFILE_HINT_NONE);
|
||||
if (!file)
|
||||
return NULL;
|
||||
|
||||
|
|
|
@ -511,7 +511,7 @@ int sha1_calculate(const char *path, char *result)
|
|||
SHA1Context sha;
|
||||
unsigned char buff[4096];
|
||||
int rv = 1;
|
||||
RFILE *fd = filestream_open(path, RFILE_MODE_READ, -1);
|
||||
RFILE *fd = filestream_open(path, RFILE_MODE_READ, RFILE_HINT_NONE);
|
||||
|
||||
if (!fd)
|
||||
goto error;
|
||||
|
|
|
@ -38,15 +38,17 @@ RETRO_BEGIN_DECLS
|
|||
|
||||
typedef struct RFILE RFILE;
|
||||
|
||||
#define RFILE_HINT_NONE (0)
|
||||
/* There is no guarantee these requests will be attended. */
|
||||
#define RFILE_HINT_UNBUFFERED (1 << 8)
|
||||
/* requires RFILE_MODE_READ */
|
||||
#define RFILE_HINT_MMAP (1 << 9)
|
||||
|
||||
enum
|
||||
{
|
||||
RFILE_MODE_READ = 0,
|
||||
RFILE_MODE_WRITE,
|
||||
RFILE_MODE_READ_WRITE,
|
||||
|
||||
/* There is no guarantee these requests will be attended. */
|
||||
RFILE_HINT_UNBUFFERED = 1<<8,
|
||||
RFILE_HINT_MMAP = 1<<9 /* requires RFILE_MODE_READ */
|
||||
RFILE_MODE_READ_WRITE
|
||||
};
|
||||
|
||||
int64_t filestream_get_size(RFILE *stream);
|
||||
|
@ -64,7 +66,7 @@ const char *filestream_get_ext(RFILE *stream);
|
|||
* Opens a file for reading or writing, depending on the requested mode.
|
||||
* Returns a pointer to an RFILE if opened successfully, otherwise NULL.
|
||||
**/
|
||||
RFILE *filestream_open(const char *path, unsigned mode, ssize_t unused);
|
||||
RFILE *filestream_open(const char *path, unsigned mode, unsigned hints);
|
||||
|
||||
ssize_t filestream_seek(RFILE *stream, ssize_t offset, int whence);
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ bool intfstream_resize(intfstream_internal_t *intf,
|
|||
intfstream_info_t *info);
|
||||
|
||||
bool intfstream_open(intfstream_internal_t *intf,
|
||||
const char *path, unsigned mode, ssize_t len);
|
||||
const char *path, unsigned mode, unsigned hints);
|
||||
|
||||
ssize_t intfstream_read(intfstream_internal_t *intf,
|
||||
void *s, size_t len);
|
||||
|
|
|
@ -144,7 +144,7 @@ void filestream_set_size(RFILE *stream)
|
|||
* Opens a file for reading or writing, depending on the requested mode.
|
||||
* Returns a pointer to an RFILE if opened successfully, otherwise NULL.
|
||||
**/
|
||||
RFILE *filestream_open(const char *path, unsigned mode, ssize_t unused)
|
||||
RFILE *filestream_open(const char *path, unsigned mode, unsigned hints)
|
||||
{
|
||||
int flags = 0;
|
||||
#if !defined(_WIN32) || defined(LEGACY_WIN32)
|
||||
|
@ -159,16 +159,16 @@ RFILE *filestream_open(const char *path, unsigned mode, ssize_t unused)
|
|||
|
||||
(void)flags;
|
||||
|
||||
stream->hints = mode;
|
||||
stream->hints = hints;
|
||||
|
||||
#ifdef HAVE_MMAP
|
||||
if (stream->hints & RFILE_HINT_MMAP && (stream->hints & 0xff) == RFILE_MODE_READ)
|
||||
if (stream->hints & RFILE_HINT_MMAP && (stream->mode == RFILE_MODE_READ))
|
||||
stream->hints |= RFILE_HINT_UNBUFFERED;
|
||||
else
|
||||
#endif
|
||||
stream->hints &= ~RFILE_HINT_MMAP;
|
||||
|
||||
switch (mode & 0xff)
|
||||
switch (mode)
|
||||
{
|
||||
case RFILE_MODE_READ:
|
||||
if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0)
|
||||
|
@ -582,7 +582,8 @@ int filestream_read_file(const char *path, void **buf, ssize_t *len)
|
|||
ssize_t ret = 0;
|
||||
ssize_t content_buf_size = 0;
|
||||
void *content_buf = NULL;
|
||||
RFILE *file = filestream_open(path, RFILE_MODE_READ, -1);
|
||||
RFILE *file = filestream_open(path,
|
||||
RFILE_MODE_READ, RFILE_HINT_NONE);
|
||||
|
||||
if (!file)
|
||||
{
|
||||
|
@ -648,7 +649,7 @@ error:
|
|||
bool filestream_write_file(const char *path, const void *data, ssize_t size)
|
||||
{
|
||||
ssize_t ret = 0;
|
||||
RFILE *file = filestream_open(path, RFILE_MODE_WRITE, -1);
|
||||
RFILE *file = filestream_open(path, RFILE_MODE_WRITE, RFILE_HINT_NONE);
|
||||
if (!file)
|
||||
return false;
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ bool intfstream_resize(intfstream_internal_t *intf, intfstream_info_t *info)
|
|||
}
|
||||
|
||||
bool intfstream_open(intfstream_internal_t *intf, const char *path,
|
||||
unsigned mode, ssize_t len)
|
||||
unsigned mode, unsigned hints)
|
||||
{
|
||||
if (!intf)
|
||||
return false;
|
||||
|
@ -91,7 +91,7 @@ bool intfstream_open(intfstream_internal_t *intf, const char *path,
|
|||
switch (intf->type)
|
||||
{
|
||||
case INTFSTREAM_FILE:
|
||||
intf->file.fp = filestream_open(path, mode, len);
|
||||
intf->file.fp = filestream_open(path, mode, hints);
|
||||
if (!intf->file.fp)
|
||||
return false;
|
||||
break;
|
||||
|
|
|
@ -804,7 +804,7 @@ int main(int argc, char** argv)
|
|||
dat_buffer++;
|
||||
}
|
||||
|
||||
rdb_file = filestream_open(rdb_path, RFILE_MODE_WRITE, -1);
|
||||
rdb_file = filestream_open(rdb_path, RFILE_MODE_WRITE, RFILE_HINT_NONE);
|
||||
|
||||
if (!rdb_file)
|
||||
{
|
||||
|
|
|
@ -217,7 +217,7 @@ int libretrodb_open(const char *path, libretrodb_t *db)
|
|||
libretrodb_header_t header;
|
||||
libretrodb_metadata_t md;
|
||||
int rv;
|
||||
RFILE *fd = filestream_open(path, RFILE_MODE_READ, -1);
|
||||
RFILE *fd = filestream_open(path, RFILE_MODE_READ, RFILE_HINT_NONE);
|
||||
|
||||
if (!fd)
|
||||
return -errno;
|
||||
|
@ -431,7 +431,7 @@ int libretrodb_cursor_open(libretrodb_t *db, libretrodb_cursor_t *cursor,
|
|||
if (!db || string_is_empty(db->path))
|
||||
return -errno;
|
||||
|
||||
cursor->fd = filestream_open(db->path, RFILE_MODE_READ | RFILE_HINT_MMAP, -1);
|
||||
cursor->fd = filestream_open(db->path, RFILE_MODE_READ, RFILE_HINT_MMAP);
|
||||
|
||||
if (!cursor->fd)
|
||||
return -errno;
|
||||
|
|
|
@ -92,7 +92,8 @@ int main(int argc, char ** argv)
|
|||
|
||||
call_init(L, argc - 2, (const char **) argv + 2);
|
||||
|
||||
dst = filestream_open(db_file, RFILE_MODE_WRITE, -1);
|
||||
dst = filestream_open(db_file, RFILE_MODE_WRITE, RFILE_HINT_NONE);
|
||||
|
||||
if (!dst)
|
||||
{
|
||||
printf(
|
||||
|
|
|
@ -106,7 +106,7 @@ static int create_db(lua_State *L)
|
|||
}
|
||||
lua_setfield(L, LUA_REGISTRYINDEX, "testlib_get_value");
|
||||
|
||||
dst = filestream_open(db_file, RFILE_MODE_WRITE, -1);
|
||||
dst = filestream_open(db_file, RFILE_MODE_WRITE, RFILE_HINT_NONE);
|
||||
if (!dst)
|
||||
{
|
||||
lua_pushstring(L, "Could not open destination file");
|
||||
|
|
|
@ -186,7 +186,7 @@ static struct rmsgpack_read_callbacks stub_callbacks = {
|
|||
int main(void)
|
||||
{
|
||||
struct stub_state state;
|
||||
RFILE *fd = filestream_open("test.msgpack", RFILE_MODE_READ, -1);
|
||||
RFILE *fd = filestream_open("test.msgpack", RFILE_MODE_READ, RFILE_HINT_NONE);
|
||||
|
||||
state.i = 0;
|
||||
state.stack[0] = 0;
|
||||
|
|
|
@ -1876,7 +1876,8 @@ static void systemd_service_toggle(const char *path, char *unit, bool enable)
|
|||
args[2] = unit;
|
||||
|
||||
if (enable)
|
||||
filestream_close(filestream_open(path, RFILE_MODE_WRITE, -1));
|
||||
filestream_close(filestream_open(path,
|
||||
RFILE_MODE_WRITE, RFILE_HINT_NONE));
|
||||
else
|
||||
path_file_remove(path);
|
||||
|
||||
|
|
4
movie.c
4
movie.c
|
@ -75,7 +75,7 @@ static bool bsv_movie_init_playback(bsv_movie_t *handle, const char *path)
|
|||
uint32_t state_size = 0;
|
||||
uint32_t content_crc = 0;
|
||||
uint32_t header[4] = {0};
|
||||
RFILE *file = filestream_open(path, RFILE_MODE_READ, -1);
|
||||
RFILE *file = filestream_open(path, RFILE_MODE_READ, RFILE_HINT_NONE);
|
||||
|
||||
if (!file)
|
||||
{
|
||||
|
@ -152,7 +152,7 @@ static bool bsv_movie_init_record(bsv_movie_t *handle, const char *path)
|
|||
uint32_t state_size = 0;
|
||||
uint32_t content_crc = 0;
|
||||
uint32_t header[4] = {0};
|
||||
RFILE *file = filestream_open(path, RFILE_MODE_WRITE, -1);
|
||||
RFILE *file = filestream_open(path, RFILE_MODE_WRITE, RFILE_HINT_NONE);
|
||||
|
||||
if (!file)
|
||||
{
|
||||
|
|
|
@ -393,7 +393,8 @@ void playlist_write_file(playlist_t *playlist)
|
|||
if (!playlist || !playlist->modified)
|
||||
return;
|
||||
|
||||
file = filestream_open(playlist->conf_path, RFILE_MODE_WRITE, -1);
|
||||
file = filestream_open(playlist->conf_path,
|
||||
RFILE_MODE_WRITE, RFILE_HINT_NONE);
|
||||
|
||||
if (!file)
|
||||
{
|
||||
|
@ -493,7 +494,7 @@ static bool playlist_read_file(
|
|||
unsigned i;
|
||||
char buf[PLAYLIST_ENTRIES][1024];
|
||||
RFILE *file = filestream_open(
|
||||
path, RFILE_MODE_READ, -1);
|
||||
path, RFILE_MODE_READ, RFILE_HINT_NONE);
|
||||
|
||||
for (i = 0; i < PLAYLIST_ENTRIES; i++)
|
||||
buf[i][0] = '\0';
|
||||
|
|
|
@ -101,7 +101,7 @@ static intfstream_t* intfstream_open_file(const char *path)
|
|||
if (!fd)
|
||||
return NULL;
|
||||
|
||||
if (!intfstream_open(fd, path, RFILE_MODE_READ, -1))
|
||||
if (!intfstream_open(fd, path, RFILE_MODE_READ, RFILE_HINT_NONE))
|
||||
goto error;
|
||||
|
||||
return fd;
|
||||
|
@ -130,7 +130,7 @@ static intfstream_t *open_memory(void *data, size_t size)
|
|||
if (!fd)
|
||||
return NULL;
|
||||
|
||||
if (!intfstream_open(fd, NULL, RFILE_MODE_READ, -1))
|
||||
if (!intfstream_open(fd, NULL, RFILE_MODE_READ, RFILE_HINT_NONE))
|
||||
goto error;
|
||||
|
||||
return fd;
|
||||
|
@ -158,7 +158,7 @@ open_chd_track(const char *path, int32_t track)
|
|||
if (!fd)
|
||||
return NULL;
|
||||
|
||||
if (!intfstream_open(fd, path, RFILE_MODE_READ, -1))
|
||||
if (!intfstream_open(fd, path, RFILE_MODE_READ, RFILE_HINT_NONE))
|
||||
goto error;
|
||||
|
||||
return fd;
|
||||
|
|
|
@ -413,10 +413,9 @@ clean:
|
|||
static ssize_t get_file_size(const char *path)
|
||||
{
|
||||
ssize_t rv;
|
||||
RFILE *fd = filestream_open(path, RFILE_MODE_READ, -1);
|
||||
if (fd == NULL) {
|
||||
RFILE *fd = filestream_open(path, RFILE_MODE_READ, RFILE_HINT_NONE);
|
||||
if (fd == NULL)
|
||||
return -1;
|
||||
}
|
||||
rv = filestream_get_size(fd);
|
||||
filestream_close(fd);
|
||||
return rv;
|
||||
|
@ -468,7 +467,7 @@ int cue_find_track(const char *cue_path, bool first,
|
|||
if (!fd)
|
||||
goto error;
|
||||
|
||||
if (!intfstream_open(fd, cue_path, RFILE_MODE_READ, -1))
|
||||
if (!intfstream_open(fd, cue_path, RFILE_MODE_READ, RFILE_HINT_NONE))
|
||||
{
|
||||
RARCH_LOG("Could not open CUE file '%s': %s\n", cue_path,
|
||||
strerror(errno));
|
||||
|
@ -622,7 +621,7 @@ int gdi_find_track(const char *gdi_path, bool first,
|
|||
if (!fd)
|
||||
goto error;
|
||||
|
||||
if (!intfstream_open(fd, gdi_path, RFILE_MODE_READ, -1))
|
||||
if (!intfstream_open(fd, gdi_path, RFILE_MODE_READ, RFILE_HINT_NONE))
|
||||
{
|
||||
RARCH_LOG("Could not open GDI file '%s': %s\n", gdi_path,
|
||||
strerror(errno));
|
||||
|
|
|
@ -157,7 +157,8 @@ static void autosave_thread(void *data)
|
|||
if (differ)
|
||||
{
|
||||
/* Should probably deal with this more elegantly. */
|
||||
RFILE *file = filestream_open(save->path, RFILE_MODE_WRITE, -1);
|
||||
RFILE *file = filestream_open(save->path,
|
||||
RFILE_MODE_WRITE, RFILE_HINT_NONE);
|
||||
|
||||
if (file)
|
||||
{
|
||||
|
@ -564,7 +565,8 @@ static void task_save_handler(retro_task_t *task)
|
|||
|
||||
if (!state->file)
|
||||
{
|
||||
state->file = filestream_open(state->path, RFILE_MODE_WRITE, -1);
|
||||
state->file = filestream_open(state->path, RFILE_MODE_WRITE,
|
||||
RFILE_HINT_NONE);
|
||||
|
||||
if (!state->file)
|
||||
return;
|
||||
|
@ -736,7 +738,8 @@ static void task_load_handler(retro_task_t *task)
|
|||
|
||||
if (!state->file)
|
||||
{
|
||||
state->file = filestream_open(state->path, RFILE_MODE_READ, -1);
|
||||
state->file = filestream_open(state->path, RFILE_MODE_READ,
|
||||
RFILE_HINT_NONE);
|
||||
|
||||
if (!state->file)
|
||||
goto error;
|
||||
|
|
Loading…
Reference in New Issue