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