mirror of
https://github.com/git/git.git
synced 2026-04-01 12:30:09 +02:00
mingw.c: Use the O_BINARY flag to open files
On Windows, non-text files must be opened using the O_BINARY flag. MinGW does this for us automatically, but Microsoft Visual C++ does not. So let's be explicit. Signed-off-by: Frank Li <lznuaa@gmail.com> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
committed by
Johannes Schindelin
parent
c124c96792
commit
62d2d6829c
@@ -161,7 +161,7 @@ int mingw_open (const char *filename, int oflags, ...)
|
||||
if (!strcmp(filename, "/dev/null"))
|
||||
filename = "nul";
|
||||
|
||||
fd = open(filename, oflags, mode);
|
||||
fd = open(filename, oflags | O_BINARY, mode);
|
||||
|
||||
if (fd < 0 && (oflags & O_CREAT) && errno == EACCES) {
|
||||
DWORD attrs = GetFileAttributes(filename);
|
||||
@@ -354,7 +354,7 @@ int mkstemp(char *template)
|
||||
char *filename = mktemp(template);
|
||||
if (filename == NULL)
|
||||
return -1;
|
||||
return open(filename, O_RDWR | O_CREAT, 0600);
|
||||
return open(filename, O_RDWR | O_CREAT | O_BINARY, 0600);
|
||||
}
|
||||
|
||||
int gettimeofday(struct timeval *tv, void *tz)
|
||||
|
||||
Reference in New Issue
Block a user