From 679234a5550af84ed2ef60b6de9493181964a2f4 Mon Sep 17 00:00:00 2001 From: mysticbbs Date: Sun, 19 Aug 2012 14:22:24 -0400 Subject: [PATCH] Bunch of archive fixes for LZH/LHA and FILE_ID importing --- mystic/HISTORY.txt | 20 +++++- mystic/aview.pas | 26 ++++---- mystic/aviewlzh.pas | 121 ++++++++++++++++++----------------- mystic/bbs_cfg_archive.pas | 3 +- mystic/bbs_filebase.pas | 127 +++++++++++++++++++++++++------------ 5 files changed, 177 insertions(+), 120 deletions(-) diff --git a/mystic/HISTORY.txt b/mystic/HISTORY.txt index da72f36..3fb0579 100644 --- a/mystic/HISTORY.txt +++ b/mystic/HISTORY.txt @@ -4670,5 +4670,21 @@ ! Fixed a bug that could cause viewing files from within an archive to fail. - + MUTIL now has the ability to import FILES.BBS files automatically. See - the MUTIL.CFG file for more information. + + MUTIL now has the ability to import FILES.BBS files automatically. In + 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. diff --git a/mystic/aview.pas b/mystic/aview.pas index 9b53bf5..c4977d1 100644 --- a/mystic/aview.pas +++ b/mystic/aview.pas @@ -29,7 +29,7 @@ Type TArchive = Object Constructor Init; Destructor Done; - Function Name (n:string) : Boolean; + Function Name (N: String) : Boolean; Procedure FindFirst (Var SR: ArcSearchRec); Procedure FindNext (Var SR: ArcSearchRec); Private @@ -37,7 +37,7 @@ Type _Archive : PGeneralArchive; End; -Function Get_Arc_Type (Name: String) : Char; +Function GetArchiveType (Name: String) : Char; Implementation @@ -47,13 +47,14 @@ Uses AViewLZH, AViewRAR; -Function Get_Arc_Type (Name: String) : Char; +Function GetArchiveType (Name: String) : Char; Var ArcFile : File; - Buf : Array[1..3] of Char; + Buf : Array[1..5] of Char; Res : LongInt; Begin - Get_Arc_Type := '?'; + Result := '?'; + If Name = '' Then Exit; Assign (ArcFile, Name); @@ -66,19 +67,16 @@ Begin If Res = 0 Then Exit; If (Buf[1] = 'R') and (Buf[2] = 'a') and (Buf[3] = 'r') Then - Get_Arc_Type := 'R' + Result := 'R' Else - If (Buf[1] = #$60) And (Buf[2] = #$EA) Then - Get_Arc_Type := 'A' + Result := 'A' Else - If (Buf[1] = 'P') And (Buf[2] = 'K') Then - Get_Arc_Type := 'Z' + Result := 'Z' Else - - If Pos('.LZH', Name) > 0 Then - Get_Arc_Type := 'L'; + If (Buf[3] = '-') and (Buf[4] = 'l') and (Buf[5] in ['h', 'z']) Then + Result := 'L'; End; Constructor TGeneralArchive.Init; @@ -129,7 +127,7 @@ Begin If DosError <> 0 Then Exit; - Case Get_Arc_Type(_Name) of + Case GetArchiveType(_Name) of '?' : Exit; 'A' : _Archive := New(PArjArchive, Init); 'Z' : _Archive := New(PZipArchive, Init); diff --git a/mystic/aviewlzh.pas b/mystic/aviewlzh.pas index d4ac810..2996f49 100644 --- a/mystic/aviewlzh.pas +++ b/mystic/aviewlzh.pas @@ -1,81 +1,80 @@ -Unit aviewlzh; +Unit AViewLZH; {$I M_OPS.PAS} Interface -Uses Dos,aview; +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]; - f32 :pathstr; - dt :DateTime; - end; - - -type 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; +Type + LFHeader = Record + HeadSize, + HeadChk : Byte; + HeadID : Packed Array[1..5] of Char; + PackSize, + OrigSize, + FileTime : LongInt; + Attr : Word; + FileName : String[12]; + F32 : PathStr; + 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; Implementation +Constructor TLzhArchive.Init; +Begin + _SL := 0; + FillChar (_FHdr,sizeof(_FHdr), 0); +End; -constructor TLzhArchive.Init; -begin - _SL:=0; - FillChar(_FHdr,sizeof(_FHdr),0); -end; - - -procedure TLzhArchive.GetHeader(var sr:ArcSearchRec); +Procedure TLzhArchive.GetHeader (Var SR: ArcSearchRec); Var - {$IFDEF MSDOS} - NR : Word; - {$ELSE} NR : LongInt; - {$ENDIF} -begin - fillchar(sr,sizeof(sr),0); - 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; +Begin + FillChar (SR, SizeOf(SR), 0); + Seek (ArcFile, _SL); + If Eof(ArcFile) Then Exit; -procedure TLzhArchive.FindFirst(var sr:ArcSearchRec); -begin - _SL:=0; - GetHeader(sr); -end; + BlockRead (ArcFile, _FHdr, SizeOf(LFHeader), NR); + If _FHdr.HeadSize = 0 Then Exit; -procedure TLzhArchive.FindNext(var sr:ArcSearchRec); -begin - GetHeader(sr); -end; + Inc (_SL, _FHdr.HeadSize); + Inc (_SL, 2); + Inc (_SL, _FHdr.PackSize); + 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. \ No newline at end of file diff --git a/mystic/bbs_cfg_archive.pas b/mystic/bbs_cfg_archive.pas index b2a2234..b2e0b4b 100644 --- a/mystic/bbs_cfg_archive.pas +++ b/mystic/bbs_cfg_archive.pas @@ -34,7 +34,7 @@ Begin 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.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 ('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, ''); @@ -70,6 +70,7 @@ Var 0 : OS := 'Windows'; 1 : OS := 'Linux '; 2 : OS := 'OSX '; + 3 : OS := 'All '; End; List.Add (strPadR(YesNoStr[Arc.Active], 5, ' ') + strPadR(Arc.Ext, 7, ' ') + OS + ' ' + Arc.Desc, 0); diff --git a/mystic/bbs_filebase.pas b/mystic/bbs_filebase.pas index 92edf59..00f05c7 100644 --- a/mystic/bbs_filebase.pas +++ b/mystic/bbs_filebase.pas @@ -419,10 +419,10 @@ Function TFileBase.ImportDIZ (FN: String) : Boolean; Procedure RemoveLine (Num: Byte); Var - A : Byte; + Count : Byte; Begin - For A := Num To FDir.DescLines - 1 Do - Session.Msgs.Msgtext[A] := Session.Msgs.MsgText[A + 1]; + For Count := Num To FDir.DescLines - 1 Do + Session.Msgs.Msgtext[Count] := Session.Msgs.MsgText[Count + 1]; Session.Msgs.MsgText[FDir.DescLines] := ''; @@ -430,25 +430,49 @@ Function TFileBase.ImportDIZ (FN: String) : Boolean; End; Var - tFile : Text; + DizFile : Text; DizName : String; + {$IFDEF FS_SENSITIVE} + Arc : PArchive; + SR : ArcSearchRec; + {$ENDIF} 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'); - Assign (tFile, DizName); - {$I-} Reset (tFile); {$I+} + Assign (DizFile, DizName); + {$I-} Reset (DizFile); {$I+} If IoResult = 0 Then Begin Result := True; FDir.DescLines := 0; - While Not Eof(tFile) Do Begin + While Not Eof(DizFile) Do Begin 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]); @@ -457,7 +481,7 @@ Begin If FDir.DescLines = Config.MaxFileDesc Then Break; End; - Close (tFile); + Close (DizFile); FileErase(DizName); @@ -765,9 +789,6 @@ Function TFileBase.ArchiveList (FName : String) : Boolean; Var Arc : PArchive; SR : ArcSearchRec; - D : DirStr; - N : NameStr; - E : ExtStr; Begin Result := False; Arc := New(PArchive, Init); @@ -776,19 +797,20 @@ Begin Dispose (Arc, Done); If FileExist(FName) Then Begin - ExecuteArchive (FName, '', '_view_.tmp', 3); - Session.io.OutFile (Session.TempPath + '_view_.tmp', True, 0); - FileErase (Session.TempPath + '_view_.tmp'); + ExecuteArchive (FName, '', '_view_.tmp', 3); + Session.io.OutFile (Session.TempPath + '_view_.tmp', True, 0); + FileErase (Session.TempPath + '_view_.tmp'); End; + + Result := True; + Exit; End; Session.io.AllowPause := True; Session.io.PausePtr := 1; - FSplit (FName, D, N, E); {make getpath and getfname functions???} - - Session.io.PromptInfo[1] := N + E; + Session.io.PromptInfo[1] := JustFile(FName); Session.io.OutFullLn (Session.GetPrompt(192)); @@ -884,6 +906,7 @@ Begin Repeat Session.io.OutFull (Session.GetPrompt(304)); + Case Session.io.OneKey('DQRV', True) of 'D' : Begin Session.io.OutFull (Session.GetPrompt(384)); @@ -1064,39 +1087,54 @@ End; Function TFileBase.SelectArchive : Boolean; Var - A : SmallInt; + NewArc : SmallInt; + Count : SmallInt; Begin Result := False; - - Session.io.OutRawLn (''); + Count := 0; 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 Read (ArcFile, Arc); - Session.io.PromptInfo[1] := strI2S(FilePos(ArcFile)); - Session.io.PromptInfo[2] := Arc.Desc; - Session.io.PromptInfo[3] := Arc.Ext; + If Arc.Active and ((Arc.OSType = OSType) or (Arc.OSType = 3)) Then Begin + Inc (Count); - Session.io.OutFullLn (Session.GetPrompt(170)); + 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[3] := Arc.Ext; + + Session.io.OutFullLn (Session.GetPrompt(170)); + End; + End; + + If Count = 0 Then Begin + Session.io.OutFullLn (Session.GetPrompt(169)); + + Close (ArcFile); + + Exit; End; 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 - Seek (ArcFile, A - 1); - Read (ArcFile, Arc); + If (NewArc > 0) and (NewArc <= Count) Then Begin + Reset (ArcFile); + + Count := 0; + + While Not Eof(ArcFile) And (Count <> NewArc) Do Begin + Read (ArcFile, Arc); + + If (Arc.Active) and ((Arc.OSType = OSType) or (Arc.OSType = 3)) Then + Inc (Count); + End; End Else Begin Close (ArcFile); Exit; @@ -1194,9 +1232,13 @@ Var Temp2 : String[60]; Begin If Temp = '' Then - Case Get_Arc_Type(FName) of + Case GetArchiveType(FName) of 'A' : Temp := 'ARJ'; - 'L' : Temp := 'LZH'; + 'L' : Begin + Temp := 'LZH'; + + If strUpper(JustFileExt(FName)) = 'LHA' Then Temp := 'LHA'; + End; 'R' : Temp := 'RAR'; 'Z' : Temp := 'ZIP'; '?' : Temp := strUpper(JustFileExt(FName)); @@ -1212,7 +1254,8 @@ Begin 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; Until False;