From d2b8cb2dd5e084ee97b120c5aec1f0f903a520d4 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Mon, 23 May 2016 17:37:30 +0200 Subject: [PATCH] Fix compilation on Windows. --- coreapi/lpconfig.c | 2 +- coreapi/sqlite3_bctbx_vfs.c | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/coreapi/lpconfig.c b/coreapi/lpconfig.c index b397140e2..88070bb9d 100644 --- a/coreapi/lpconfig.c +++ b/coreapi/lpconfig.c @@ -439,7 +439,7 @@ LpConfig *lp_config_new_with_factory(const char *config_filename, const char *fa #ifdef RENAME_REQUIRES_NONEXISTENT_NEW_PATH if (fd == -1){ - pFile = bctbx_filecreate_and_open(lpconfig->g_bctbx_vfs,lpconfig->tmpfilename, "r+"); + pFile = bctbx_file_open(lpconfig->g_bctbx_vfs,lpconfig->tmpfilename, "r+"); if (fd){ ms_warning("Could not open %s but %s works, app may have crashed during last sync.",lpconfig->filename,lpconfig->tmpfilename); } diff --git a/coreapi/sqlite3_bctbx_vfs.c b/coreapi/sqlite3_bctbx_vfs.c index 006bd2e8e..a1178f101 100644 --- a/coreapi/sqlite3_bctbx_vfs.c +++ b/coreapi/sqlite3_bctbx_vfs.c @@ -206,11 +206,13 @@ static int sqlite3bctbx_nolockUnlock(sqlite3_file *pUnused, int unused){ * @return SQLITE_OK on success, SLITE_IOERR_FSYNC if an error occurred. */ static int sqlite3bctbx_Sync(sqlite3_file *p, int flags){ - sqlite3_bctbx_file *pFile = (sqlite3_bctbx_file*)p; - int rc; - - rc = fsync(pFile->pbctbx_file->fd); - return (rc==0 ? SQLITE_OK : SQLITE_IOERR_FSYNC); + sqlite3_bctbx_file *pFile = (sqlite3_bctbx_file*)p; +#if _WIN32 + return (FlushFileBuffers(pFile->pbctbx_file->fd) ? SQLITE_OK : SQLITE_IOERR_FSYNC); +#else + int rc = fsync(pFile->pbctbx_file->fd); + return (rc==0 ? SQLITE_OK : SQLITE_IOERR_FSYNC); +#endif }