mirror of
https://github.com/libretro/libretro-common.git
synced 2025-03-02 13:35:59 +00:00
Updates
This commit is contained in:
parent
d61c588b7f
commit
a645c24e69
@ -23,7 +23,6 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <dynamic/dylib.h>
|
||||
#include <encodings/win32.h>
|
||||
|
||||
#ifdef NEED_DYNAMIC
|
||||
|
||||
@ -35,7 +34,7 @@
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
static TCHAR last_dyn_error[512] = {0};
|
||||
static char last_dyn_error[512];
|
||||
|
||||
static void set_dl_error(void)
|
||||
{
|
||||
@ -46,16 +45,11 @@ static void set_dl_error(void)
|
||||
NULL,
|
||||
err,
|
||||
MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT),
|
||||
(LPTSTR)last_dyn_error,
|
||||
last_dyn_error,
|
||||
sizeof(last_dyn_error) - 1,
|
||||
NULL) == 0)
|
||||
{
|
||||
WCHAR_TO_CHAR_ALLOC(last_dyn_error, last_dyn_error_str)
|
||||
snprintf(last_dyn_error_str, sizeof(last_dyn_error) - 1,
|
||||
snprintf(last_dyn_error, sizeof(last_dyn_error) - 1,
|
||||
"unknown error %lu", err);
|
||||
if (last_dyn_error_str)
|
||||
free(last_dyn_error_str);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -71,12 +65,8 @@ dylib_t dylib_load(const char *path)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
int prevmode = SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX);
|
||||
dylib_t lib = NULL;
|
||||
CHAR_TO_WCHAR_ALLOC(path, path_wide)
|
||||
dylib_t lib = LoadLibrary(path);
|
||||
|
||||
lib = LoadLibrary(path_wide);
|
||||
|
||||
free(path_wide);
|
||||
SetErrorMode(prevmode);
|
||||
|
||||
if (!lib)
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include <retro_common.h>
|
||||
#include <encodings/win32.h>
|
||||
|
||||
#include <boolean.h>
|
||||
#include <retro_stat.h>
|
||||
@ -35,9 +34,6 @@ struct RDIR *retro_opendir(const char *name)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
char path_buf[1024] = {0};
|
||||
#ifdef UNICODE
|
||||
wchar_t pathW[1024] = {0};
|
||||
#endif
|
||||
#endif
|
||||
struct RDIR *rdir = (struct RDIR*)calloc(1, sizeof(*rdir));
|
||||
|
||||
@ -45,13 +41,8 @@ struct RDIR *retro_opendir(const char *name)
|
||||
return NULL;
|
||||
|
||||
#if defined(_WIN32)
|
||||
#ifdef UNICODE
|
||||
snprintf(path_buf, sizeof(path_buf), "%s\\*", name);
|
||||
MultiByteToWideChar(CP_UTF8, 0, path_buf, -1, pathW, sizeof(pathW) / sizeof(pathW[0]));
|
||||
rdir->directory = FindFirstFileW(pathW, &rdir->entry);
|
||||
#else
|
||||
rdir->directory = FindFirstFile(path_buf, &rdir->entry);
|
||||
#endif
|
||||
#elif defined(VITA) || defined(PSP)
|
||||
rdir->directory = sceIoDopen(name);
|
||||
#elif defined(_3DS)
|
||||
@ -103,11 +94,7 @@ int retro_readdir(struct RDIR *rdir)
|
||||
const char *retro_dirent_get_name(struct RDIR *rdir)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
memset(rdir->path, 0, sizeof(rdir->path));
|
||||
#ifdef UNICODE
|
||||
utf16_to_char_string((const uint16_t*)rdir->entry.cFileName, rdir->path, sizeof(rdir->path));
|
||||
#endif
|
||||
return rdir->path;
|
||||
return rdir->entry.cFileName;
|
||||
#elif defined(VITA) || defined(PSP) || defined(__CELLOS_LV2__)
|
||||
return rdir->entry.d_name;
|
||||
#else
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <encodings/win32.h>
|
||||
#include <retro_miscellaneous.h>
|
||||
|
||||
#if defined(_WIN32)
|
||||
@ -104,12 +103,8 @@ static bool path_stat(const char *path, enum stat_mode mode, int32_t *size)
|
||||
#elif defined(_WIN32)
|
||||
WIN32_FILE_ATTRIBUTE_DATA file_info;
|
||||
GET_FILEEX_INFO_LEVELS fInfoLevelId = GetFileExInfoStandard;
|
||||
CHAR_TO_WCHAR_ALLOC(path, path_wide)
|
||||
|
||||
DWORD ret = GetFileAttributesEx(path_wide, fInfoLevelId, &file_info);
|
||||
|
||||
if (path_wide)
|
||||
free(path_wide);
|
||||
DWORD ret = GetFileAttributesEx(path, fInfoLevelId, &file_info);
|
||||
|
||||
if (ret == 0)
|
||||
return false;
|
||||
@ -211,7 +206,7 @@ bool mkdir_norecurse(const char *dir)
|
||||
#elif defined(PSP) || defined(_3DS)
|
||||
if ((ret == -1) && path_is_directory(dir))
|
||||
ret = 0;
|
||||
#else
|
||||
#else
|
||||
if (ret < 0 && errno == EEXIST && path_is_directory(dir))
|
||||
ret = 0;
|
||||
#endif
|
||||
|
@ -35,12 +35,12 @@ extern "C" {
|
||||
#ifndef snprintf
|
||||
#define snprintf c99_snprintf_retro__
|
||||
#endif
|
||||
|
||||
|
||||
int c99_snprintf_retro__(char *outBuf, size_t size, const char *format, ...);
|
||||
#endif
|
||||
|
||||
/* Pre-MSVC 2010 compilers don't implement vsnprintf in a cross-platform manner? Not sure about this one. */
|
||||
#if _MSC_VER < 1600
|
||||
#if _MSC_VER < 1600
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#ifndef vsnprintf
|
||||
@ -53,6 +53,7 @@ extern "C" {
|
||||
}
|
||||
#endif
|
||||
|
||||
#undef UNICODE /* Do not bother with UNICODE at this time. */
|
||||
#include <direct.h>
|
||||
#include <stddef.h>
|
||||
#include <math.h>
|
||||
|
@ -45,10 +45,6 @@
|
||||
#include <time.h>
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <encodings/win32.h>
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) && !defined(_XBOX)
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
|
@ -26,7 +26,6 @@
|
||||
#include <errno.h>
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include <encodings/win32.h>
|
||||
# ifdef _MSC_VER
|
||||
# define setmode _setmode
|
||||
# endif
|
||||
@ -75,17 +74,10 @@ struct RFILE
|
||||
|
||||
#define HAVE_BUFFERED_IO 1
|
||||
|
||||
#ifdef _WIN32
|
||||
#define MODE_STR_READ L"r"
|
||||
#define MODE_STR_READ_UNBUF L"rb"
|
||||
#define MODE_STR_WRITE_UNBUF L"wb"
|
||||
#define MODE_STR_WRITE_PLUS L"w+"
|
||||
#else
|
||||
#define MODE_STR_READ "r"
|
||||
#define MODE_STR_READ_UNBUF "rb"
|
||||
#define MODE_STR_WRITE_UNBUF "wb"
|
||||
#define MODE_STR_WRITE_PLUS "w+"
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_BUFFERED_IO)
|
||||
FILE *fp;
|
||||
@ -115,12 +107,7 @@ RFILE *filestream_open(const char *path, unsigned mode, ssize_t len)
|
||||
int flags = 0;
|
||||
int mode_int = 0;
|
||||
#if defined(HAVE_BUFFERED_IO)
|
||||
#ifdef _WIN32
|
||||
const wchar_t *mode_str = NULL;
|
||||
wchar_t path_wide[PATH_MAX_LENGTH] = {0};
|
||||
#else
|
||||
const char *mode_str = NULL;
|
||||
#endif
|
||||
#endif
|
||||
RFILE *stream = (RFILE*)calloc(1, sizeof(*stream));
|
||||
|
||||
@ -211,12 +198,7 @@ RFILE *filestream_open(const char *path, unsigned mode, ssize_t len)
|
||||
#if defined(HAVE_BUFFERED_IO)
|
||||
if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
MultiByteToWideChar(CP_UTF8, 0, path, -1, path_wide, sizeof(path_wide) / sizeof(path_wide[0]));
|
||||
stream->fp = _wfopen(path_wide, mode_str);
|
||||
#else
|
||||
stream->fp = fopen(path, mode_str);
|
||||
#endif
|
||||
if (!stream->fp)
|
||||
goto error;
|
||||
}
|
||||
@ -293,7 +275,7 @@ char *filestream_getline(RFILE *stream)
|
||||
}
|
||||
|
||||
newline[idx] = '\0';
|
||||
return newline;
|
||||
return newline;
|
||||
}
|
||||
|
||||
char *filestream_gets(RFILE *stream, char *s, size_t len)
|
||||
@ -344,7 +326,7 @@ ssize_t filestream_seek(RFILE *stream, ssize_t offset, int whence)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MMAP
|
||||
/* Need to check stream->mapped because this function is
|
||||
/* Need to check stream->mapped because this function is
|
||||
* called in filestream_open() */
|
||||
if (stream->mapped && stream->hints & RFILE_HINT_MMAP)
|
||||
{
|
||||
@ -414,7 +396,7 @@ ssize_t filestream_tell(RFILE *stream)
|
||||
return ftell(stream->fp);
|
||||
#endif
|
||||
#ifdef HAVE_MMAP
|
||||
/* Need to check stream->mapped because this function
|
||||
/* Need to check stream->mapped because this function
|
||||
* is called in filestream_open() */
|
||||
if (stream->mapped && stream->hints & RFILE_HINT_MMAP)
|
||||
return stream->mappos;
|
||||
|
Loading…
x
Reference in New Issue
Block a user