mirror of
https://github.com/libretro/RetroArch
synced 2025-03-06 04:13:52 +00:00
Add PSP/Vita ifdefs to retro_file.c
This commit is contained in:
parent
4ed3d66c04
commit
a6458d6ab6
@ -29,6 +29,7 @@ PPU_SRCS = frontend/frontend_salamander.c \
|
|||||||
libretro-common/hash/rhash.c \
|
libretro-common/hash/rhash.c \
|
||||||
libretro-common/string/string_list.c \
|
libretro-common/string/string_list.c \
|
||||||
libretro-common/compat/compat.c \
|
libretro-common/compat/compat.c \
|
||||||
|
libretro-common/file/retro_file.c \
|
||||||
libretro-common/file/config_file.c
|
libretro-common/file/config_file.c
|
||||||
|
|
||||||
ifeq ($(HAVE_LOGGER), 1)
|
ifeq ($(HAVE_LOGGER), 1)
|
||||||
|
@ -41,6 +41,7 @@ OBJS = frontend/frontend_salamander.o \
|
|||||||
libretro-common/file/retro_dirent.o \
|
libretro-common/file/retro_dirent.o \
|
||||||
libretro-common/compat/compat.o \
|
libretro-common/compat/compat.o \
|
||||||
libretro-common/file/config_file.o \
|
libretro-common/file/config_file.o \
|
||||||
|
libretro-common/file/retro_file.o \
|
||||||
libretro-common/hash/rhash.o \
|
libretro-common/hash/rhash.o \
|
||||||
psp1/kernel_functions.o
|
psp1/kernel_functions.o
|
||||||
|
|
||||||
|
@ -48,6 +48,7 @@ OBJ = frontend/frontend_salamander.o \
|
|||||||
libretro-common/hash/rhash.o \
|
libretro-common/hash/rhash.o \
|
||||||
libretro-common/string/string_list.o \
|
libretro-common/string/string_list.o \
|
||||||
libretro-common/file/dir_list.o \
|
libretro-common/file/dir_list.o \
|
||||||
|
libretro-common/file/retro_file.o \
|
||||||
libretro-common/file/retro_dirent.o \
|
libretro-common/file/retro_dirent.o \
|
||||||
libretro-common/compat/compat.o \
|
libretro-common/compat/compat.o \
|
||||||
libretro-common/file/config_file.o \
|
libretro-common/file/config_file.o \
|
||||||
|
@ -40,7 +40,11 @@
|
|||||||
|
|
||||||
struct RFILE
|
struct RFILE
|
||||||
{
|
{
|
||||||
|
#if defined(PSP) || defined(VITA)
|
||||||
|
SceUID fd;
|
||||||
|
#else
|
||||||
int fd;
|
int fd;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
RFILE *retro_fopen(const char *path, unsigned mode, ssize_t len)
|
RFILE *retro_fopen(const char *path, unsigned mode, ssize_t len)
|
||||||
@ -53,16 +57,28 @@ RFILE *retro_fopen(const char *path, unsigned mode, ssize_t len)
|
|||||||
switch (mode)
|
switch (mode)
|
||||||
{
|
{
|
||||||
case RFILE_MODE_READ:
|
case RFILE_MODE_READ:
|
||||||
|
#if defined(VITA) || defined(PSP)
|
||||||
|
stream->fd = sceIoOpen(path, O_RDONLY, 0777);
|
||||||
|
#else
|
||||||
stream->fd = open(path, O_RDONLY);
|
stream->fd = open(path, O_RDONLY);
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
case RFILE_MODE_WRITE:
|
case RFILE_MODE_WRITE:
|
||||||
|
#if defined(VITA) || defined(PSP)
|
||||||
|
stream->fd = sceIoOpen(path, O_WRONLY | O_CREAT, 0777);
|
||||||
|
#else
|
||||||
stream->fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
|
stream->fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
case RFILE_MODE_READ_WRITE:
|
case RFILE_MODE_READ_WRITE:
|
||||||
|
#if defined(VITA) || defined(PSP)
|
||||||
|
stream->fd = sceIoOpen(path, O_RDWR, 0777);
|
||||||
|
#else
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
stream->fd = open(path, O_RDWR | O_BINARY);
|
stream->fd = open(path, O_RDWR | O_BINARY);
|
||||||
#else
|
#else
|
||||||
stream->fd = open(path, O_RDWR);
|
stream->fd = open(path, O_RDWR);
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -75,21 +91,33 @@ ssize_t retro_fseek(RFILE *stream, ssize_t offset, int whence)
|
|||||||
if (!stream)
|
if (!stream)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
#if defined(VITA) || defined(PSP)
|
||||||
|
return sceIoLseek(stream->fd, (SceOff)offset, whence);
|
||||||
|
#else
|
||||||
return lseek(stream->fd, offset, whence);
|
return lseek(stream->fd, offset, whence);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t retro_fread(RFILE *stream, void *s, size_t len)
|
ssize_t retro_fread(RFILE *stream, void *s, size_t len)
|
||||||
{
|
{
|
||||||
if (!stream)
|
if (!stream)
|
||||||
return -1;
|
return -1;
|
||||||
|
#if defined(VITA) || defined(PSP)
|
||||||
|
return sceIoRead(stream->fd, s, len);
|
||||||
|
#else
|
||||||
return read(stream->fd, s, len);
|
return read(stream->fd, s, len);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t retro_fwrite(RFILE *stream, const void *s, size_t len)
|
ssize_t retro_fwrite(RFILE *stream, const void *s, size_t len)
|
||||||
{
|
{
|
||||||
if (!stream)
|
if (!stream)
|
||||||
return -1;
|
return -1;
|
||||||
|
#if defined(VITA) || defined(PSP)
|
||||||
|
return sceIoWrite(stream->fd, s, len);
|
||||||
|
#else
|
||||||
return write(stream->fd, s, len);
|
return write(stream->fd, s, len);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void retro_fclose(RFILE *stream)
|
void retro_fclose(RFILE *stream)
|
||||||
@ -97,7 +125,11 @@ void retro_fclose(RFILE *stream)
|
|||||||
if (!stream)
|
if (!stream)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
#if defined(VITA) || defined(PSP)
|
||||||
|
sceIoClose(stream->fd);
|
||||||
|
#else
|
||||||
close(stream->fd);
|
close(stream->fd);
|
||||||
|
#endif
|
||||||
free(stream);
|
free(stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user