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

Function arCheckEntries

lib-src/sqlite/shell.c:16426–16456  ·  view source on GitHub ↗

** This function assumes that all arguments within the ArCommand.azArg[] ** array refer to archive members, as for the --extract or --list 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 is returne

Source from the content-addressed store, hash-verified

16424** Linux.
16425*/
16426static int arCheckEntries(ArCommand *pAr){
16427 int rc = SQLITE_OK;
16428 if( pAr->nArg ){
16429 int i, j;
16430 sqlite3_stmt *pTest = 0;
16431
16432 shellPreparePrintf(pAr->db, &rc, &pTest,
16433 "SELECT name FROM %s WHERE name=$name",
16434 pAr->zSrcTable
16435 );
16436 j = sqlite3_bind_parameter_index(pTest, "$name");
16437 for(i=0; i<pAr->nArg && rc==SQLITE_OK; i++){
16438 char *z = pAr->azArg[i];
16439 int n = strlen30(z);
16440 int bOk = 0;
16441 while( n>0 && z[n-1]=='/' ) n--;
16442 z[n] = '\0';
16443 sqlite3_bind_text(pTest, j, z, -1, SQLITE_STATIC);
16444 if( SQLITE_ROW==sqlite3_step(pTest) ){
16445 bOk = 1;
16446 }
16447 shellReset(&rc, pTest);
16448 if( rc==SQLITE_OK && bOk==0 ){
16449 utf8_printf(stderr, "not found in archive: %s\n", z);
16450 rc = SQLITE_ERROR;
16451 }
16452 }
16453 shellFinalize(&rc, pTest);
16454 }
16455 return rc;
16456}
16457
16458/*
16459** Format a WHERE clause that can be used against the "sqlar" table to

Callers 2

arListCommandFunction · 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