diff options
author | drh <> | 2024-09-25 15:26:37 +0000 |
---|---|---|
committer | drh <> | 2024-09-25 15:26:37 +0000 |
commit | 7119a6c16b046a35b690fc8c56c8ee26a35cbad9 (patch) | |
tree | 7a6d3d725d4eb5aa2002cfa8f7332c182856cd54 /ext/misc/fileio.c | |
parent | 95f35b64da4e4507c3fd117f91f7ee2069c65723 (diff) | |
download | sqlite-7119a6c16b046a35b690fc8c56c8ee26a35cbad9.tar.gz sqlite-7119a6c16b046a35b690fc8c56c8ee26a35cbad9.zip |
Have the zipfile and fileio extensions use sqlite3_stdio.c when it is
available - such as when those extensions are preloaded into the CLI.
FossilOrigin-Name: 74bbb2b2b4507d9acbd91209a2ce341968e9ff64f3aebe9e817bfe488d39ae03
Diffstat (limited to 'ext/misc/fileio.c')
-rw-r--r-- | ext/misc/fileio.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/ext/misc/fileio.c b/ext/misc/fileio.c index c2ecab0b2..483ef0187 100644 --- a/ext/misc/fileio.c +++ b/ext/misc/fileio.c @@ -110,6 +110,13 @@ SQLITE_EXTENSION_INIT1 #include <time.h> #include <errno.h> +/* When used as part of the CLI, the sqlite3_stdio.h module will have +** been included before this one. In that case use the sqlite3_stdio.h +** #defines. If not, create our own for fopen(). +*/ +#ifndef _SQLITE3_STDIO_H_ +# define sqlite3_fopen fopen +#endif /* ** Structure of the fsdir() table-valued function @@ -142,7 +149,7 @@ static void readFileContents(sqlite3_context *ctx, const char *zName){ sqlite3 *db; int mxBlob; - in = fopen(zName, "rb"); + in = sqlite3_fopen(zName, "rb"); if( in==0 ){ /* File does not exist or is unreadable. Leave the result set to NULL. */ return; @@ -397,7 +404,7 @@ static int writeFile( sqlite3_int64 nWrite = 0; const char *z; int rc = 0; - FILE *out = fopen(zFile, "wb"); + FILE *out = sqlite3_fopen(zFile, "wb"); if( out==0 ) return 1; z = (const char*)sqlite3_value_blob(pData); if( z ){ |