path: root/compat/mingw.c
diff options
authorJohannes Sixt <>2017-05-29 20:27:35 (GMT)
committerJunio C Hamano <>2017-06-02 01:40:04 (GMT)
commite5b313442ab7c700d0851e9dbe7d2b029e3893e5 (patch)
tree33b59e0d9f56bd9b405bcb8a19d84e9c81b1ed03 /compat/mingw.c
parent13b57da83384e9523943ea9d8ecf3ec7993ce56a (diff)
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 <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'compat/mingw.c')
1 files changed, 2 insertions, 0 deletions
diff --git a/compat/mingw.c b/compat/mingw.c
index 3fbfda5..b604a82 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -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;