mirror of
https://github.com/nzp-team/fteqw.git
synced 2024-11-22 20:11:44 +00:00
Fix up some backslashes in zips. Fix a typo.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@6090 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
eb157e09b8
commit
660f128569
1 changed files with 15 additions and 12 deletions
|
@ -1479,7 +1479,7 @@ struct zipcentralentry
|
|||
unsigned int crc32;
|
||||
qofs_t csize;
|
||||
qofs_t usize;
|
||||
unsigned short fnane_len;
|
||||
unsigned short fname_len;
|
||||
unsigned short extra_len;
|
||||
unsigned short comment_len;
|
||||
unsigned int disknum;
|
||||
|
@ -1637,7 +1637,7 @@ static qboolean FSZIP_ReadCentralEntry(zipfile_t *zip, qbyte *data, struct zipce
|
|||
struct tm t;
|
||||
entry->flags = 0;
|
||||
entry->fname = "";
|
||||
entry->fnane_len = 0;
|
||||
entry->fname_len = 0;
|
||||
|
||||
if (data[0] != 'P' ||
|
||||
data[1] != 'K' ||
|
||||
|
@ -1655,7 +1655,7 @@ static qboolean FSZIP_ReadCentralEntry(zipfile_t *zip, qbyte *data, struct zipce
|
|||
entry->crc32 = LittleU4FromPtr(data+16);
|
||||
entry->csize = LittleU4FromPtr(data+20);
|
||||
entry->usize = LittleU4FromPtr(data+24);
|
||||
entry->fnane_len = LittleU2FromPtr(data+28);
|
||||
entry->fname_len = LittleU2FromPtr(data+28);
|
||||
entry->extra_len = LittleU2FromPtr(data+30);
|
||||
entry->comment_len = LittleU2FromPtr(data+32);
|
||||
entry->disknum = LittleU2FromPtr(data+34);
|
||||
|
@ -1666,7 +1666,7 @@ static qboolean FSZIP_ReadCentralEntry(zipfile_t *zip, qbyte *data, struct zipce
|
|||
|
||||
//mark the filename position
|
||||
entry->fname = data+entry->cesize;
|
||||
entry->cesize += entry->fnane_len;
|
||||
entry->cesize += entry->fname_len;
|
||||
|
||||
memset(&t, 0, sizeof(t));
|
||||
t.tm_mday = (entry->lastmodfiledate&0x001f)>>0;
|
||||
|
@ -1743,7 +1743,7 @@ static qboolean FSZIP_ReadCentralEntry(zipfile_t *zip, qbyte *data, struct zipce
|
|||
//if (LittleU4FromPtr(extra+1) == qcrc32(?,entry->fname, entry->fnane_len))
|
||||
{
|
||||
entry->fname = extra+5;
|
||||
entry->fnane_len = extrachunk_len-5;
|
||||
entry->fname_len = extrachunk_len-5;
|
||||
extra += extrachunk_len;
|
||||
|
||||
entry->gflags |= (1u<<11); //just set that flag. we don't support comments anyway.
|
||||
|
@ -1823,6 +1823,7 @@ static qboolean FSZIP_ReadCentralEntry(zipfile_t *zip, qbyte *data, struct zipce
|
|||
|
||||
//for compatibility with windows, this is an IBM437 -> unicode translation (ucs-2 is sufficient here)
|
||||
//the zip codepage is defined as either IBM437(aka: dos) or UTF-8. Systems that use a different codepage are buggy.
|
||||
//this table is for filenames, so lets just fix up windows problems here.
|
||||
unsigned short ibmtounicode[256] =
|
||||
{
|
||||
0x0000,0x263A,0x263B,0x2665,0x2666,0x2663,0x2660,0x2022,0x25D8,0x25CB,0x25D9,0x2642,0x2640,0x266A,0x266B,0x263C, //0x00(non-ascii, display-only)
|
||||
|
@ -1830,7 +1831,7 @@ unsigned short ibmtounicode[256] =
|
|||
0x0020,0x0021,0x0022,0x0023,0x0024,0x0025,0x0026,0x0027,0x0028,0x0029,0x002A,0x002B,0x002C,0x002D,0x002E,0x002F, //0x20(ascii)
|
||||
0x0030,0x0031,0x0032,0x0033,0x0034,0x0035,0x0036,0x0037,0x0038,0x0039,0x003A,0x003B,0x003C,0x003D,0x003E,0x003F, //0x30(ascii)
|
||||
0x0040,0x0041,0x0042,0x0043,0x0044,0x0045,0x0046,0x0047,0x0048,0x0049,0x004A,0x004B,0x004C,0x004D,0x004E,0x004F, //0x40(ascii)
|
||||
0x0050,0x0051,0x0052,0x0053,0x0054,0x0055,0x0056,0x0057,0x0058,0x0059,0x005A,0x005B,0x005C,0x005D,0x005E,0x005F, //0x50(ascii)
|
||||
0x0050,0x0051,0x0052,0x0053,0x0054,0x0055,0x0056,0x0057,0x0058,0x0059,0x005A,0x005B, '/',0x005D,0x005E,0x005F, //0x50(ascii)
|
||||
0x0060,0x0061,0x0062,0x0063,0x0064,0x0065,0x0066,0x0067,0x0068,0x0069,0x006A,0x006B,0x006C,0x006D,0x006E,0x006F, //0x60(ascii)
|
||||
0x0070,0x0071,0x0072,0x0073,0x0074,0x0075,0x0076,0x0077,0x0078,0x0079,0x007A,0x007B,0x007C,0x007D,0x007E,0x2302, //0x70(mostly ascii, one display-only)
|
||||
0x00C7,0x00FC,0x00E9,0x00E2,0x00E4,0x00E0,0x00E5,0x00E7,0x00EA,0x00EB,0x00E8,0x00EF,0x00EE,0x00EC,0x00C4,0x00C5, //0x80(non-ascii, printable)
|
||||
|
@ -1870,18 +1871,20 @@ static qboolean FSZIP_EnumerateCentralDirectory(zipfile_t *zip, struct zipinfo *
|
|||
|
||||
//copy out the filename and lowercase it
|
||||
if (entry.gflags & (1u<<11))
|
||||
{ //already utf-8 encoding
|
||||
if (entry.fnane_len > sizeof(f->name)-1)
|
||||
entry.fnane_len = sizeof(f->name)-1;
|
||||
memcpy(f->name, entry.fname, entry.fnane_len);
|
||||
f->name[entry.fnane_len] = 0;
|
||||
{ //already utf-8 encoding, still need to work around windows though.
|
||||
if (entry.fname_len > sizeof(f->name)-1)
|
||||
entry.fname_len = sizeof(f->name)-1;
|
||||
for (i = 0; i < entry.fname_len; i++)
|
||||
f->name[i] = (entry.fname[i]=='\\')?'/':entry.fname[i];
|
||||
memcpy(f->name, entry.fname, entry.fname_len);
|
||||
f->name[entry.fname_len] = 0;
|
||||
}
|
||||
else
|
||||
{ //legacy charset
|
||||
int i;
|
||||
int nlen = 0;
|
||||
int cl;
|
||||
for (i = 0; i < entry.fnane_len; i++)
|
||||
for (i = 0; i < entry.fname_len; i++)
|
||||
{
|
||||
cl = utf8_encode(f->name+nlen, ibmtounicode[entry.fname[i]], sizeof(f->name)-1 - nlen);
|
||||
if (!cl) //overflowed, truncate cleanly.
|
||||
|
|
Loading…
Reference in a new issue