Bunch of archive fixes for LZH/LHA and FILE_ID importing

This commit is contained in:
mysticbbs 2012-08-19 14:22:24 -04:00
parent 394c82d551
commit 679234a555
5 changed files with 177 additions and 120 deletions

View File

@ -4670,5 +4670,21 @@
! Fixed a bug that could cause viewing files from within an archive to ! Fixed a bug that could cause viewing files from within an archive to
fail. fail.
+ MUTIL now has the ability to import FILES.BBS files automatically. See + MUTIL now has the ability to import FILES.BBS files automatically. In
the MUTIL.CFG file for more information. addition, if MUTIL detects that a file already exists, but has a
different file size, it will update the existing record and description.
This is for people who are using it for networked file bases and TIC.
See MUTIL.CFG file for more information.
+ When importing FILE_ID.DIZ, Mystic will attempt to use its internal
archive viewing capabilities to find the "casing" of the FILE_ID.DIZ file.
If it finds one it will pass the exact casing to the configured archive.
! Fixed a bug where Mystic would not detect and use its internal archive
viewing for LZH files with a different file extension (ie .LHA files from
an Amiga, for example). Mystic will now properly internally view LHA
extensions, as well as properly look for LHA in the archive configuration.
! Fixed a bug when viewing an archive that is not supported with the
internal view that could cause the lightbar file list display to get
messed up.

View File

@ -29,7 +29,7 @@ Type
TArchive = Object TArchive = Object
Constructor Init; Constructor Init;
Destructor Done; Destructor Done;
Function Name (n:string) : Boolean; Function Name (N: String) : Boolean;
Procedure FindFirst (Var SR: ArcSearchRec); Procedure FindFirst (Var SR: ArcSearchRec);
Procedure FindNext (Var SR: ArcSearchRec); Procedure FindNext (Var SR: ArcSearchRec);
Private Private
@ -37,7 +37,7 @@ Type
_Archive : PGeneralArchive; _Archive : PGeneralArchive;
End; End;
Function Get_Arc_Type (Name: String) : Char; Function GetArchiveType (Name: String) : Char;
Implementation Implementation
@ -47,13 +47,14 @@ Uses
AViewLZH, AViewLZH,
AViewRAR; AViewRAR;
Function Get_Arc_Type (Name: String) : Char; Function GetArchiveType (Name: String) : Char;
Var Var
ArcFile : File; ArcFile : File;
Buf : Array[1..3] of Char; Buf : Array[1..5] of Char;
Res : LongInt; Res : LongInt;
Begin Begin
Get_Arc_Type := '?'; Result := '?';
If Name = '' Then Exit; If Name = '' Then Exit;
Assign (ArcFile, Name); Assign (ArcFile, Name);
@ -66,19 +67,16 @@ Begin
If Res = 0 Then Exit; If Res = 0 Then Exit;
If (Buf[1] = 'R') and (Buf[2] = 'a') and (Buf[3] = 'r') Then If (Buf[1] = 'R') and (Buf[2] = 'a') and (Buf[3] = 'r') Then
Get_Arc_Type := 'R' Result := 'R'
Else Else
If (Buf[1] = #$60) And (Buf[2] = #$EA) Then If (Buf[1] = #$60) And (Buf[2] = #$EA) Then
Get_Arc_Type := 'A' Result := 'A'
Else Else
If (Buf[1] = 'P') And (Buf[2] = 'K') Then If (Buf[1] = 'P') And (Buf[2] = 'K') Then
Get_Arc_Type := 'Z' Result := 'Z'
Else Else
If (Buf[3] = '-') and (Buf[4] = 'l') and (Buf[5] in ['h', 'z']) Then
If Pos('.LZH', Name) > 0 Then Result := 'L';
Get_Arc_Type := 'L';
End; End;
Constructor TGeneralArchive.Init; Constructor TGeneralArchive.Init;
@ -129,7 +127,7 @@ Begin
If DosError <> 0 Then Exit; If DosError <> 0 Then Exit;
Case Get_Arc_Type(_Name) of Case GetArchiveType(_Name) of
'?' : Exit; '?' : Exit;
'A' : _Archive := New(PArjArchive, Init); 'A' : _Archive := New(PArjArchive, Init);
'Z' : _Archive := New(PZipArchive, Init); 'Z' : _Archive := New(PZipArchive, Init);

View File

@ -1,81 +1,80 @@
Unit aviewlzh; Unit AViewLZH;
{$I M_OPS.PAS} {$I M_OPS.PAS}
Interface Interface
Uses Dos,aview; Uses
Dos,
AView;
Type LFHeader=Record Type
Headsize,Headchk :byte; LFHeader = Record
HeadID :packed Array[1..5] of char; HeadSize,
Packsize,Origsize,Filetime:longint; HeadChk : Byte;
Attr :word; HeadID : Packed Array[1..5] of Char;
Filename :string[12]; PackSize,
f32 :pathstr; OrigSize,
dt :DateTime; FileTime : LongInt;
end; Attr : Word;
FileName : String[12];
F32 : PathStr;
type PLzhArchive=^TLzhArchive; DT : DateTime;
TLzhArchive=object(TGeneralArchive) End;
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;
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;
Implementation Implementation
Constructor TLzhArchive.Init;
Begin
_SL := 0;
FillChar (_FHdr,sizeof(_FHdr), 0);
End;
constructor TLzhArchive.Init; Procedure TLzhArchive.GetHeader (Var SR: ArcSearchRec);
begin
_SL:=0;
FillChar(_FHdr,sizeof(_FHdr),0);
end;
procedure TLzhArchive.GetHeader(var sr:ArcSearchRec);
Var Var
{$IFDEF MSDOS}
NR : Word;
{$ELSE}
NR : LongInt; NR : LongInt;
{$ENDIF} Begin
begin FillChar (SR, SizeOf(SR), 0);
fillchar(sr,sizeof(sr),0); Seek (ArcFile, _SL);
seek(ArcFile,_SL);
if eof(ArcFile) then Exit;
blockread(ArcFile,_FHdr,sizeof(LFHeader),nr);
if _FHdr.headsize=0 then exit;
inc(_SL,_FHdr.headsize);
inc(_SL,2);
inc(_SL,_FHdr.packsize);
if _FHdr.headsize<>0 then
UnPackTime(_FHdr.FileTime,_FHdr.DT);
sr.Name:=_FHdr.FileName;
sr.Size:=_FHdr.OrigSize;
sr.Time:=_FHdr.FileTime;
end;
If Eof(ArcFile) Then Exit;
procedure TLzhArchive.FindFirst(var sr:ArcSearchRec); BlockRead (ArcFile, _FHdr, SizeOf(LFHeader), NR);
begin
_SL:=0;
GetHeader(sr);
end;
If _FHdr.HeadSize = 0 Then Exit;
procedure TLzhArchive.FindNext(var sr:ArcSearchRec); Inc (_SL, _FHdr.HeadSize);
begin Inc (_SL, 2);
GetHeader(sr); Inc (_SL, _FHdr.PackSize);
end;
If _FHdr.HeadSize <> 0 Then
UnPackTime (_FHdr.FileTime, _FHdr.DT);
end. SR.Name := _FHdr.FileName;
SR.Size := _FHdr.OrigSize;
SR.Time := _FHdr.FileTime;
End;
{ CUT ----------------------------------------------------------- } Procedure TLzhArchive.FindFirst (Var SR: ArcSearchRec);
Begin
_SL := 0;
GetHeader(SR);
End;
Procedure TLzhArchive.FindNext (Var SR: ArcSearchRec);
Begin
GetHeader(SR);
End;
End.

View File

@ -34,7 +34,7 @@ Begin
Form.AddBol ('A', ' Active ' , 20, 7, 30, 7, 8, 3, @Arc.Active, ''); Form.AddBol ('A', ' Active ' , 20, 7, 30, 7, 8, 3, @Arc.Active, '');
Form.AddStr ('X', ' Extension ' , 17, 8, 30, 8, 11, 4, 4, @Arc.Ext, ''); Form.AddStr ('X', ' Extension ' , 17, 8, 30, 8, 11, 4, 4, @Arc.Ext, '');
Form.AddTog ('O', ' OS ' , 24, 9, 30, 9, 4, 7, 0, 2, 'Windows Linux OSX', @Arc.OSType, ''); Form.AddTog ('O', ' OS ' , 24, 9, 30, 9, 4, 7, 0, 3, 'Windows Linux OSX All', @Arc.OSType, '');
Form.AddStr ('D', ' Description ' , 15, 10, 30, 10, 13, 30, 30, @Arc.Desc, ''); Form.AddStr ('D', ' Description ' , 15, 10, 30, 10, 13, 30, 30, @Arc.Desc, '');
Form.AddStr ('P', ' Pack Cmd ' , 18, 11, 30, 11, 10, 35, 80, @Arc.Pack, ''); Form.AddStr ('P', ' Pack Cmd ' , 18, 11, 30, 11, 10, 35, 80, @Arc.Pack, '');
Form.AddStr ('U', ' Unpack Cmd ' , 16, 12, 30, 12, 12, 35, 80, @Arc.Unpack, ''); Form.AddStr ('U', ' Unpack Cmd ' , 16, 12, 30, 12, 12, 35, 80, @Arc.Unpack, '');
@ -70,6 +70,7 @@ Var
0 : OS := 'Windows'; 0 : OS := 'Windows';
1 : OS := 'Linux '; 1 : OS := 'Linux ';
2 : OS := 'OSX '; 2 : OS := 'OSX ';
3 : OS := 'All ';
End; End;
List.Add (strPadR(YesNoStr[Arc.Active], 5, ' ') + strPadR(Arc.Ext, 7, ' ') + OS + ' ' + Arc.Desc, 0); List.Add (strPadR(YesNoStr[Arc.Active], 5, ' ') + strPadR(Arc.Ext, 7, ' ') + OS + ' ' + Arc.Desc, 0);

View File

@ -419,10 +419,10 @@ Function TFileBase.ImportDIZ (FN: String) : Boolean;
Procedure RemoveLine (Num: Byte); Procedure RemoveLine (Num: Byte);
Var Var
A : Byte; Count : Byte;
Begin Begin
For A := Num To FDir.DescLines - 1 Do For Count := Num To FDir.DescLines - 1 Do
Session.Msgs.Msgtext[A] := Session.Msgs.MsgText[A + 1]; Session.Msgs.Msgtext[Count] := Session.Msgs.MsgText[Count + 1];
Session.Msgs.MsgText[FDir.DescLines] := ''; Session.Msgs.MsgText[FDir.DescLines] := '';
@ -430,25 +430,49 @@ Function TFileBase.ImportDIZ (FN: String) : Boolean;
End; End;
Var Var
tFile : Text; DizFile : Text;
DizName : String; DizName : String;
{$IFDEF FS_SENSITIVE}
Arc : PArchive;
SR : ArcSearchRec;
{$ENDIF}
Begin Begin
Result := False; Result := False;
DizName := 'file_id.diz';
ExecuteArchive (FBase.Path + FN, '', 'file_id.diz', 2); {$IFDEF FS_SENSITIVE}
Arc := New(PArchive, Init);
If Arc^.Name(FN) Then Begin
Arc^.FindFirst(SR);
While SR.Name <> '' Do Begin
If (strUpper(SR.Name) = 'FILE_ID.DIZ') Then Begin
DizName := SR.Name;
Break;
End;
Arc^.FindNext(SR);
End;
Dispose (Arc, Done);
End;
{$ENDIF}
ExecuteArchive (FBase.Path + FN, '', DizName, 2);
DizName := FileFind(Session.TempPath + 'file_id.diz'); DizName := FileFind(Session.TempPath + 'file_id.diz');
Assign (tFile, DizName); Assign (DizFile, DizName);
{$I-} Reset (tFile); {$I+} {$I-} Reset (DizFile); {$I+}
If IoResult = 0 Then Begin If IoResult = 0 Then Begin
Result := True; Result := True;
FDir.DescLines := 0; FDir.DescLines := 0;
While Not Eof(tFile) Do Begin While Not Eof(DizFile) Do Begin
Inc (FDir.DescLines); Inc (FDir.DescLines);
ReadLn (tFile, Session.Msgs.MsgText[FDir.DescLines]); ReadLn (DizFile, Session.Msgs.MsgText[FDir.DescLines]);
Session.Msgs.MsgText[FDir.DescLines] := strStripLOW(Session.Msgs.MsgText[FDir.DescLines]); Session.Msgs.MsgText[FDir.DescLines] := strStripLOW(Session.Msgs.MsgText[FDir.DescLines]);
@ -457,7 +481,7 @@ Begin
If FDir.DescLines = Config.MaxFileDesc Then Break; If FDir.DescLines = Config.MaxFileDesc Then Break;
End; End;
Close (tFile); Close (DizFile);
FileErase(DizName); FileErase(DizName);
@ -765,9 +789,6 @@ Function TFileBase.ArchiveList (FName : String) : Boolean;
Var Var
Arc : PArchive; Arc : PArchive;
SR : ArcSearchRec; SR : ArcSearchRec;
D : DirStr;
N : NameStr;
E : ExtStr;
Begin Begin
Result := False; Result := False;
Arc := New(PArchive, Init); Arc := New(PArchive, Init);
@ -780,15 +801,16 @@ Begin
Session.io.OutFile (Session.TempPath + '_view_.tmp', True, 0); Session.io.OutFile (Session.TempPath + '_view_.tmp', True, 0);
FileErase (Session.TempPath + '_view_.tmp'); FileErase (Session.TempPath + '_view_.tmp');
End; End;
Result := True;
Exit; Exit;
End; End;
Session.io.AllowPause := True; Session.io.AllowPause := True;
Session.io.PausePtr := 1; Session.io.PausePtr := 1;
FSplit (FName, D, N, E); {make getpath and getfname functions???} Session.io.PromptInfo[1] := JustFile(FName);
Session.io.PromptInfo[1] := N + E;
Session.io.OutFullLn (Session.GetPrompt(192)); Session.io.OutFullLn (Session.GetPrompt(192));
@ -884,6 +906,7 @@ Begin
Repeat Repeat
Session.io.OutFull (Session.GetPrompt(304)); Session.io.OutFull (Session.GetPrompt(304));
Case Session.io.OneKey('DQRV', True) of Case Session.io.OneKey('DQRV', True) of
'D' : Begin 'D' : Begin
Session.io.OutFull (Session.GetPrompt(384)); Session.io.OutFull (Session.GetPrompt(384));
@ -1064,39 +1087,54 @@ End;
Function TFileBase.SelectArchive : Boolean; Function TFileBase.SelectArchive : Boolean;
Var Var
A : SmallInt; NewArc : SmallInt;
Count : SmallInt;
Begin Begin
Result := False; Result := False;
Count := 0;
Session.io.OutRawLn ('');
Reset (ArcFile); Reset (ArcFile);
If Eof(ArcFile) Then Begin
Session.io.OutFullLn (Session.GetPrompt(169));
Close (ArcFile);
Exit;
End;
Session.io.OutFullLn (Session.GetPrompt(73));
While Not Eof(ArcFile) Do Begin While Not Eof(ArcFile) Do Begin
Read (ArcFile, Arc); Read (ArcFile, Arc);
Session.io.PromptInfo[1] := strI2S(FilePos(ArcFile)); If Arc.Active and ((Arc.OSType = OSType) or (Arc.OSType = 3)) Then Begin
Inc (Count);
If Count = 1 Then
Session.io.OutFullLn (Session.GetPrompt(73));
Session.io.PromptInfo[1] := strI2S(Count);
Session.io.PromptInfo[2] := Arc.Desc; Session.io.PromptInfo[2] := Arc.Desc;
Session.io.PromptInfo[3] := Arc.Ext; Session.io.PromptInfo[3] := Arc.Ext;
Session.io.OutFullLn (Session.GetPrompt(170)); Session.io.OutFullLn (Session.GetPrompt(170));
End; End;
End;
If Count = 0 Then Begin
Session.io.OutFullLn (Session.GetPrompt(169));
Close (ArcFile);
Exit;
End;
Session.io.OutFull (Session.GetPrompt(171)); Session.io.OutFull (Session.GetPrompt(171));
A := strS2I(Session.io.GetInput(2, 2, 12, '')); NewArc := strS2I(Session.io.GetInput(2, 2, 12, ''));
If (A > 0) and (A <= FileSize(ArcFile)) Then Begin If (NewArc > 0) and (NewArc <= Count) Then Begin
Seek (ArcFile, A - 1); Reset (ArcFile);
Count := 0;
While Not Eof(ArcFile) And (Count <> NewArc) Do Begin
Read (ArcFile, Arc); Read (ArcFile, Arc);
If (Arc.Active) and ((Arc.OSType = OSType) or (Arc.OSType = 3)) Then
Inc (Count);
End;
End Else Begin End Else Begin
Close (ArcFile); Close (ArcFile);
Exit; Exit;
@ -1194,9 +1232,13 @@ Var
Temp2 : String[60]; Temp2 : String[60];
Begin Begin
If Temp = '' Then If Temp = '' Then
Case Get_Arc_Type(FName) of Case GetArchiveType(FName) of
'A' : Temp := 'ARJ'; 'A' : Temp := 'ARJ';
'L' : Temp := 'LZH'; 'L' : Begin
Temp := 'LZH';
If strUpper(JustFileExt(FName)) = 'LHA' Then Temp := 'LHA';
End;
'R' : Temp := 'RAR'; 'R' : Temp := 'RAR';
'Z' : Temp := 'ZIP'; 'Z' : Temp := 'ZIP';
'?' : Temp := strUpper(JustFileExt(FName)); '?' : Temp := strUpper(JustFileExt(FName));
@ -1212,7 +1254,8 @@ Begin
Read (ArcFile, Arc); Read (ArcFile, Arc);
If (Not Arc.Active) or (Arc.OSType <> OSType) Then Continue; If (Not Arc.Active) or ((Arc.OSType <> OSType) and (Arc.OSType <> 3)) Then
Continue;
If strUpper(Arc.Ext) = Temp Then Break; If strUpper(Arc.Ext) = Temp Then Break;
Until False; Until False;