mingw_fopen: report ENOENT for invalid file names
On Windows, certain characters are prohibited in file names, most prominently the colon. When fopen() is called with such an invalid file name, the underlying Windows API actually reports a particular error, but since there is no suitable errno value, this error is translated to EINVAL. Detect the case and report ENOENT instead. Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
13b57da833
commit
e5b313442a
@ -423,6 +423,8 @@ FILE *mingw_fopen (const char *filename, const char *otype)
|
||||
return NULL;
|
||||
}
|
||||
file = _wfopen(wfilename, wotype);
|
||||
if (!file && GetLastError() == ERROR_INVALID_NAME)
|
||||
errno = ENOENT;
|
||||
if (file && hide && set_hidden_flag(wfilename, 1))
|
||||
warning("could not mark '%s' as hidden.", filename);
|
||||
return file;
|
||||
|
Reference in New Issue
Block a user