Added gzip support to the dos version
This commit is contained in:
@@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#include <zlib.h>
|
||||||
#ifdef ZDOS
|
#ifdef ZDOS
|
||||||
#include <dos.h>
|
#include <dos.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -30,6 +30,9 @@
|
|||||||
FILE *FILEHANDLE[16];
|
FILE *FILEHANDLE[16];
|
||||||
DWORD CurrentHandle=0;
|
DWORD CurrentHandle=0;
|
||||||
|
|
||||||
|
//Indicate whether the file must be opened using
|
||||||
|
//zlib or not (used for gzip support)
|
||||||
|
BYTE TextFile;
|
||||||
|
|
||||||
|
|
||||||
// ZFileSystemInit
|
// ZFileSystemInit
|
||||||
@@ -86,81 +89,136 @@ DWORD DriveNumber;
|
|||||||
BYTE * ZFileDelFName;
|
BYTE * ZFileDelFName;
|
||||||
// return current position
|
// return current position
|
||||||
|
|
||||||
|
|
||||||
DWORD ZFileSystemInit()
|
DWORD ZFileSystemInit()
|
||||||
{
|
{
|
||||||
CurrentHandle=0;
|
#ifdef __GZIP__
|
||||||
return(0);
|
TextFile = 0;
|
||||||
|
#else
|
||||||
|
TextFile = 1;
|
||||||
|
#endif
|
||||||
|
CurrentHandle=0;
|
||||||
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DWORD ZOpenFile()
|
DWORD ZOpenFile()
|
||||||
{
|
{
|
||||||
if(ZOpenMode==0)
|
if(ZOpenMode==0)
|
||||||
{
|
{
|
||||||
if((FILEHANDLE[CurrentHandle]=fopen(ZOpenFileName,"rb"))!=NULL)
|
if (TextFile)
|
||||||
{
|
FILEHANDLE[CurrentHandle]=fopen(ZOpenFileName,"rb");
|
||||||
CurrentHandle+=1;
|
else
|
||||||
return(CurrentHandle-1);
|
FILEHANDLE[CurrentHandle]=(FILE *)gzopen(ZOpenFileName,"rb");
|
||||||
}
|
if(FILEHANDLE[CurrentHandle]!=NULL)
|
||||||
return(0xFFFFFFFF);
|
{
|
||||||
}
|
CurrentHandle+=1;
|
||||||
if(ZOpenMode==1)
|
return(CurrentHandle-1);
|
||||||
{
|
}
|
||||||
if((FILEHANDLE[CurrentHandle]=fopen(ZOpenFileName,"wb"))!=NULL)
|
return(0xFFFFFFFF);
|
||||||
{
|
}
|
||||||
CurrentHandle+=1;
|
if(ZOpenMode==1)
|
||||||
return(CurrentHandle-1);
|
{
|
||||||
}
|
if (TextFile)
|
||||||
return(0xFFFFFFFF);
|
FILEHANDLE[CurrentHandle]=fopen(ZOpenFileName,"wb");
|
||||||
}
|
else
|
||||||
if(ZOpenMode==2)
|
FILEHANDLE[CurrentHandle]=(FILE *)gzopen(ZOpenFileName,"wb");
|
||||||
{
|
if(FILEHANDLE[CurrentHandle]!=NULL)
|
||||||
if((FILEHANDLE[CurrentHandle]=fopen(ZOpenFileName,"r+b"))!=NULL)
|
{
|
||||||
{
|
CurrentHandle+=1;
|
||||||
CurrentHandle+=1;
|
return(CurrentHandle-1);
|
||||||
return(CurrentHandle-1);
|
}
|
||||||
}
|
return(0xFFFFFFFF);
|
||||||
return(0xFFFFFFFF);
|
}
|
||||||
}
|
if(ZOpenMode==2)
|
||||||
return(0xFFFFFFFF);
|
{
|
||||||
|
if (TextFile)
|
||||||
|
FILEHANDLE[CurrentHandle]=fopen(ZOpenFileName,"r+b");
|
||||||
|
else
|
||||||
|
FILEHANDLE[CurrentHandle]=gzopen(ZOpenFileName,"r+b");
|
||||||
|
if(FILEHANDLE[CurrentHandle]!=NULL)
|
||||||
|
{
|
||||||
|
CurrentHandle+=1;
|
||||||
|
return(CurrentHandle-1);
|
||||||
|
}
|
||||||
|
return(0xFFFFFFFF);
|
||||||
|
}
|
||||||
|
return(0xFFFFFFFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD ZCloseFile()
|
DWORD ZCloseFile()
|
||||||
{
|
{
|
||||||
fclose(FILEHANDLE[ZCloseFileHandle]);
|
if (TextFile)
|
||||||
CurrentHandle-=1;
|
fclose(FILEHANDLE[ZCloseFileHandle]);
|
||||||
return(0);
|
else
|
||||||
|
gzclose(FILEHANDLE[ZCloseFileHandle]);
|
||||||
|
CurrentHandle-=1;
|
||||||
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD ZFileSeek()
|
DWORD ZFileSeek()
|
||||||
{
|
{
|
||||||
if(ZFileSeekMode==0)
|
int res = 0;
|
||||||
{
|
int mode = 0;
|
||||||
fseek(FILEHANDLE[ZFileSeekHandle],ZFileSeekPos,SEEK_SET);
|
if (ZFileSeekMode==0)
|
||||||
return(0);
|
mode = SEEK_SET;
|
||||||
}
|
else if (ZFileSeekMode==1) {
|
||||||
if(ZFileSeekMode==1)
|
mode = SEEK_END;
|
||||||
{
|
if (TextFile==0)
|
||||||
fseek(FILEHANDLE[ZFileSeekHandle],ZFileSeekPos,SEEK_END);
|
printf("Warning : gzseek(SEEK_END) not supported");
|
||||||
return(0);
|
} else return (0xFFFFFFFF);
|
||||||
}
|
|
||||||
return(0xFFFFFFFF);
|
if (TextFile) {
|
||||||
|
fseek(FILEHANDLE[ZFileSeekHandle], ZFileSeekPos, mode);
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
gzseek(FILEHANDLE[ZFileSeekHandle], ZFileSeekPos, mode);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return(0xFFFFFFFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD ZFileRead()
|
DWORD ZFileRead()
|
||||||
{
|
{
|
||||||
return(fread(ZFileReadBlock,1,ZFileReadSize,FILEHANDLE[ZFileReadHandle]));
|
if (TextFile)
|
||||||
|
return(fread(ZFileReadBlock,
|
||||||
|
1,
|
||||||
|
ZFileReadSize,
|
||||||
|
FILEHANDLE[ZFileReadHandle]));
|
||||||
|
else
|
||||||
|
return(gzread(FILEHANDLE[ZFileReadHandle],
|
||||||
|
ZFileReadBlock,
|
||||||
|
ZFileReadSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DWORD ZFileWrite()
|
DWORD ZFileWrite()
|
||||||
{
|
{
|
||||||
if((fwrite(ZFileWriteBlock,1,ZFileWriteSize,FILEHANDLE[ZFileWriteHandle]))!=ZFileWriteSize) return(0xFFFFFFFF);
|
int res=0;
|
||||||
return(0);
|
if (TextFile)
|
||||||
|
res = fwrite(ZFileWriteBlock,
|
||||||
|
1,
|
||||||
|
ZFileWriteSize,
|
||||||
|
FILEHANDLE[ZFileWriteHandle]);
|
||||||
|
else
|
||||||
|
res = gzwrite(FILEHANDLE[ZFileWriteHandle],
|
||||||
|
ZFileWriteBlock,
|
||||||
|
ZFileWriteSize);
|
||||||
|
|
||||||
|
if (res!=ZFileWriteSize)
|
||||||
|
return(0xFFFFFFFF);
|
||||||
|
|
||||||
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD ZFileTell()
|
DWORD ZFileTell()
|
||||||
{
|
{
|
||||||
return(ftell(FILEHANDLE[ZFileTellHandle]));
|
int res = 0;
|
||||||
|
if (TextFile) {
|
||||||
|
res = ftell(FILEHANDLE[ZFileTellHandle]);
|
||||||
|
if (res == -1) fprintf(stderr, "Oups!! gzTell\n");
|
||||||
|
return(res);
|
||||||
|
} else return gztell(FILEHANDLE[ZFileTellHandle]);
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD ZFileDelete()
|
DWORD ZFileDelete()
|
||||||
@@ -264,4 +322,4 @@ DWORD GetDate()
|
|||||||
+((newtime->tm_wday) << 28);
|
+((newtime->tm_wday) << 28);
|
||||||
|
|
||||||
return(value);
|
return(value);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -568,10 +568,7 @@ GetNormalEntries2:
|
|||||||
GUIGetEntry2 GUIsfcfind
|
GUIGetEntry2 GUIsfcfind
|
||||||
GUIGetEntry2 GUIswcfind
|
GUIGetEntry2 GUIswcfind
|
||||||
GUIGetEntry2 GUIfigfind
|
GUIGetEntry2 GUIfigfind
|
||||||
cmp byte[OSPort],1
|
|
||||||
jbe near .dos
|
|
||||||
GUIGetEntry2 GUIfindGZIP
|
GUIGetEntry2 GUIfindGZIP
|
||||||
.dos
|
|
||||||
GUIGetEntry2 GUIfind058
|
GUIGetEntry2 GUIfind058
|
||||||
GUIGetEntry2 GUIfind078
|
GUIGetEntry2 GUIfind078
|
||||||
GUIGetEntry2 GUIfindUSA
|
GUIGetEntry2 GUIfindUSA
|
||||||
@@ -595,10 +592,7 @@ GetNormalEntries:
|
|||||||
GUIGetEntry GUIsfcfind
|
GUIGetEntry GUIsfcfind
|
||||||
GUIGetEntry GUIswcfind
|
GUIGetEntry GUIswcfind
|
||||||
GUIGetEntry GUIfigfind
|
GUIGetEntry GUIfigfind
|
||||||
cmp byte[OSPort],1
|
|
||||||
jbe near .dos
|
|
||||||
GUIGetEntry GUIfindGZIP
|
GUIGetEntry GUIfindGZIP
|
||||||
.dos
|
|
||||||
GUIGetEntry GUIfind058
|
GUIGetEntry GUIfind058
|
||||||
GUIGetEntry GUIfind078
|
GUIGetEntry GUIfind078
|
||||||
GUIGetEntry GUIfindUSA
|
GUIGetEntry GUIfindUSA
|
||||||
@@ -760,10 +754,7 @@ GetLoadLfn:
|
|||||||
GUIGetEntryLFN GUIsfcfind
|
GUIGetEntryLFN GUIsfcfind
|
||||||
GUIGetEntryLFN GUIswcfind
|
GUIGetEntryLFN GUIswcfind
|
||||||
GUIGetEntryLFN GUIfigfind
|
GUIGetEntryLFN GUIfigfind
|
||||||
cmp byte[OSPort],1
|
|
||||||
jbe near .dos
|
|
||||||
GUIGetEntryLFN GUIfindGZIP
|
GUIGetEntryLFN GUIfindGZIP
|
||||||
.dos
|
|
||||||
GUIGetEntryLFN GUIfind058
|
GUIGetEntryLFN GUIfind058
|
||||||
GUIGetEntryLFN GUIfind078
|
GUIGetEntryLFN GUIfind078
|
||||||
GUIGetEntryLFN GUIfindUSA
|
GUIGetEntryLFN GUIfindUSA
|
||||||
|
|||||||
Reference in New Issue
Block a user