Revert "Windows long paths fix"

This commit is contained in:
Autechre 2020-12-24 16:40:15 +01:00 committed by GitHub
parent 2bd017bd76
commit 9e6ee680b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -21,7 +21,6 @@
*/ */
#include <compat/fopen_utf8.h> #include <compat/fopen_utf8.h>
#include <retro_miscellaneous.h>
#include <encodings/utf.h> #include <encodings/utf.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -37,13 +36,9 @@
void *fopen_utf8(const char * filename, const char * mode) void *fopen_utf8(const char * filename, const char * mode)
{ {
const char * filename_local = NULL;
const char* windows_long_prefix = "\\\\?\\";
char long_filename[PATH_MAX_LENGTH];
#if defined(LEGACY_WIN32) #if defined(LEGACY_WIN32)
FILE *ret = NULL; FILE *ret = NULL;
filename_local = utf8_to_local_string_alloc(filename); char * filename_local = utf8_to_local_string_alloc(filename);
if (!filename_local) if (!filename_local)
return NULL; return NULL;
@ -52,17 +47,7 @@ void *fopen_utf8(const char * filename, const char * mode)
free(filename_local); free(filename_local);
return ret; return ret;
#else #else
#ifdef _WIN32 wchar_t * filename_w = utf8_to_utf16_string_alloc(filename);
/*
prefix to tell Windows to bypass the ~260 characters limit in many I/O APIs
https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file
*/
snprintf(long_filename, PATH_MAX_LENGTH, "%s%s", windows_long_prefix, filename);
filename_local = long_filename;
#else
filename_local = filename;
#endif
wchar_t * filename_w = utf8_to_utf16_string_alloc(filename_local);
wchar_t * mode_w = utf8_to_utf16_string_alloc(mode); wchar_t * mode_w = utf8_to_utf16_string_alloc(mode);
FILE* ret = NULL; FILE* ret = NULL;