Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Add the shell tool ".ar --update" command. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | sqlar-shell-support |
Files: | files | file ages | folders |
SHA3-256: |
825e3c037b03fc09d581aeda0193ff1d |
User & Date: | dan 2017-12-13 20:17:18.759 |
Context
2017-12-14
| ||
13:55 | Merge latest trunk changes into this branch. (check-in: 803156cba8 user: dan tags: sqlar-shell-support) | |
2017-12-13
| ||
20:17 | Add the shell tool ".ar --update" command. (check-in: 825e3c037b user: dan tags: sqlar-shell-support) | |
20:04 | Add support for the "--list" command. And for arguments to the "--extract" command. (check-in: 32c4fa2552 user: dan tags: sqlar-shell-support) | |
Changes
Changes to src/shell.c.in.
︙ | ︙ | |||
4324 4325 4326 4327 4328 4329 4330 | } } } return SQLITE_OK; } | < < < < < < < < | 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 | } } } return SQLITE_OK; } /* ** 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 returned. |
︙ | ︙ | |||
4496 4497 4498 4499 4500 4501 4502 | sqlite3_free(zDir); sqlite3_free(zWhere); return rc; } /* | | > > > | | > | 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 | sqlite3_free(zDir); sqlite3_free(zWhere); return rc; } /* ** Implementation of .ar "create" and "update" commands. ** ** Create the "sqlar" table in the database if it does not already exist. ** Then add each file in the azFile[] array to the archive. Directories ** are added recursively. If argument bVerbose is non-zero, a message is ** printed on stdout for each file archived. ** ** The create command is the same as update, except that it drops ** any existing "sqlar" table before beginning. */ static int arCreateUpdate( ShellState *p, /* Shell state pointer */ sqlite3 *db, ArCommand *pAr, /* Command arguments and options */ int bUpdate ){ const char *zSql = "SELECT name, mode, mtime, data FROM fsdir(?, ?)"; const char *zCreate = "CREATE TABLE IF NOT EXISTS sqlar(" "name TEXT PRIMARY KEY, -- name of the file\n" "mode INT, -- access permissions\n" "mtime INT, -- last modification time\n" |
︙ | ︙ | |||
4531 4532 4533 4534 4535 4536 4537 | Bytef *aCompress = 0; /* Compression buffer */ int nCompress = 0; /* Size of compression buffer */ rc = sqlite3_exec(db, "SAVEPOINT ar;", 0, 0, 0); if( rc!=SQLITE_OK ) return rc; | > | | > | 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 | Bytef *aCompress = 0; /* Compression buffer */ int nCompress = 0; /* Size of compression buffer */ rc = sqlite3_exec(db, "SAVEPOINT ar;", 0, 0, 0); if( rc!=SQLITE_OK ) return rc; if( bUpdate==0 ){ rc = sqlite3_exec(db, zDrop, 0, 0, 0); if( rc!=SQLITE_OK ) return rc; } rc = sqlite3_exec(db, zCreate, 0, 0, 0); shellPrepare(db, &rc, zInsert, &pInsert); shellPrepare(db, &rc, zSql, &pStmt); sqlite3_bind_text(pStmt, 2, pAr->zDir, -1, SQLITE_STATIC); for(i=0; i<pAr->nArg && rc==SQLITE_OK; i++){ |
︙ | ︙ | |||
4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 | rc = sqlite3_exec(db, "RELEASE ar;", 0, 0, 0); } shellFinalize(&rc, pStmt); shellFinalize(&rc, pInsert); sqlite3_free(aCompress); return rc; } /* ** Implementation of ".ar" dot command. */ static int arDotCommand( ShellState *pState, /* Current shell tool state */ char **azArg, /* Array of arguments passed to dot command */ | > > > > > > > > > > > > > > > > > > > > > > > > | 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 | rc = sqlite3_exec(db, "RELEASE ar;", 0, 0, 0); } shellFinalize(&rc, pStmt); shellFinalize(&rc, pInsert); sqlite3_free(aCompress); return rc; } /* ** Implementation of .ar "Create" command. ** ** Create the "sqlar" table in the database if it does not already exist. ** Then add each file in the azFile[] array to the archive. Directories ** are added recursively. If argument bVerbose is non-zero, a message is ** printed on stdout for each file archived. */ static int arCreateCommand( ShellState *p, /* Shell state pointer */ sqlite3 *db, ArCommand *pAr /* Command arguments and options */ ){ return arCreateUpdate(p, db, pAr, 0); } /* ** Implementation of .ar "Update" command. */ static int arUpdateCmd(ShellState *p, sqlite3 *db, ArCommand *pAr){ return arCreateUpdate(p, db, pAr, 1); } /* ** Implementation of ".ar" dot command. */ static int arDotCommand( ShellState *pState, /* Current shell tool state */ char **azArg, /* Array of arguments passed to dot command */ |
︙ | ︙ |