Implement Q_fopen() for Windows.
This is done in shared.c so that's available for both the client / server / renderer and the game. A work around for older game DLL will be added at a later time.
This commit is contained in:
parent
37ea3e1d58
commit
a87e34906c
|
@ -257,7 +257,7 @@ int Q_strlcat(char *dst, const char *src, int size);
|
||||||
/* Unicode wrappers around fopen(). */
|
/* Unicode wrappers around fopen(). */
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#error "Not implemented yet"
|
FILE *Q_fopen(const char *file, const char *mode);
|
||||||
#else
|
#else
|
||||||
#define Q_fopen(file, mode) fopen(file, mode)
|
#define Q_fopen(file, mode) fopen(file, mode)
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1144,6 +1144,35 @@ Q_strlcat(char *dst, const char *src, int size)
|
||||||
return (d - dst) + Q_strlcpy(d, src, size);
|
return (d - dst) + Q_strlcpy(d, src, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* An unicode compatible fopen() Wrapper for Windows.
|
||||||
|
*/
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
FILE *Q_fopen(const char *file, const char *mode)
|
||||||
|
{
|
||||||
|
WCHAR wfile[MAX_OSPATH];
|
||||||
|
WCHAR wmode[16];
|
||||||
|
|
||||||
|
int len = MultiByteToWideChar(CP_UTF8, 0, file, -1, wfile, MAX_OSPATH);
|
||||||
|
|
||||||
|
if (len > 0)
|
||||||
|
{
|
||||||
|
if (MultiByteToWideChar(CP_UTF8, 0, mode, -1, wmode, 16) > 0)
|
||||||
|
{
|
||||||
|
FILE *ret;
|
||||||
|
if(_wfopen_s(&ret, wfile, wmode) == 0)
|
||||||
|
{
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* =====================================================================
|
* =====================================================================
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue