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

Function zipfileUpdate

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

** xUpdate method. */

Source from the content-addressed store, hash-verified

7407** xUpdate method.
7408*/
7409static int zipfileUpdate(
7410 sqlite3_vtab *pVtab,
7411 int nVal,
7412 sqlite3_value **apVal,
7413 sqlite_int64 *pRowid
7414){
7415 ZipfileTab *pTab = (ZipfileTab*)pVtab;
7416 int rc = SQLITE_OK; /* Return Code */
7417 ZipfileEntry *pNew = 0; /* New in-memory CDS entry */
7418
7419 u32 mode = 0; /* Mode for new entry */
7420 u32 mTime = 0; /* Modification time for new entry */
7421 i64 sz = 0; /* Uncompressed size */
7422 const char *zPath = 0; /* Path for new entry */
7423 int nPath = 0; /* strlen(zPath) */
7424 const u8 *pData = 0; /* Pointer to buffer containing content */
7425 int nData = 0; /* Size of pData buffer in bytes */
7426 int iMethod = 0; /* Compression method for new entry */
7427 u8 *pFree = 0; /* Free this */
7428 char *zFree = 0; /* Also free this */
7429 ZipfileEntry *pOld = 0;
7430 ZipfileEntry *pOld2 = 0;
7431 int bUpdate = 0; /* True for an update that modifies "name" */
7432 int bIsDir = 0;
7433 u32 iCrc32 = 0;
7434
7435 if( pTab->pWriteFd==0 ){
7436 rc = zipfileBegin(pVtab);
7437 if( rc!=SQLITE_OK ) return rc;
7438 }
7439
7440 /* If this is a DELETE or UPDATE, find the archive entry to delete. */
7441 if( sqlite3_value_type(apVal[0])!=SQLITE_NULL ){
7442 const char *zDelete = (const char*)sqlite3_value_text(apVal[0]);
7443 int nDelete = (int)strlen(zDelete);
7444 if( nVal>1 ){
7445 const char *zUpdate = (const char*)sqlite3_value_text(apVal[1]);
7446 if( zUpdate && zipfileComparePath(zUpdate, zDelete, nDelete)!=0 ){
7447 bUpdate = 1;
7448 }
7449 }
7450 for(pOld=pTab->pFirstEntry; 1; pOld=pOld->pNext){
7451 if( zipfileComparePath(pOld->cds.zFile, zDelete, nDelete)==0 ){
7452 break;
7453 }
7454 assert( pOld->pNext );
7455 }
7456 }
7457
7458 if( nVal>1 ){
7459 /* Check that "sz" and "rawdata" are both NULL: */
7460 if( sqlite3_value_type(apVal[5])!=SQLITE_NULL ){
7461 zipfileTableErr(pTab, "sz must be NULL");
7462 rc = SQLITE_CONSTRAINT;
7463 }
7464 if( sqlite3_value_type(apVal[6])!=SQLITE_NULL ){
7465 zipfileTableErr(pTab, "rawdata must be NULL");
7466 rc = SQLITE_CONSTRAINT;

Callers

nothing calls this directly

Calls 11

zipfileBeginFunction · 0.85
zipfileComparePathFunction · 0.85
zipfileTableErrFunction · 0.85
zipfileDeflateFunction · 0.85
zipfileGetModeFunction · 0.85
zipfileGetTimeFunction · 0.85
zipfileNewEntryFunction · 0.85
zipfileMtimeToDosFunction · 0.85
zipfileAppendEntryFunction · 0.85
zipfileAddEntryFunction · 0.85

Tested by

no test coverage detected