mirror of https://github.com/snes9xgit/snes9x.git
win32: make _twfullpath work with NULL destination
This commit is contained in:
parent
4ede9b18cc
commit
5b01fa2dc1
|
@ -48,12 +48,18 @@ extern "C" int _twopen(const char *filename, int oflag, int pmode) {
|
|||
return _wopen(Utf8ToWide(filename), oflag, pmode);
|
||||
}
|
||||
|
||||
extern "C" void _twfullpath(char* dst, const char* src, int len) {
|
||||
extern "C" char *_twfullpath(char* dst, const char* src, int len) {
|
||||
wchar_t *resolved = _wfullpath(NULL, Utf8ToWide(src), MAX_PATH);
|
||||
strncpy(dst, WideToUtf8(resolved), len);
|
||||
WideToUtf8 utf8resolved = WideToUtf8(resolved);
|
||||
free(resolved);
|
||||
if (dst == NULL)
|
||||
{
|
||||
len = strlen(utf8resolved) + 1;
|
||||
dst = (char *)malloc(len);
|
||||
}
|
||||
strncpy(dst, utf8resolved, len);
|
||||
dst[len - 1] = '\0';
|
||||
return;
|
||||
return dst;
|
||||
}
|
||||
|
||||
#endif // UNICODE
|
||||
|
|
|
@ -18,7 +18,7 @@ extern "C" {
|
|||
FILE *_tfwopen(const char *filename, const char *mode );
|
||||
int _twremove(const char *filename );
|
||||
int _twopen(const char *filename, int oflag, int pmode);
|
||||
void _twfullpath(char* dst, const char* src, int len);
|
||||
char *_twfullpath(char* dst, const char* src, int len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue