summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: fc715be)
raw | patch | inline | side by side (parent: fc715be)
author | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Fri, 8 Apr 2016 02:05:33 +0000 (05:05 +0300) | ||
committer | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Fri, 8 Apr 2016 02:05:55 +0000 (05:05 +0300) |
src/sfs/sfsMemFS.pas | patch | blob | history | |
src/sfs/sfsPlainFS.pas | patch | blob | history | |
src/sfs/sfsZipFS.pas | patch | blob | history |
diff --git a/src/sfs/sfsMemFS.pas b/src/sfs/sfsMemFS.pas
index 03c8be287c7890367062e86b45b5b10148670e61..edf35c0bed806ba75c26a1ced966930894b9daf2 100644 (file)
--- a/src/sfs/sfsMemFS.pas
+++ b/src/sfs/sfsMemFS.pas
// as a side effect this gives us an opportunity to read enclosed packs
// from the packs which aren't supporting backseeking (such as zips).
//
+{.$DEFINE SFS_MSMFS}
{$MODE DELPHI}
{.$R-}
unit sfsMemFS;
interface
+{$IFDEF SFS_MSMFS}
uses
SysUtils, Classes, Contnrs, sfs;
function Produce (const prefix, fileName: TSFSString; st: TStream): TSFSVolume; override;
procedure Recycle (vol: TSFSVolume); override;
end;
-
+{$ENDIF}
implementation
+{$IFDEF SFS_MSMFS}
uses
xstreams;
SFSRegisterVolumeFactory(memf);
finalization
SFSUnregisterVolumeFactory(memf);
+{$ENDIF}
end.
diff --git a/src/sfs/sfsPlainFS.pas b/src/sfs/sfsPlainFS.pas
index c96dbf954a4ac62f67afe58c53bbe68601553524..81eb440964a7459bea276e1f401de216d221a0e1 100644 (file)
--- a/src/sfs/sfsPlainFS.pas
+++ b/src/sfs/sfsPlainFS.pas
// file type.
// undefine this and file type will be directory name.
{.$DEFINE SFS_PLAIN_FS_DEBUG_ALLEGRO}
+{.$DEFINE SFS_PLAINFS_FULL}
{$MODE DELPHI}
{.$R-}
unit sfsPlainFS;
SysUtils, Classes, Contnrs, sfs;
-
type
TSFSPlainVolumeType =
- (sfspvNone, sfspvWAD, sfspvPAK, sfspvGRP, sfspvSPE, sfspvWAD2, sfspvALL,
- sfspvDune2, sfspvMAX, sfspvSIN);
+ (sfspvNone,
+ sfspvPAK,
+ sfspvSIN
+ {$IFDEF SFS_PLAINFS_FULL}
+ ,sfspvWAD,
+ sfspvGRP,
+ sfspvSPE,
+ sfspvWAD2,
+ sfspvALL,
+ sfspvDune2,
+ sfspvMAX
+ {$ENDIF}
+ );
TSFSPlainVolume = class (TSFSVolume)
protected
fType: TSFSPlainVolumeType;
procedure PAKReadDirectory ();
+ procedure SINReadDirectory ();
+ {$IFDEF SFS_PLAINFS_FULL}
procedure WADReadDirectory ();
procedure GRPReadDirectory ();
procedure SPEReadDirectory ();
procedure ALLReadDirectory ();
procedure Dune2ReadDirectory ();
procedure MAXReadDirectory ();
- procedure SINReadDirectory ();
+ {$ENDIF}
procedure ReadDirectory (); override;
fLink: TSFSString;
end;
+{$IFDEF SFS_PLAINFS_FULL}
TAllegroProperty = class
name: TSFSString;
ofs: Int64;
size: Integer;
end;
+{$ENDIF}
function ReadMD (st: TStream): Integer;
result := (buf[0] shl 24) or (buf[1] shl 16) or (buf[2] shl 8) or buf[3];
end;
+{$IFDEF SFS_PLAINFS_FULL}
function WADCheckMagic (st: TStream): Boolean;
var
sign: packed array [0..3] of Char;
(dofs+fcnt*16 > st.Size) then exit;
result := true;
end;
+{$ENDIF}
function PAKCheckMagic (st: TStream): Boolean;
var
result := true;
end;
+{$IFDEF SFS_PLAINFS_FULL}
function GRPCheckMagic (st: TStream): Boolean;
var
sign: packed array [0..11] of Char;
(dofs+fcnt > st.Size) then exit;
result := true;
end;
+{$ENDIF}
{ TSFSPlainVolume }
+{$IFDEF SFS_PLAINFS_FULL}
procedure TSFSPlainVolume.WADReadDirectory ();
var
fcnt: LongWord;
Dec(fcnt);
end;
end;
+{$ENDIF}
procedure TSFSPlainVolume.PAKReadDirectory ();
var
end;
end;
+{$IFDEF SFS_PLAINFS_FULL}
procedure TSFSPlainVolume.GRPReadDirectory ();
var
fcnt: LongWord;
Dec(fcnt, 16);
end;
end;
-
+{$ENDIF}
procedure TSFSPlainVolume.ReadDirectory ();
begin
case fType of
- sfspvWAD: WADReadDirectory();
sfspvPAK: PAKReadDirectory();
+ sfspvSIN: SINReadDirectory();
+ {$IFDEF SFS_PLAINFS_FULL}
+ sfspvWAD: WADReadDirectory();
sfspvGRP: GRPReadDirectory();
sfspvSPE: SPEReadDirectory();
sfspvWAD2: WAD2ReadDirectory();
sfspvALL: ALLReadDirectory();
sfspvDune2: Dune2ReadDirectory();
sfspvMAX: MAXReadDirectory();
- sfspvSIN: SINReadDirectory();
+ {$ENDIF}
else raise ESFSError.Create('invalid plain SFS');
end;
end;
@@ -668,19 +692,23 @@ function TSFSPlainVolumeFactory.IsMyVolumePrefix (const prefix: TSFSString): Boo
begin
result :=
SFSStrEqu(prefix, 'pak') or
- //SFSStrEqu(prefix, 'wad') or // sorry
+ SFSStrEqu(prefix, 'sin') or
+ SFSStrEqu(prefix, 'quake')
+ {$IFDEF SFS_PLAINFS_FULL}
+ or
+ SFSStrEqu(prefix, 'wad') or // sorry
SFSStrEqu(prefix, 'wad2') or
SFSStrEqu(prefix, 'grp') or
SFSStrEqu(prefix, 'spe') or
SFSStrEqu(prefix, 'spec') or
- SFSStrEqu(prefix, 'quake') or
SFSStrEqu(prefix, 'doom') or
SFSStrEqu(prefix, 'duke3d') or
SFSStrEqu(prefix, 'abuse') or
SFSStrEqu(prefix, 'allegro') or
SFSStrEqu(prefix, 'dune2') or
- SFSStrEqu(prefix, 'max') or
- SFSStrEqu(prefix, 'sin');
+ SFSStrEqu(prefix, 'max')
+ {$ENDIF}
+ ;
end;
procedure TSFSPlainVolumeFactory.Recycle (vol: TSFSVolume);
vt: TSFSPlainVolumeType;
begin
vt := sfspvNone;
- if WADCheckMagic(st) then vt := sfspvWAD
- else if PAKCheckMagic(st) then vt := sfspvPAK
+ if PAKCheckMagic(st) then vt := sfspvPAK
+ else if SINCheckMagic(st) then vt := sfspvSIN
+ {$IFDEF SFS_PLAINFS_FULL}
+ else if WADCheckMagic(st) then vt := sfspvWAD
else if GRPCheckMagic(st) then vt := sfspvGRP
else if SPECheckMagic(st) then vt := sfspvSPE
else if WAD2CheckMagic(st) then vt := sfspvWAD2
//else if ALLCheckMagic(st) then vt := sfspvALL
else if MAXCheckMagic(st) then vt := sfspvMAX
- else if SINCheckMagic(st) then vt := sfspvSIN;
- //else if Dune2CheckMagic(st) then vt := sfspvDune2; // this must be the last!
+ //else if Dune2CheckMagic(st) then vt := sfspvDune2 // this must be the last!
+ {$ENDIF}
+ ;
if vt <> sfspvNone then
begin
diff --git a/src/sfs/sfsZipFS.pas b/src/sfs/sfsZipFS.pas
index 9fb1137e0ca70d054282ddc68c6a01a190b67717..b7e9051523e952e7535549f684da3e840b14b1cb 100644 (file)
--- a/src/sfs/sfsZipFS.pas
+++ b/src/sfs/sfsZipFS.pas
// dfwad : D2D:F wad archives
//
{.$DEFINE SFS_DEBUG_ZIPFS}
+{.$DEFINE SFS_ZIPFS_FULL}
{$MODE DELPHI}
{.$R-}
unit sfsZipFS;
SysUtils, Classes, Contnrs, sfs;
-
type
- TSFSZipVolumeType = (sfszvNone, sfszvZIP, sfszvF2DAT, sfszvVTDB, sfszvDFWAD);
+ TSFSZipVolumeType = (
+ sfszvNone,
+ sfszvZIP,
+ {$IFDEF SFS_ZIPFS_FULL}
+ sfszvF2DAT,
+ sfszvVTDB,
+ {$ENDIF}
+ sfszvDFWAD
+ );
TSFSZipVolume = class(TSFSVolume)
protected
fType: TSFSZipVolumeType;
procedure ZIPReadDirectory ();
+ procedure DFWADReadDirectory ();
+ {$IFDEF SFS_ZIPFS_FULL}
procedure F2DATReadDirectory ();
procedure VTDBReadDirectory ();
- procedure DFWADReadDirectory ();
+ {$ENDIF}
procedure ReadDirectory (); override;
procedure removeCommonPath (); override;
result := true;
end;
+{$IFDEF SFS_ZIPFS_FULL}
function F2DATCheckMagic (st: TStream): Boolean;
var
dsize, fiSz: Integer;
if (fcnt < 0) or (dofs < 32) or (dofs+fcnt*8 > st.Size) then exit;
result := true;
end;
+{$ENDIF}
function DFWADCheckMagic (st: TStream): Boolean;
var
end;
end;
+
{ TSFSZipVolume }
procedure TSFSZipVolume.ZIPReadDirectory ();
var
end;
end;
+{$IFDEF SFS_ZIPFS_FULL}
procedure TSFSZipVolume.F2DATReadDirectory ();
var
dsize: Integer;
fi.fMethod := 255;
end;
end;
+{$ENDIF}
procedure TSFSZipVolume.DFWADReadDirectory ();
// idiotic format
begin
case fType of
sfszvZIP: ZIPReadDirectory();
+ {$IFDEF SFS_ZIPFS_FULL}
sfszvF2DAT: F2DATReadDirectory();
sfszvVTDB: VTDBReadDirectory();
+ {$ENDIF}
sfszvDFWAD: DFWADReadDirectory();
else raise ESFSError.Create('invalid zipped SFS');
end;
@@ -541,11 +558,14 @@ function TSFSZipVolumeFactory.IsMyVolumePrefix (const prefix: TSFSString): Boole
begin
result :=
SFSStrEqu(prefix, 'zip') or
- SFSStrEqu(prefix, 'jar') or
+ SFSStrEqu(prefix, 'dfwad')
+ {$IFDEF SFS_ZIPFS_FULL}
+ or SFSStrEqu(prefix, 'jar') or
SFSStrEqu(prefix, 'fout2') or
SFSStrEqu(prefix, 'vtdb') or
- SFSStrEqu(prefix, 'wad') or
- SFSStrEqu(prefix, 'dfwad');
+ SFSStrEqu(prefix, 'wad')
+ {$ENDIF}
+ ;
end;
procedure TSFSZipVolumeFactory.Recycle (vol: TSFSVolume);
vt: TSFSZipVolumeType;
begin
vt := sfszvNone;
- if ZIPCheckMagic(st) then vt := sfszvZIP
+ if ZIPCheckMagic(st) then vt := sfszvZIP
else if DFWADCheckMagic(st) then vt := sfszvDFWAD
+ {$IFDEF SFS_ZIPFS_FULL}
else if F2DATCheckMagic(st) then vt := sfszvF2DAT
- else if VTDBCheckMagic(st) then vt := sfszvVTDB;
+ else if VTDBCheckMagic(st) then vt := sfszvVTDB
+ {$ENDIF}
+ ;
if vt <> sfszvNone then
begin