** xFilter callback. ** ** idxNum==1 PATH parameter only ** idxNum==2 Both PATH and DIR supplied */
| 6298 | ** idxNum==2 Both PATH and DIR supplied |
| 6299 | */ |
| 6300 | static 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 |
nothing calls this directly
no test coverage detected