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

Function arCheckEntries

modules/dasSQLITE/sqlite/shell.c:22190–22220  ·  view source on GitHub ↗

** This function assumes that all arguments within the ArCommand.azArg[] ** array refer to archive members, as for the --extract, --list or --remove ** commands. It checks that each of them are "present". If any specified ** file is not present in the archive, an error is printed to stderr and an ** error code returned. Otherwise, if all specified arguments are present ** in the archive, SQLITE_OK

Source from the content-addressed store, hash-verified

22188** Linux.
22189*/
22190static int arCheckEntries(ArCommand *pAr){
22191 int rc = SQLITE_OK;
22192 if( pAr->nArg ){
22193 int i, j;
22194 sqlite3_stmt *pTest = 0;
22195 const char *zSel = (pAr->bGlob)
22196 ? "SELECT name FROM %s WHERE glob($name,name)"
22197 : "SELECT name FROM %s WHERE name=$name";
22198
22199 shellPreparePrintf(pAr->db, &rc, &pTest, zSel, pAr->zSrcTable);
22200 j = sqlite3_bind_parameter_index(pTest, "$name");
22201 for(i=0; i<pAr->nArg && rc==SQLITE_OK; i++){
22202 char *z = pAr->azArg[i];
22203 int n = strlen30(z);
22204 int bOk = 0;
22205 while( n>0 && z[n-1]=='/' ) n--;
22206 z[n] = '\0';
22207 sqlite3_bind_text(pTest, j, z, -1, SQLITE_STATIC);
22208 if( SQLITE_ROW==sqlite3_step(pTest) ){
22209 bOk = 1;
22210 }
22211 shellReset(&rc, pTest);
22212 if( rc==SQLITE_OK && bOk==0 ){
22213 utf8_printf(stderr, "not found in archive: %s\n", z);
22214 rc = SQLITE_ERROR;
22215 }
22216 }
22217 shellFinalize(&rc, pTest);
22218 }
22219 return rc;
22220}
22221
22222/*
22223** Format a WHERE clause that can be used against the "sqlar" table to

Callers 3

arListCommandFunction · 0.85
arRemoveCommandFunction · 0.85
arExtractCommandFunction · 0.85

Calls 5

shellPreparePrintfFunction · 0.85
strlen30Function · 0.85
shellResetFunction · 0.85
utf8_printfFunction · 0.85
shellFinalizeFunction · 0.85

Tested by

no test coverage detected