mysticbbs/mystic/aviewlzh.pas

105 lines
2.6 KiB
ObjectPascal
Raw Normal View History

Unit AViewLZH;
2012-02-13 16:50:48 -08:00
// ====================================================================
// Mystic BBS Software Copyright 1997-2013 By James Coyle
// ====================================================================
//
// This file is part of Mystic BBS.
//
// Mystic BBS is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Mystic BBS is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Mystic BBS. If not, see <http://www.gnu.org/licenses/>.
//
// ====================================================================
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.