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

Function arListCommand

modules/dasSQLITE/sqlite/shell.c:22263–22298  ·  view source on GitHub ↗

** Implementation of .ar "lisT" command. */

Source from the content-addressed store, hash-verified

22261** Implementation of .ar "lisT" command.
22262*/
22263static int arListCommand(ArCommand *pAr){
22264 const char *zSql = "SELECT %s FROM %s WHERE %s";
22265 const char *azCols[] = {
22266 "name",
22267 "lsmode(mode), sz, datetime(mtime, 'unixepoch'), name"
22268 };
22269
22270 char *zWhere = 0;
22271 sqlite3_stmt *pSql = 0;
22272 int rc;
22273
22274 rc = arCheckEntries(pAr);
22275 arWhereClause(&rc, pAr, &zWhere);
22276
22277 shellPreparePrintf(pAr->db, &rc, &pSql, zSql, azCols[pAr->bVerbose],
22278 pAr->zSrcTable, zWhere);
22279 if( pAr->bDryRun ){
22280 utf8_printf(pAr->p->out, "%s\n", sqlite3_sql(pSql));
22281 }else{
22282 while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pSql) ){
22283 if( pAr->bVerbose ){
22284 utf8_printf(pAr->p->out, "%s % 10d %s %s\n",
22285 sqlite3_column_text(pSql, 0),
22286 sqlite3_column_int(pSql, 1),
22287 sqlite3_column_text(pSql, 2),
22288 sqlite3_column_text(pSql, 3)
22289 );
22290 }else{
22291 utf8_printf(pAr->p->out, "%s\n", sqlite3_column_text(pSql, 0));
22292 }
22293 }
22294 }
22295 shellFinalize(&rc, pSql);
22296 sqlite3_free(zWhere);
22297 return rc;
22298}
22299
22300
22301/*

Callers 1

arDotCommandFunction · 0.85

Calls 5

arCheckEntriesFunction · 0.85
arWhereClauseFunction · 0.85
shellPreparePrintfFunction · 0.85
utf8_printfFunction · 0.85
shellFinalizeFunction · 0.85

Tested by

no test coverage detected