From 2c514f6c21866e5434865d550238e62979c7add2 Mon Sep 17 00:00:00 2001 From: Ketmar Dark Date: Fri, 8 Apr 2016 05:05:33 +0300 Subject: [PATCH] sfs: removed unused archive support --- src/sfs/sfsMemFS.pas | 6 ++++- src/sfs/sfsPlainFS.pas | 61 +++++++++++++++++++++++++++++++----------- src/sfs/sfsZipFS.pas | 39 +++++++++++++++++++++------ 3 files changed, 82 insertions(+), 24 deletions(-) diff --git a/src/sfs/sfsMemFS.pas b/src/sfs/sfsMemFS.pas index 03c8be2..edf35c0 100644 --- a/src/sfs/sfsMemFS.pas +++ b/src/sfs/sfsMemFS.pas @@ -11,12 +11,14 @@ // 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; @@ -44,11 +46,12 @@ type function Produce (const prefix, fileName: TSFSString; st: TStream): TSFSVolume; override; procedure Recycle (vol: TSFSVolume); override; end; - +{$ENDIF} implementation +{$IFDEF SFS_MSMFS} uses xstreams; @@ -240,4 +243,5 @@ initialization SFSRegisterVolumeFactory(memf); finalization SFSUnregisterVolumeFactory(memf); +{$ENDIF} end. diff --git a/src/sfs/sfsPlainFS.pas b/src/sfs/sfsPlainFS.pas index c96dbf9..81eb440 100644 --- a/src/sfs/sfsPlainFS.pas +++ b/src/sfs/sfsPlainFS.pas @@ -18,6 +18,7 @@ // 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; @@ -28,17 +29,29 @@ uses 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 (); @@ -46,7 +59,7 @@ type procedure ALLReadDirectory (); procedure Dune2ReadDirectory (); procedure MAXReadDirectory (); - procedure SINReadDirectory (); + {$ENDIF} procedure ReadDirectory (); override; @@ -76,11 +89,13 @@ type fLink: TSFSString; end; +{$IFDEF SFS_PLAINFS_FULL} TAllegroProperty = class name: TSFSString; ofs: Int64; size: Integer; end; +{$ENDIF} function ReadMD (st: TStream): Integer; @@ -92,6 +107,7 @@ begin 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; @@ -106,6 +122,7 @@ begin (dofs+fcnt*16 > st.Size) then exit; result := true; end; +{$ENDIF} function PAKCheckMagic (st: TStream): Boolean; var @@ -137,6 +154,7 @@ begin result := true; end; +{$IFDEF SFS_PLAINFS_FULL} function GRPCheckMagic (st: TStream): Boolean; var sign: packed array [0..11] of Char; @@ -221,9 +239,11 @@ begin (dofs+fcnt > st.Size) then exit; result := true; end; +{$ENDIF} { TSFSPlainVolume } +{$IFDEF SFS_PLAINFS_FULL} procedure TSFSPlainVolume.WADReadDirectory (); var fcnt: LongWord; @@ -246,6 +266,7 @@ begin Dec(fcnt); end; end; +{$ENDIF} procedure TSFSPlainVolume.PAKReadDirectory (); var @@ -291,6 +312,7 @@ begin end; end; +{$IFDEF SFS_PLAINFS_FULL} procedure TSFSPlainVolume.GRPReadDirectory (); var fcnt: LongWord; @@ -594,20 +616,22 @@ begin 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); @@ -693,15 +721,18 @@ var 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 9fb1137..b7e9051 100644 --- a/src/sfs/sfsZipFS.pas +++ b/src/sfs/sfsZipFS.pas @@ -9,6 +9,7 @@ // dfwad : D2D:F wad archives // {.$DEFINE SFS_DEBUG_ZIPFS} +{.$DEFINE SFS_ZIPFS_FULL} {$MODE DELPHI} {.$R-} unit sfsZipFS; @@ -19,18 +20,27 @@ uses 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; @@ -89,6 +99,7 @@ begin result := true; end; +{$IFDEF SFS_ZIPFS_FULL} function F2DATCheckMagic (st: TStream): Boolean; var dsize, fiSz: Integer; @@ -115,6 +126,7 @@ begin if (fcnt < 0) or (dofs < 32) or (dofs+fcnt*8 > st.Size) then exit; result := true; end; +{$ENDIF} function DFWADCheckMagic (st: TStream): Boolean; var @@ -191,6 +203,7 @@ begin end; end; + { TSFSZipVolume } procedure TSFSZipVolume.ZIPReadDirectory (); var @@ -319,6 +332,7 @@ begin end; end; +{$IFDEF SFS_ZIPFS_FULL} procedure TSFSZipVolume.F2DATReadDirectory (); var dsize: Integer; @@ -392,6 +406,7 @@ begin fi.fMethod := 255; end; end; +{$ENDIF} procedure TSFSZipVolume.DFWADReadDirectory (); // idiotic format @@ -445,8 +460,10 @@ procedure TSFSZipVolume.ReadDirectory (); 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); @@ -558,10 +578,13 @@ var 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 -- 2.29.2