home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Black Box 4
/
BlackBox.cdr
/
archiver
/
gus_150.arj
/
GUS_WCFG.PAS
next >
Wrap
Pascal/Delphi Source File
|
1992-04-13
|
5KB
|
121 lines
{$A+,B-,D-,E-,F-,I+,L-,N-,O-,R+,S+,V-}
{$IFDEF VER60}
{$G-,X-}
{$ENDIF}
{$M 1024,0,0}
program GUS_WriteConfig; { Append or update configuration }
{ information to or in GUS.EXE for v1.50 !!! }
uses DOS;
type
FNameStr = string[12];
ArcType = (ARC,ARJ,A7p,DWC,HYP,LZH,PAK,ZIP,ZOO);
ArcCmds = (Extract,Replace,Display,Test);
ArcData = record
Ext : string[3];
Prog: FNameStr;
Cmd : array [ArcCmds] of string[10];
Pth,
Pwd : string[5];
end;
ArcCfg = record
Marker : longint;
ArcTable: array [ArcType] of ArcData;
end;
const
GUSname = 'GUS.EXE';
CfgMarker = $96535547; {'GUS'+chr(150)}
Unsupported = '**********';
ArcInfo : ArcCfg
= (Marker : CfgMarker;
ArcTable : { Extract Replace Display Test }
((Ext: 'ARC'; Prog: 'PKUNPAK .EXE'; Cmd:('-n ', '-r ', '-c ', '-t '); Pth: Unsupported;
Pwd: ' -g ' ),
(Ext: 'ARJ'; Prog: 'ARJ .EXE'; Cmd:('e -n ', 'e -y ', 'p ', 't '); Pth: ' -jf ' ;
Pwd: ' -g ' ),
(Ext: 'A7+'; Prog: 'XARC .EXE'; Cmd:(' ', '/o ', Unsupported , Unsupported ); Pth: Unsupported;
Pwd: '/g ' ),
(Ext: 'DWC'; Prog: 'DWC .EXE'; Cmd:('xow ', 'xw ', 'p ', 't '); Pth: 'r ' ;
Pwd: 'g ' ),
(Ext: 'HYP'; Prog: 'HYPER .EXE'; Cmd:('-x ', '-xo ', Unsupported , Unsupported ); Pth: 'p ' ;
Pwd: Unsupported ),
(Ext: 'LZH'; Prog: 'LHA .EXE'; Cmd:('e /m+ ', 'e /m+c+ ', 'p ', 't '); Pth: 'x+ ' ;
Pwd: Unsupported ),
(Ext: 'PAK'; Prog: 'PAK .EXE'; Cmd:('e/WN ', 'e/WA ', 'p ', 't '); Pth: '/PATH' ;
Pwd: '/g ' ),
(Ext: 'ZIP'; Prog: 'PKUNZIP .EXE'; Cmd:('-n ', '-o ', '-c ', '-t '); Pth: ' -d ' ;
Pwd: ' -s ' ),
(Ext: 'ZOO'; Prog: 'ZOO .EXE'; Cmd:('e: ', 'eSO: ', 'e:p ', 'e:N '); Pth: '// ' ;
Pwd: Unsupported )
)
);
var
CfgData : ArcCfg;
GUSfile : file;
procedure ReadData (var F : file;
var Data: ArcCfg);
begin
{$I-}
reset(F,1);
{$I+}
if IOresult<>0
then begin
writeln('Can''t open ',GUSname);
Halt(1);
end;
{$I-} seek(F,filesize(F)-sizeof(ArcCfg)); {$I+}
if IOresult<>0
then begin
writeln('Problem: cannot seek to byte location ',filesize(F),' - ',sizeof(ArcCfg));
Halt(1);
end;
{$I-} BlockRead(F,Data,sizeof(ArcCfg)); {$I+}
if IOresult<>0
then begin
writeln('Problem: cannot read ',sizeof(ArcCfg),' bytes in ',GUSname,' at offset ',filepos(F));
Halt(1);
end;
close(F);
writeln('Reading configuration information from ',GUSname)
end; {ReadData}
procedure AppendData (var F : file;
var Data: ArcCfg);
begin
Data.Marker:=CfgMarker;
reset(F,1);
seek(F,filesize(F));
BlockWrite(F,Data,sizeof(ArcCfg));
close(F);
writeln('Appending configuration information to ',GUSname)
end; {AppendData}
procedure UpdateData (var F : file;
var Data: ArcCfg);
begin
Data.Marker:=CfgMarker;
reset(F,1);
seek(F,filesize(F)-sizeof(ArcCfg));
BlockWrite(F,Data,sizeof(ArcCfg));
close(F);
writeln('Updating configuration information in ',GUSname)
end; {UpdateData}
begin {=MAIN=}
assign(GUSfile,GUSname);
ReadData(GUSfile,CfgData);
if CfgData.Marker=CfgMarker
then UpdateData(GUSfile,ArcInfo)
else AppendData(GUSfile,ArcInfo)
end.