mysticbbs/mystic/aviewlzh.pas

84 lines
1.6 KiB
ObjectPascal
Raw Normal View History

Unit AViewLZH;
2012-02-13 16:50:48 -08:00
{$I M_OPS.PAS}
Interface
Uses
Dos,
AView;
Type
LFHeader = Record
HeadSize,
HeadChk : Byte;
HeadID : Packed Array[1..5] of Char;
PackSize,
OrigSize,
FileTime : LongInt;
Attr : Word;
FileName : String[12];
2012-09-20 10:52:58 -07:00
F32 : String[255];
DT : DateTime;
End;
PLzhArchive = ^TLzhArchive;
TLzhArchive = Object(TGeneralArchive)
Constructor Init;
Procedure FindFirst (Var SR: ArcSearchRec); Virtual;
Procedure FindNext (Var SR: ArcSearchRec); Virtual;
Private
_FHdr : LFHeader;
_SL : LongInt;
Procedure GetHeader (Var SR: ArcSearchRec);
End;
2012-02-13 16:50:48 -08:00
Implementation
2012-02-13 16:50:48 -08:00
Constructor TLzhArchive.Init;
Begin
_SL := 0;
FillChar (_FHdr,sizeof(_FHdr), 0);
End;
2012-02-13 16:50:48 -08:00
Procedure TLzhArchive.GetHeader (Var SR: ArcSearchRec);
Var
NR : LongInt;
Begin
FillChar (SR, SizeOf(SR), 0);
Seek (ArcFile, _SL);
2012-02-13 16:50:48 -08:00
If Eof(ArcFile) Then Exit;
2012-02-13 16:50:48 -08:00
BlockRead (ArcFile, _FHdr, SizeOf(LFHeader), NR);
2012-02-13 16:50:48 -08:00
If _FHdr.HeadSize = 0 Then Exit;
2012-02-13 16:50:48 -08:00
Inc (_SL, _FHdr.HeadSize);
Inc (_SL, 2);
Inc (_SL, _FHdr.PackSize);
2012-02-13 16:50:48 -08:00
If _FHdr.HeadSize <> 0 Then
UnPackTime (_FHdr.FileTime, _FHdr.DT);
2012-02-13 16:50:48 -08:00
2012-09-20 10:52:58 -07:00
If Pos(#0, _FHdr.FileName) > 0 Then
SR.Name := Copy(_FHdr.FileName, 1, Pos(#0, _FHdr.FileName) - 1)
Else
SR.Name := _FHdr.FileName;
SR.Size := _FHdr.OrigSize;
SR.Time := _FHdr.FileTime;
End;
Procedure TLzhArchive.FindFirst (Var SR: ArcSearchRec);
Begin
GetHeader(SR);
End;
Procedure TLzhArchive.FindNext (Var SR: ArcSearchRec);
Begin
GetHeader(SR);
End;
2012-09-20 10:52:58 -07:00
End.