mirror of
https://github.com/libretro/RetroArch
synced 2025-02-25 21:41:03 +00:00
Update
This commit is contained in:
parent
acc24b8a57
commit
47b4de7bbf
@ -31,6 +31,8 @@
|
|||||||
#include <retro_common_api.h>
|
#include <retro_common_api.h>
|
||||||
#include <boolean.h>
|
#include <boolean.h>
|
||||||
|
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
RETRO_BEGIN_DECLS
|
RETRO_BEGIN_DECLS
|
||||||
|
|
||||||
typedef struct RFILE RFILE;
|
typedef struct RFILE RFILE;
|
||||||
@ -81,6 +83,12 @@ bool filestream_write_file(const char *path, const void *data, ssize_t size);
|
|||||||
|
|
||||||
int filestream_putc(RFILE *stream, int c);
|
int filestream_putc(RFILE *stream, int c);
|
||||||
|
|
||||||
|
int filestream_vprintf(RFILE *stream, const char* format, va_list args);
|
||||||
|
|
||||||
|
int filestream_printf(RFILE *stream, const char* format, ...);
|
||||||
|
|
||||||
|
int filestream_error(RFILE *stream);
|
||||||
|
|
||||||
int filestream_get_fd(RFILE *stream);
|
int filestream_get_fd(RFILE *stream);
|
||||||
|
|
||||||
int filestream_flush(RFILE *stream);
|
int filestream_flush(RFILE *stream);
|
||||||
|
@ -24,12 +24,12 @@
|
|||||||
#define __LIBRETRO_SDK_FILE_STREAM_TRANSFORMS_H
|
#define __LIBRETRO_SDK_FILE_STREAM_TRANSFORMS_H
|
||||||
|
|
||||||
#include <retro_common_api.h>
|
#include <retro_common_api.h>
|
||||||
|
|
||||||
#include <streams/file_stream.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
RETRO_BEGIN_DECLS
|
RETRO_BEGIN_DECLS
|
||||||
|
|
||||||
|
typedef struct RFILE RFILE;
|
||||||
|
|
||||||
#define FILE RFILE
|
#define FILE RFILE
|
||||||
|
|
||||||
#define fopen rfopen
|
#define fopen rfopen
|
||||||
@ -38,9 +38,14 @@ RETRO_BEGIN_DECLS
|
|||||||
#define fseek rfseek
|
#define fseek rfseek
|
||||||
#define fread rfread
|
#define fread rfread
|
||||||
#define fgets rfgets
|
#define fgets rfgets
|
||||||
|
#define fgetc rfgetc
|
||||||
#define fwrite rfwrite
|
#define fwrite rfwrite
|
||||||
|
#define fputc rfputc
|
||||||
|
#define fprintf rfprintf
|
||||||
|
#define ferror rferror
|
||||||
|
#define feof rfeof
|
||||||
|
|
||||||
RFILE* rfopen(const char *path, char *mode);
|
RFILE* rfopen(const char *path, const char *mode);
|
||||||
|
|
||||||
int rfclose(RFILE* stream);
|
int rfclose(RFILE* stream);
|
||||||
|
|
||||||
@ -53,9 +58,19 @@ size_t rfread(void* buffer,
|
|||||||
|
|
||||||
char *rfgets(char *buffer, int maxCount, RFILE* stream);
|
char *rfgets(char *buffer, int maxCount, RFILE* stream);
|
||||||
|
|
||||||
|
int rfgetc(RFILE* stream);
|
||||||
|
|
||||||
size_t rfwrite(void const* buffer,
|
size_t rfwrite(void const* buffer,
|
||||||
size_t elementSize, size_t elementCount, RFILE* stream);
|
size_t elementSize, size_t elementCount, RFILE* stream);
|
||||||
|
|
||||||
|
int rfputc(int character, RFILE * stream);
|
||||||
|
|
||||||
|
int rfprintf(RFILE * stream, const char * format, ...);
|
||||||
|
|
||||||
|
int rferror(RFILE* stream);
|
||||||
|
|
||||||
|
int rfeof(RFILE* stream);
|
||||||
|
|
||||||
RETRO_END_DECLS
|
RETRO_END_DECLS
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -529,6 +529,34 @@ int filestream_putc(RFILE *stream, int c)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int filestream_vprintf(RFILE *stream, const char* format, va_list args)
|
||||||
|
{
|
||||||
|
static char buffer[8 * 1024];
|
||||||
|
int numChars = vsprintf(buffer, format, args);
|
||||||
|
|
||||||
|
if (numChars < 0)
|
||||||
|
return -1;
|
||||||
|
else if (numChars == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return filestream_write(stream, buffer, numChars);
|
||||||
|
}
|
||||||
|
|
||||||
|
int filestream_printf(RFILE *stream, const char* format, ...)
|
||||||
|
{
|
||||||
|
va_list vl;
|
||||||
|
int result;
|
||||||
|
va_start(vl, format);
|
||||||
|
result = filestream_vprintf(stream, format, vl);
|
||||||
|
va_end(vl);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
int filestream_error(RFILE *stream)
|
||||||
|
{
|
||||||
|
return ferror(stream->fp);
|
||||||
|
}
|
||||||
|
|
||||||
int filestream_close(RFILE *stream)
|
int filestream_close(RFILE *stream)
|
||||||
{
|
{
|
||||||
if (!stream)
|
if (!stream)
|
||||||
|
@ -22,8 +22,9 @@
|
|||||||
|
|
||||||
#include <streams/file_stream.h>
|
#include <streams/file_stream.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
RFILE* rfopen(const char *path, char *mode)
|
RFILE* rfopen(const char *path, const char *mode)
|
||||||
{
|
{
|
||||||
unsigned int retro_mode = RFILE_MODE_READ_TEXT;
|
unsigned int retro_mode = RFILE_MODE_READ_TEXT;
|
||||||
if (strstr(mode, "r"))
|
if (strstr(mode, "r"))
|
||||||
@ -64,8 +65,38 @@ char *rfgets(char *buffer, int maxCount, RFILE* stream)
|
|||||||
return filestream_gets(stream, buffer, maxCount);
|
return filestream_gets(stream, buffer, maxCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int rfgetc(RFILE* stream)
|
||||||
|
{
|
||||||
|
return filestream_getc(stream);
|
||||||
|
}
|
||||||
|
|
||||||
size_t rfwrite(void const* buffer,
|
size_t rfwrite(void const* buffer,
|
||||||
size_t elementSize, size_t elementCount, RFILE* stream)
|
size_t elementSize, size_t elementCount, RFILE* stream)
|
||||||
{
|
{
|
||||||
return filestream_write(stream, buffer, elementSize*elementCount);
|
return filestream_write(stream, buffer, elementSize*elementCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int rfputc(int character, RFILE * stream)
|
||||||
|
{
|
||||||
|
return filestream_putc(stream, character);
|
||||||
|
}
|
||||||
|
|
||||||
|
int rfprintf(RFILE * stream, const char * format, ...)
|
||||||
|
{
|
||||||
|
int result;
|
||||||
|
va_list vl;
|
||||||
|
va_start(vl, format);
|
||||||
|
result = filestream_vprintf(stream, format, vl);
|
||||||
|
va_end(vl);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
int rferror(RFILE* stream)
|
||||||
|
{
|
||||||
|
return filestream_error(stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
int rfeof(RFILE* stream)
|
||||||
|
{
|
||||||
|
return filestream_eof(stream);
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user