mirror of
https://git.proxmox.com/git/libgit2
synced 2026-01-08 19:34:33 +00:00
win32: Open or create files in binary mode
On windows, unless we use the O_BINARY flag in the open() call, the file I/O routines will perform line ending conversion (\r\n => \n on input, \n => \r\n on output). In addition to the performance penalty, most files in the object database are binary and will, therefore, become corrupted by this conversion. Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
This commit is contained in:
parent
0f39781c25
commit
7a6cf81537
@ -3,13 +3,13 @@
|
||||
|
||||
int gitfo_open(const char *path, int flags)
|
||||
{
|
||||
int fd = open(path, flags);
|
||||
int fd = open(path, flags | O_BINARY);
|
||||
return fd >= 0 ? fd : git_os_error();
|
||||
}
|
||||
|
||||
int gitfo_creat(const char *path, int mode)
|
||||
{
|
||||
int fd = creat(path, mode);
|
||||
int fd = open(path, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, mode);
|
||||
return fd >= 0 ? fd : git_os_error();
|
||||
}
|
||||
|
||||
|
||||
@ -15,6 +15,10 @@
|
||||
#include <time.h>
|
||||
#include <dirent.h>
|
||||
|
||||
#if !defined(O_BINARY)
|
||||
#define O_BINARY 0
|
||||
#endif
|
||||
|
||||
#define GITFO_BUF_INIT {NULL, 0}
|
||||
|
||||
typedef int git_file;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user