diff --git a/modules/csync_owncloud.c b/modules/csync_owncloud.c index 5f03e2fc2..9bffcebec 100644 --- a/modules/csync_owncloud.c +++ b/modules/csync_owncloud.c @@ -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; diff --git a/src/csync_exclude.c b/src/csync_exclude.c index 1aa45aa7d..3ffe93eb0 100644 --- a/src/csync_exclude.c +++ b/src/csync_exclude.c @@ -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; diff --git a/src/csync_lock.c b/src/csync_lock.c index 15a437f46..630652907 100644 --- a/src/csync_lock.c +++ b/src/csync_lock.c @@ -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; } diff --git a/src/csync_statedb.c b/src/csync_statedb.c index ddcc3c220..963761a62 100644 --- a/src/csync_statedb.c +++ b/src/csync_statedb.c @@ -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) {