aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordan <dan@noemail.net>2010-08-17 05:55:35 +0000
committerdan <dan@noemail.net>2010-08-17 05:55:35 +0000
commitfc6a621a9600c26686776f8759760ae5324db81d (patch)
tree13e95d745d52cb2b01a47dba2463ae1f1bc9c0d6 /src
parent919fc66ea736f5c0842e6bf6c8096c2f14886fb9 (diff)
downloadsqlite-fc6a621a9600c26686776f8759760ae5324db81d.tar.gz
sqlite-fc6a621a9600c26686776f8759760ae5324db81d.zip
Fix some non-ANSI C code in test_demovfs.c. Also change the same file so that attempting to delete a file that does not exist does not return an error.
FossilOrigin-Name: 07570ce38051a05d6e8a71e39766850f6719ac07
Diffstat (limited to 'src')
-rw-r--r--src/test_demovfs.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/test_demovfs.c b/src/test_demovfs.c
index 7cdae8067..8c51192b4 100644
--- a/src/test_demovfs.c
+++ b/src/test_demovfs.c
@@ -127,6 +127,7 @@
#include <sys/param.h>
#include <unistd.h>
#include <time.h>
+#include <errno.h>
/*
** Size of the write buffer used by journal files in bytes.
@@ -136,6 +137,11 @@
#endif
/*
+** The maximum pathname length supported by this VFS.
+*/
+#define MAXPATHNAME 512
+
+/*
** When using this VFS, the sqlite3_file* handles that SQLite uses are
** actually pointers to instances of type DemoFile.
*/
@@ -446,16 +452,19 @@ static int demoOpen(
** file has been synced to disk before returning.
*/
static int demoDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){
- int rc;
+ int rc; /* Return code */
+
rc = unlink(zPath);
+ if( rc!=0 && errno==ENOENT ) return SQLITE_OK;
+
if( rc==0 && dirSync ){
int dfd; /* File descriptor open on directory */
int i; /* Iterator variable */
- char zDir[pVfs->mxPathname+1];/* Name of directory containing file zPath */
+ char zDir[MAXPATHNAME+1]; /* Name of directory containing file zPath */
/* Figure out the directory name from the path of the file deleted. */
- sqlite3_snprintf(pVfs->mxPathname, zDir, "%s", zPath);
- zDir[pVfs->mxPathname] = '\0';
+ sqlite3_snprintf(MAXPATHNAME, zDir, "%s", zPath);
+ zDir[MAXPATHNAME] = '\0';
for(i=strlen(zDir); i>1 && zDir[i]!='/'; i++);
zDir[i] = '\0';
@@ -524,13 +533,13 @@ static int demoFullPathname(
int nPathOut, /* Size of output buffer in bytes */
char *zPathOut /* Pointer to output buffer */
){
- char zDir[pVfs->mxPathname+1];
+ char zDir[MAXPATHNAME+1];
if( zPath[0]=='/' ){
zDir[0] = '\0';
}else{
getcwd(zDir, sizeof(zDir));
}
- zDir[pVfs->mxPathname] = '\0';
+ zDir[MAXPATHNAME] = '\0';
sqlite3_snprintf(nPathOut, zPathOut, "%s/%s", zDir, zPath);
zPathOut[nPathOut-1] = '\0';
@@ -609,7 +618,7 @@ sqlite3_vfs *sqlite3_demovfs(void){
static sqlite3_vfs demovfs = {
1, /* iVersion */
sizeof(DemoFile), /* szOsFile */
- 512, /* mxPathname */
+ MAXPATHNAME, /* mxPathname */
0, /* pNext */
"demo", /* zName */
0, /* pAppData */