owncloud: set _fmode variable to set file ops to binary mode.

Esse commit está contido em:
Klaas Freitag
2012-03-07 14:46:47 +01:00
commit 3676ca623a
4 arquivos alterados com 24 adições e 0 exclusões
+15
Ver Arquivo
@@ -779,6 +779,15 @@ static csync_vio_method_handle_t *owncloud_open(const char *durl,
}
#else
writeCtx->tmpFileName = c_strdup( "/tmp/csync.XXXXXX" );
#ifdef _WIN32
if( c_tmpname( writeCtx->tmpFileName ) == 0 ) {
_fmode = _O_BINARY;
writeCtx->fd = open( writeCtx->tmpFileName, O_RDWR | O_CREAT | O_EXCL, 0600 );
} else {
writeCtx->fd = -1;
}
#else
writeCtx->fd = mkstemp( writeCtx->tmpFileName );
#endif
DEBUG_WEBDAV(("opening temp directory %s\n", writeCtx->tmpFileName ));
@@ -873,6 +882,9 @@ static int owncloud_close(csync_vio_method_handle_t *fhandle) {
}
/* and open it again to read from */
#ifdef _WIN32
_fmode = _O_BINARY;
#endif
if (( writeCtx->fd = open( writeCtx->tmpFileName, O_RDONLY )) < 0) {
errno = EIO;
ret = -1;
@@ -939,6 +951,9 @@ static ssize_t owncloud_read(csync_vio_method_handle_t *fhandle, void *buf, size
if( writeCtx->fd == -1 ) {
/* open the downloaded file to read from */
#ifdef _WIN32
_fmode = _O_BINARY;
#endif
if (( writeCtx->fd = open( writeCtx->tmpFileName, O_RDONLY )) < 0) {
DEBUG_WEBDAV(("Could not open local file %s\n", writeCtx->tmpFileName ));
errno = EIO;
+3
Ver Arquivo
@@ -54,6 +54,9 @@ int csync_exclude_load(CSYNC *ctx, const char *fname) {
char *buf = NULL;
char *entry = NULL;
#ifdef _WIN32
_fmode = _O_BINARY;
#endif
fd = open(fname, O_RDONLY);
if (fd < 0) {
return -1;
+3
Ver Arquivo
@@ -119,6 +119,9 @@ static pid_t _csync_lock_read(const char *lockfile) {
int fd, pid;
/* Read PID from existing lock */
#ifdef _WIN32
_fmode = _O_BINARY;
#endif
if ((fd = open(lockfile, O_RDONLY)) < 0) {
return -1;
}
+3
Ver Arquivo
@@ -55,6 +55,9 @@ static int _csync_statedb_check(const char *statedb) {
sqlite3 *db = NULL;
/* check db version */
#ifdef _WIN32
_fmode = _O_BINARY;
#endif
fd = open(statedb, O_RDONLY);
if (fd >= 0) {
if (read(fd, (void *) buf, (size_t) BUF_SIZE - 1) >= 0) {