]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Update the code in test_delete.c to use the "win32" VFS if SQLITE_OS_WIN is
authordan <dan@noemail.net>
Thu, 13 Apr 2017 15:36:47 +0000 (15:36 +0000)
committerdan <dan@noemail.net>
Thu, 13 Apr 2017 15:36:47 +0000 (15:36 +0000)
defined.

FossilOrigin-Name: fa9bb7b768027677f7e7d5a196ba5b245dfc8d8986ccd101c8dab671bd15719d

manifest
manifest.uuid
src/test_delete.c

index f673b16642a1ae530e9a27267bae95c1e9a6d762..7ae648ed42d59912bf2fa73fcbfe36ed91f77f53 100644 (file)
--- 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
index 20be91a4beb8e7df28a9d3811c4431912fd83aaa..bb7a422d0cefb6b756f1bb13dabd2800bad18788 100644 (file)
@@ -1 +1 @@
-6f54ffd151b0eca6f9ef57ac54802584a839cfc7373f10c100fc18c855edcc0a
\ No newline at end of file
+fa9bb7b768027677f7e7d5a196ba5b245dfc8d8986ccd101c8dab671bd15719d
\ No newline at end of file
index ca61965b27b6cddeb309d73119f5b6167c5aaf8d..ba15826290a3c12bbaec5045d6d1c19df3640497 100644 (file)
 **     above.
 */
 
-#if SQLITE_OS_WIN
-#  include <io.h>
-#  define F_OK 0
-#else
+#ifndef SQLITE_OS_WIN
 #  include <unistd.h>
+#  include <errno.h>
 #endif
 #include <string.h>
-#include <errno.h>
+#include <assert.h>
 #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 && i<sizeof(azFmt)/sizeof(azFmt[0]); i++){
     sqlite3_snprintf(nBuf, zBuf, azFmt[i], zFile);
-    rc = sqlite3DeleteUnlinkIfExists(zBuf, 0);
+    rc = sqlite3DeleteUnlinkIfExists(pVfs, zBuf, 0);
     if( rc==0 && i!=0 ){
       sqlite3Delete83Name(zBuf);
-      rc = sqlite3DeleteUnlinkIfExists(zBuf, 0);
+      rc = sqlite3DeleteUnlinkIfExists(pVfs, zBuf, 0);
     }
   }
 
@@ -128,7 +146,7 @@ SQLITE_API int sqlite3_delete_database(
       int bExists;
       sqlite3_snprintf(nBuf, zBuf, p->zFmt, zFile, iChunk+p->iOffset);
       if( p->b83 ) sqlite3Delete83Name(zBuf);
-      rc = sqlite3DeleteUnlinkIfExists(zBuf, &bExists);
+      rc = sqlite3DeleteUnlinkIfExists(pVfs, zBuf, &bExists);
       if( bExists==0 || rc!=0 ) break;
     }
   }