MCPcopy Create free account
hub / github.com/GaijinEntertainment/daScript / fsdirFilter

Function fsdirFilter

modules/dasSQLITE/sqlite/shell.c:6300–6340  ·  view source on GitHub ↗

** xFilter callback. ** ** idxNum==1 PATH parameter only ** idxNum==2 Both PATH and DIR supplied */

Source from the content-addressed store, hash-verified

6298** idxNum==2 Both PATH and DIR supplied
6299*/
6300static int fsdirFilter(
6301 sqlite3_vtab_cursor *cur,
6302 int idxNum, const char *idxStr,
6303 int argc, sqlite3_value **argv
6304){
6305 const char *zDir = 0;
6306 fsdir_cursor *pCur = (fsdir_cursor*)cur;
6307 (void)idxStr;
6308 fsdirResetCursor(pCur);
6309
6310 if( idxNum==0 ){
6311 fsdirSetErrmsg(pCur, "table function fsdir requires an argument");
6312 return SQLITE_ERROR;
6313 }
6314
6315 assert( argc==idxNum && (argc==1 || argc==2) );
6316 zDir = (const char*)sqlite3_value_text(argv[0]);
6317 if( zDir==0 ){
6318 fsdirSetErrmsg(pCur, "table function fsdir requires a non-NULL argument");
6319 return SQLITE_ERROR;
6320 }
6321 if( argc==2 ){
6322 pCur->zBase = (const char*)sqlite3_value_text(argv[1]);
6323 }
6324 if( pCur->zBase ){
6325 pCur->nBase = (int)strlen(pCur->zBase)+1;
6326 pCur->zPath = sqlite3_mprintf("%s/%s", pCur->zBase, zDir);
6327 }else{
6328 pCur->zPath = sqlite3_mprintf("%s", zDir);
6329 }
6330
6331 if( pCur->zPath==0 ){
6332 return SQLITE_NOMEM;
6333 }
6334 if( fileLinkStat(pCur->zPath, &pCur->sStat) ){
6335 fsdirSetErrmsg(pCur, "cannot stat file: %s", pCur->zPath);
6336 return SQLITE_ERROR;
6337 }
6338
6339 return SQLITE_OK;
6340}
6341
6342/*
6343** SQLite will invoke this method one or more times while planning a query

Callers

nothing calls this directly

Calls 4

fsdirResetCursorFunction · 0.85
fsdirSetErrmsgFunction · 0.85
assertFunction · 0.85
fileLinkStatFunction · 0.85

Tested by

no test coverage detected