MCPcopy Create free account
hub / github.com/audacity/audacity / fsdirFilter

Function fsdirFilter

lib-src/sqlite/shell.c:2935–2975  ·  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

2933** idxNum==2 Both PATH and DIR supplied
2934*/
2935static int fsdirFilter(
2936 sqlite3_vtab_cursor *cur,
2937 int idxNum, const char *idxStr,
2938 int argc, sqlite3_value **argv
2939){
2940 const char *zDir = 0;
2941 fsdir_cursor *pCur = (fsdir_cursor*)cur;
2942 (void)idxStr;
2943 fsdirResetCursor(pCur);
2944
2945 if( idxNum==0 ){
2946 fsdirSetErrmsg(pCur, "table function fsdir requires an argument");
2947 return SQLITE_ERROR;
2948 }
2949
2950 assert( argc==idxNum && (argc==1 || argc==2) );
2951 zDir = (const char*)sqlite3_value_text(argv[0]);
2952 if( zDir==0 ){
2953 fsdirSetErrmsg(pCur, "table function fsdir requires a non-NULL argument");
2954 return SQLITE_ERROR;
2955 }
2956 if( argc==2 ){
2957 pCur->zBase = (const char*)sqlite3_value_text(argv[1]);
2958 }
2959 if( pCur->zBase ){
2960 pCur->nBase = (int)strlen(pCur->zBase)+1;
2961 pCur->zPath = sqlite3_mprintf("%s/%s", pCur->zBase, zDir);
2962 }else{
2963 pCur->zPath = sqlite3_mprintf("%s", zDir);
2964 }
2965
2966 if( pCur->zPath==0 ){
2967 return SQLITE_NOMEM;
2968 }
2969 if( fileLinkStat(pCur->zPath, &pCur->sStat) ){
2970 fsdirSetErrmsg(pCur, "cannot stat file: %s", pCur->zPath);
2971 return SQLITE_ERROR;
2972 }
2973
2974 return SQLITE_OK;
2975}
2976
2977/*
2978** SQLite will invoke this method one or more times while planning a query

Callers

nothing calls this directly

Calls 3

fsdirResetCursorFunction · 0.85
fsdirSetErrmsgFunction · 0.85
fileLinkStatFunction · 0.85

Tested by

no test coverage detected