ZipfileLFH lfh; /* Local File Header for current entry */
i64 iDataOff; /* Offset in zipfile to data */
u32 mTime; /* Extended mtime value */
- int flags;
+ int flags; /* Flags byte (see below for bits) */
};
/*
typedef struct ZipfileEntry ZipfileEntry;
struct ZipfileEntry {
char *zPath; /* Path of zipfile entry */
+ i64 iRowid; /* Rowid for this value if queried */
u8 *aCdsEntry; /* Buffer containing entire CDS entry */
int nCdsEntry; /* Size of buffer aCdsEntry[] in bytes */
- ZipfileEntry *pNext;
+ ZipfileEntry *pNext; /* Next element in in-memory CDS */
};
typedef struct ZipfileTab ZipfileTab;
u8 *aBuffer; /* Temporary buffer used for various tasks */
/* The following are used by write transactions only */
- ZipfileEntry *pEntry; /* Linked list of all files (if pWriteFd!=0) */
+ ZipfileEntry *pFirstEntry; /* Linked list of all files (if pWriteFd!=0) */
+ ZipfileEntry *pLastEntry; /* Last element in pFirstEntry list */
FILE *pWriteFd; /* File handle open on zip archive */
i64 szCurrent; /* Current size of zip archive */
i64 szOrig; /* Size of archive at start of transaction */
return SQLITE_OK;
}
+/*
+** Add object pNew to the end of the linked list that begins at
+** ZipfileTab.pFirstEntry and ends with pLastEntry.
+*/
+static void zipfileAddEntry(ZipfileTab *pTab, ZipfileEntry *pNew){
+ assert( (pTab->pFirstEntry==0)==(pTab->pLastEntry==0) );
+ assert( pNew->pNext==0 );
+ if( pTab->pFirstEntry==0 ){
+ pTab->pFirstEntry = pTab->pLastEntry = pNew;
+ }else{
+ assert( pTab->pLastEntry->pNext==0 );
+ pTab->pLastEntry->pNext = pNew;
+ pTab->pLastEntry = pNew;
+ }
+}
+
static int zipfileLoadDirectory(ZipfileTab *pTab){
ZipfileEOCD eocd;
int rc;
pNew->zPath[nFile] = '\0';
pNew->aCdsEntry = (u8*)&pNew->zPath[nFile+1];
pNew->nCdsEntry = ZIPFILE_CDS_FIXED_SZ+nFile+nExtra+nComment;
+ pNew->pNext = 0;
memcpy(pNew->aCdsEntry, aRec, pNew->nCdsEntry);
-
- pNew->pNext = pTab->pEntry;
- pTab->pEntry = pNew;
+ zipfileAddEntry(pTab, pNew);
}
iOff += ZIPFILE_CDS_FIXED_SZ+nFile+nExtra+nComment;
pNew->zPath = (char*)&pNew[1];
pNew->aCdsEntry = (u8*)&pNew->zPath[nPath+1];
pNew->nCdsEntry = ZIPFILE_CDS_FIXED_SZ + nPath + pCds->nExtra;
+ pNew->pNext = 0;
memcpy(pNew->zPath, zPath, nPath+1);
aWrite = pNew->aCdsEntry;
if( pNew==0 ){
rc = SQLITE_NOMEM;
}else{
- pNew->pNext = pTab->pEntry;
- pTab->pEntry = pNew;
+ zipfileAddEntry(pTab, pNew);
}
}
ZipfileEntry *pEntry;
ZipfileEntry *pNext;
- for(pEntry=pTab->pEntry; pEntry; pEntry=pNext){
+ for(pEntry=pTab->pFirstEntry; pEntry; pEntry=pNext){
pNext = pEntry->pNext;
sqlite3_free(pEntry);
}
- pTab->pEntry = 0;
+ pTab->pFirstEntry = 0;
+ pTab->pLastEntry = 0;
fclose(pTab->pWriteFd);
pTab->pWriteFd = 0;
pTab->szCurrent = 0;
int rc = SQLITE_OK;
if( pTab->pWriteFd ){
i64 iOffset = pTab->szCurrent;
- ZipfileEntry *pEntry;
+ ZipfileEntry *p;
ZipfileEOCD eocd;
int nEntry = 0;
/* Write out all entries */
- for(pEntry=pTab->pEntry; rc==SQLITE_OK && pEntry; pEntry=pEntry->pNext){
- rc = zipfileAppendData(pTab, pEntry->aCdsEntry, pEntry->nCdsEntry);
+ for(p=pTab->pFirstEntry; rc==SQLITE_OK && p; p=p->pNext){
+ rc = zipfileAppendData(pTab, p->aCdsEntry, p->nCdsEntry);
nEntry++;
}
-C Update\sext/misc/zipfile.c\sto\ssupport\screating\sand\sadding\sentries\sto\sexisting\nzip\sarchives.
-D 2017-12-29T20:19:03.196
+C Rearrange\sthings\sa\sbit\sso\sthat\swriting\sto\sa\szipfile\sdoes\snot\sinvert\sthe\sorder\nof\sobjects\sit\scontains.
+D 2017-12-30T14:26:29.195
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F Makefile.in ceb40bfcb30ebba8e1202b34c56ff7e13e112f9809e2381d99be32c2726058f5
F ext/misc/vtablog.c 31d0d8f4406795679dcd3a67917c213d3a2a5fb3ea5de35f6e773491ed7e13c9
F ext/misc/vtshim.c 1976e6dd68dd0d64508c91a6dfab8e75f8aaf6cd
F ext/misc/wholenumber.c 784b12543d60702ebdd47da936e278aa03076212
-F ext/misc/zipfile.c d9e0b0a4fdb4cb82ad22fd19d75563efdb1d6f812d62438bd30819781c282357
+F ext/misc/zipfile.c cf093f797331e51fa6c0358698bc89d08a88d06cdf11484ee4ea9d079145289b
F ext/rbu/rbu.c ea7d1b7eb44c123a2a619332e19fe5313500705c4a58aaa1887905c0d83ffc2e
F ext/rbu/rbu1.test 43836fac8c7179a358eaf38a8a1ef3d6e6285842
F ext/rbu/rbu10.test 1846519a438697f45e9dcb246908af81b551c29e1078d0304fae83f1fed7e9ee
F test/writecrash.test f1da7f7adfe8d7f09ea79b42e5ca6dcc41102f27f8e334ad71539501ddd910cc
F test/zeroblob.test 3857870fe681b8185654414a9bccfde80b62a0fa
F test/zerodamage.test e59a56443d6298ecf7435f618f0b27654f0c849e
-F test/zipfile.test c5167d0d13ed7165b1982ac46b8aa94d65bdf41d94dd82f1d17ad2250650356c
+F test/zipfile.test 63059e59024cacd01ba4c32a445cf75aac21393ff4460bddd1dc1ef4b78dd8bc
F tool/GetFile.cs a15e08acb5dd7539b75ba23501581d7c2b462cb5
F tool/GetTclKit.bat 8995df40c4209808b31f24de0b58f90930239a234f7591e3675d45bfbb990c5d
F tool/Replace.cs 02c67258801c2fb5f63231e0ac0f220b4b36ba91
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P b64681a644c419bb98d00980a6cb56ef5a0aff5ef5321955631f0b4c88aac283
-R 407639481a191f472cd3497cc84b9ac5
+P 2dec2dec592c0726ebe87b841b9c8d493dea7074a99f278eb1bf0b744d658a9d
+R 64b99b9622049272ef5b18e73b616095
U dan
-Z a9a0bf4010ca982b681b075b8e4b53ca
+Z 6ef5282c9c40bbaf3432c6295db23abc