mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-24 01:01:15 -06:00
avrdude: Add a Windows-aware fopen
This commit is contained in:
parent
a2ce4c00de
commit
fba4d109c8
3 changed files with 11 additions and 5 deletions
|
|
@ -102,9 +102,8 @@ static int fmt_autodetect(char * fname, unsigned section);
|
|||
|
||||
|
||||
|
||||
static FILE *fopen_and_seek(const char *filename, const char *mode, unsigned section)
|
||||
FILE *fopen_utf8(const char *filename, const char *mode)
|
||||
{
|
||||
FILE *file;
|
||||
// On Windows we need to convert the filename to UTF-16
|
||||
#if defined(WIN32NATIVE)
|
||||
static wchar_t fname_buffer[PATH_MAX];
|
||||
|
|
@ -113,10 +112,15 @@ static FILE *fopen_and_seek(const char *filename, const char *mode, unsigned sec
|
|||
if (MultiByteToWideChar(CP_UTF8, 0, filename, -1, fname_buffer, PATH_MAX) == 0) { return NULL; }
|
||||
if (MultiByteToWideChar(CP_ACP, 0, mode, -1, mode_buffer, MAX_MODE_LEN) == 0) { return NULL; }
|
||||
|
||||
file = _wfopen(fname_buffer, mode_buffer);
|
||||
return _wfopen(fname_buffer, mode_buffer);
|
||||
#else
|
||||
file = fopen(filename, mode);
|
||||
return fopen(filename, mode);
|
||||
#endif
|
||||
}
|
||||
|
||||
static FILE *fopen_and_seek(const char *filename, const char *mode, unsigned section)
|
||||
{
|
||||
FILE *file = fopen_utf8(filename, mode);
|
||||
|
||||
if (file == NULL) {
|
||||
return NULL;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue