Add the "filetype()" SQL function for interpreting file modes to the
fileio.c extension. FossilOrigin-Name: 58c0c74c407d93f48930a4964b6cc48f008b522d193a62a559de0e6a319a8bd0
This commit is contained in:
parent
a5676c4d2d
commit
6c237b1fa7
@ -357,6 +357,30 @@ static void writefileFunc(
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** SQL function: filetype(MODE)
|
||||
**
|
||||
** Based on the integer mode, return one of "file", "directory", or "symlink".
|
||||
*/
|
||||
static void fileTypeFunc(
|
||||
sqlite3_context *context,
|
||||
int argc,
|
||||
sqlite3_value **argv
|
||||
){
|
||||
const char *zMode;
|
||||
int iMode = sqlite3_value_int(argv[0]);
|
||||
if( S_ISLNK(iMode) ){
|
||||
zMode = "symlink";
|
||||
}else if( S_ISREG(iMode) ){
|
||||
zMode = "file";
|
||||
}else if( S_ISDIR(iMode) ){
|
||||
zMode = "directory";
|
||||
}else{
|
||||
zMode = "unknown";
|
||||
}
|
||||
sqlite3_result_text(context, zMode, -1, SQLITE_STATIC);
|
||||
}
|
||||
|
||||
#ifndef SQLITE_OMIT_VIRTUALTABLE
|
||||
|
||||
/*
|
||||
@ -768,6 +792,10 @@ int sqlite3_fileio_init(
|
||||
rc = sqlite3_create_function(db, "writefile", -1, SQLITE_UTF8, 0,
|
||||
writefileFunc, 0, 0);
|
||||
}
|
||||
if( rc==SQLITE_OK ){
|
||||
rc = sqlite3_create_function(db, "fileType", 1, SQLITE_UTF8, 0,
|
||||
fileTypeFunc, 0, 0);
|
||||
}
|
||||
if( rc==SQLITE_OK ){
|
||||
rc = fsdirRegister(db);
|
||||
}
|
||||
|
12
manifest
12
manifest
@ -1,5 +1,5 @@
|
||||
C The\s".ar"\scommand\sdeduces\swhether\sor\snot\sthe\starget\sfile\sis\na\sZIP\sor\sSQLAR\sand\sdoes\sthe\sappropropriate\sthing.\s\sThe\s"-z"\soption\sis\somitted.\nThe\s"--append"\soption\sis\sadded\sto\sopen\sauxiliary\sdatabases\susing\sapndvfs.
|
||||
D 2018-01-10T15:17:34.832
|
||||
C Add\sthe\s"filetype()"\sSQL\sfunction\sfor\sinterpreting\sfile\smodes\sto\sthe\nfileio.c\sextension.
|
||||
D 2018-01-10T15:53:06.284
|
||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||
F Makefile.in 12b6daa4bdb03fa87da27cbc205ff88ace645475b5be79414a3038b68ade14cb
|
||||
@ -277,7 +277,7 @@ F ext/misc/compress.c dd4f8a6d0baccff3c694757db5b430f3bbd821d8686d1fc24df55cf9f0
|
||||
F ext/misc/csv.c 1a009b93650732e22334edc92459c4630b9fa703397cbb3c8ca279921a36ca11
|
||||
F ext/misc/dbdump.c 3509fa6b8932d04e932d6b6b827b6a82ca362781b8e8f3c77336f416793e215e
|
||||
F ext/misc/eval.c f971962e92ebb8b0a4e6b62949463ee454d88fa2
|
||||
F ext/misc/fileio.c 5176893c15421e9c459f25478e3c1b066d19317b676ff0b142862de4e701af82
|
||||
F ext/misc/fileio.c 19d4e5590a3505dc12e652a64730a935a865bb70eb2bb8bfe75767355a09a6e2
|
||||
F ext/misc/fuzzer.c 7c64b8197bb77b7d64eff7cac7848870235d4c25
|
||||
F ext/misc/ieee754.c f190d0cc5182529acb15babd177781be1ac1718c
|
||||
F ext/misc/json1.c dbe086615b9546c156bf32b9378fc09383b58bd17513b866cfd24c1e15281984
|
||||
@ -1697,7 +1697,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 9340a2c145bcb4b38d19276a16264a37341c617f0554d66e1da653f1d9f85163
|
||||
R 9764fa4832552c458077bab9b9143a51
|
||||
P 430d1a7daa823ae53606b7a158af4e7c16f62ff9b072b90606524e7c3f6131df
|
||||
R 54a0e19016ae7cc0ce7d6a9a20dca28f
|
||||
U drh
|
||||
Z fa68d24d45da969d4d63bf64e8c4f030
|
||||
Z d67640218b4e3095d4e0ccc9365f61ee
|
||||
|
@ -1 +1 @@
|
||||
430d1a7daa823ae53606b7a158af4e7c16f62ff9b072b90606524e7c3f6131df
|
||||
58c0c74c407d93f48930a4964b6cc48f008b522d193a62a559de0e6a319a8bd0
|
Loading…
Reference in New Issue
Block a user