From: dan Date: Thu, 13 Apr 2017 15:36:47 +0000 (+0000) Subject: Update the code in test_delete.c to use the "win32" VFS if SQLITE_OS_WIN is X-Git-Tag: version-3.19.0~65 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=44ae27ac32128553611e16d1e8c21cabe89aa3d0;p=thirdparty%2Fsqlite.git Update the code in test_delete.c to use the "win32" VFS if SQLITE_OS_WIN is defined. FossilOrigin-Name: fa9bb7b768027677f7e7d5a196ba5b245dfc8d8986ccd101c8dab671bd15719d --- diff --git a/manifest b/manifest index f673b16642..7ae648ed42 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Allow\sa\suser\scolumn\sname\sto\sbe\sused\son\sthe\sLHS\sof\sa\sMATCH\soperator\sin\sFTS5. -D 2017-04-13T09:45:21.225 +C Update\sthe\scode\sin\stest_delete.c\sto\suse\sthe\s"win32"\sVFS\sif\sSQLITE_OS_WIN\sis\ndefined. +D 2017-04-13T15:36:47.128 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc a4c0613a18663bda56d8cf76079ab6590a7c3602e54befb4bbdef76bcaa38b6a @@ -427,7 +427,7 @@ F src/test_bestindex.c d23f80d334c59662af69191854c76b8d3d0c8c96 F src/test_blob.c f65ac717da2618691cf9dad094e6da0219dcd208 F src/test_btree.c 8b2dc8b8848cf3a4db93f11578f075e82252a274 F src/test_config.c edcba290248dc18736dd814c9b95863c6762e0b35753048d8cbe5bf65f7abfbb -F src/test_delete.c af7eab5702f853fb1c62a5f7665e2234cf1ae17b +F src/test_delete.c e9c5a8556970f320ec7d5c10adbe33361c565553896ad443d0d5219146fe7308 F src/test_demovfs.c a0c3bdd45ed044115c2c9f7779e56eafff18741e F src/test_devsym.c 4e58dec2602d8e139ca08659f62a62450587cb58 F src/test_fs.c e16cbe68d3b107e00a907c20a9a02629870eb69b @@ -1571,7 +1571,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8e7b611863247a3bf46a96ec4b47d24c0ae0d60c9cee968a1cfd1da157e7c9bb -R c8c7d138fdb377c6e26ca103486be93e +P 6f54ffd151b0eca6f9ef57ac54802584a839cfc7373f10c100fc18c855edcc0a +R 059cacbdb1a4697b56b848d2127e6b17 U dan -Z 1fddd5a6b11f63b38f6de23209c4c2b7 +Z 0315456a90ada783d6692c926030f70c diff --git a/manifest.uuid b/manifest.uuid index 20be91a4be..bb7a422d0c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6f54ffd151b0eca6f9ef57ac54802584a839cfc7373f10c100fc18c855edcc0a \ No newline at end of file +fa9bb7b768027677f7e7d5a196ba5b245dfc8d8986ccd101c8dab671bd15719d \ No newline at end of file diff --git a/src/test_delete.c b/src/test_delete.c index ca61965b27..ba15826290 100644 --- a/src/test_delete.c +++ b/src/test_delete.c @@ -19,14 +19,12 @@ ** above. */ -#if SQLITE_OS_WIN -# include -# define F_OK 0 -#else +#ifndef SQLITE_OS_WIN # include +# include #endif #include -#include +#include #include "sqlite3.h" /* The following #defines are copied from test_multiplex.c */ @@ -57,30 +55,44 @@ static void sqlite3Delete83Name(char *z){ ** set *pbExists to true and unlink it. Or, if the file does not exist, ** set *pbExists to false before returning. ** -** If an error occurs, the value of errno is returned. Or, if no error -** occurs, zero is returned. +** If an error occurs, non-zero is returned. Or, if no error occurs, zero. */ -static int sqlite3DeleteUnlinkIfExists(const char *zFile, int *pbExists){ - int rc; +static int sqlite3DeleteUnlinkIfExists( + sqlite3_vfs *pVfs, + const char *zFile, + int *pbExists +){ + int rc = SQLITE_ERROR; +#if SQLITE_OS_WIN + if( pVfs ){ + if( pbExists ) *pbExists = 1; + rc = pVfs->xDelete(pVfs, zFile, 0); + if( rc==SQLITE_IOERR_DELETE_NOENT ){ + if( pbExists ) *pbExists = 0; + rc = SQLITE_OK; + } + } +#else + assert( pVfs==0 ); rc = access(zFile, F_OK); if( rc ){ if( errno==ENOENT ){ if( pbExists ) *pbExists = 0; - return 0; + rc = SQLITE_OK; } - return errno; + }else{ + if( pbExists ) *pbExists = 1; + rc = unlink(zFile); } - if( pbExists ) *pbExists = 1; - rc = unlink(zFile); - if( rc ) return errno; - return 0; +#endif + return rc; } /* ** Delete the database file identified by the string argument passed to this ** function. The string must contain a filename, not an SQLite URI. */ -SQLITE_API int sqlite3_delete_database( +int sqlite3_delete_database( const char *zFile /* File to delete */ ){ char *zBuf; /* Buffer to sprintf() filenames to */ @@ -103,6 +115,12 @@ SQLITE_API int sqlite3_delete_database( { "%s-wal%03d", SQLITE_MULTIPLEX_WAL_8_3_OFFSET, 1 }, }; +#ifdef SQLITE_OS_WIN + sqlite3_vfs *pVfs = sqlite3_vfs_find("win32"); +#else + sqlite3_vfs *pVfs = 0; +#endif + /* Allocate a buffer large enough for any of the files that need to be ** deleted. */ nBuf = (int)strlen(zFile) + 100; @@ -113,10 +131,10 @@ SQLITE_API int sqlite3_delete_database( ** journal, wal and shm files. */ for(i=0; rc==0 && izFmt, zFile, iChunk+p->iOffset); if( p->b83 ) sqlite3Delete83Name(zBuf); - rc = sqlite3DeleteUnlinkIfExists(zBuf, &bExists); + rc = sqlite3DeleteUnlinkIfExists(pVfs, zBuf, &bExists); if( bExists==0 || rc!=0 ) break; } }