home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / PROGRAM / PASCAL / PARADIS1 / ARJVIEW.PAS < prev    next >
Pascal/Delphi Source File  |  1992-02-25  |  5KB  |  153 lines

  1. (7189)  Sat 22 Feb 92 13:43
  2. By: Steve Gabrilowitz
  3. To: Darren Lyon
  4. Re: Re: Arj viewing
  5. St:
  6. ---------------------------------------------------------------------------
  7. @PID: QE 2.76 (Beta-5)
  8. @MSGID: 1:363/1701 29A10D6B
  9. In a message to Steve Gabrilowitz <02-20-92 00:33> Darren Lyon wrote:
  10.  
  11. DL>  Steve Gabrilowitz of [1:363/1701] once typed in a message to someone:
  12. DL>
  13. DL>   SG> Are you looking for something that will extract and display text
  14. DL>  files
  15. DL>   SG> from the ARJ, or just a program to read the header and display
  16. DL>  the
  17. DL>   SG> directory?  I have the latter...
  18. DL>
  19. DL>     Does it write out a display similar to that of the ARJ L ***.ARJ
  20. DL>  command?
  21. DL>  Well not the same, but accesses all the information? If so, can you
  22. DL>  post it
  23. DL>  here??
  24.  
  25. A bit ugly, but here it is:
  26.  
  27. Program ListARJ;
  28. Uses OpString;
  29. Type
  30.   ARJsignature=Record
  31.                  MagicNumber : Word;
  32.                  BasicHdrSiz : Word;
  33.   End;
  34.   ARJheader=record
  35.               FirstHdrSize: Byte; (* size up to extra data *)
  36.               ARJversion  : Byte; (* version that created archive *)
  37.               ARJrequired : Byte; (* oldest possible to unextract *)
  38.               HostOS      : Byte;
  39.               Flags       : Byte;
  40.               Method      : Byte; (* 0=stored, or comp level 1-4 *)
  41.               FileType    : Byte; (* 0=binary, 1=text, 2=comment header *)
  42.               GarbleMod   : Byte; (* Garbled password modifier? *)
  43.               DateTime    : LongInt;
  44.               CompSize    : LongInt;
  45.               OrigSize    : LongInt;
  46.               OrigCRC     : Array[1..4] of Byte;
  47.               EntryName   : Word; (* entryname position in filename? *)
  48.               AccessMode  : Word;
  49.               HostData    : Word;
  50.   End;
  51. Var
  52.   ArjFile : File;
  53.   Hdr  : ARJheader;
  54.   Sig  : ARJsignature;
  55.   FileName : String;
  56.   MethodStr: String;
  57.   JunkByte : Byte;
  58.   BytesRead : Word;
  59.   I : Integer;
  60.   HeaderCRC : LongInt;
  61.   ExtSize : Word;
  62.   TimeStr : String[5];
  63.   DateStr : String[8];
  64.   Month,Day,Year,Hour,Minute : Word;
  65.   Ratio : Word;
  66. function int_str(Num,Len : Word) : String;
  67. Var
  68.   Answer : String[5];
  69. Begin
  70.   Answer:=Long2Str(Num);
  71.   While Length(Answer)<Len Do Answer:='0'+Answer;
  72.   Int_Str:=Answer;
  73. End;
  74. Begin
  75.   Write('ARJ file: '); Readln(FileName);
  76.   Assign(ArjFile,FileName);
  77.   Reset(ArjFile,1);
  78.   BlockRead(ArjFile,Sig,SizeOf(Sig));
  79.   BlockRead(ArjFile,Hdr,SizeOf(Hdr),BytesRead);
  80.   I:=0;
  81.   Repeat
  82.     Inc(I);
  83.     BlockRead(ArjFile,FileName[I],1);
  84.   Until FileName[I]=#0;
  85.   FileName[0]:=Chr(I-1);
  86.   Repeat
  87.     BlockRead(ArjFile,JunkByte,1);
  88.   Until JunkByte=0; (* Blow off the comment *)
  89.   BlockRead(ArjFile,HeaderCRC,4);
  90.   BlockRead(ArjFile,ExtSize,2);
  91.   If ExtSize>0 Then Seek(ArjFile,FilePos(ArjFile)+ExtSize+4);
  92.   BlockRead(ArjFile,Sig,SizeOf(Sig));
  93.   Writeln('Filename      Length     Method   Size Now  Ratio  Date Time
  94. CRC');
  95.   Writeln('------------  --------  --------  --------  -----  --------- -----
  96. --------');
  97.  
  98.   While Sig.BasicHdrSiz>0 Do
  99.   Begin
  100.     BlockRead(ArjFile,Hdr,SizeOf(Hdr),BytesRead);
  101.     I:=0;
  102.     Repeat
  103.       Inc(I);
  104.       BlockRead(ArjFile,FileName[I],1);
  105.     Until FileName[I]=#0;
  106.     FileName[0]:=Chr(I-1);
  107.     Repeat
  108.       BlockRead(ArjFile,JunkByte,1);
  109.     Until JunkByte=0; (* Blow off the comment *)
  110.     Case Hdr.Method Of
  111.     0 : MethodStr := ' Stored ';
  112.     1 : MethodStr := 'Factor-1';
  113.     2 : MethodStr := 'Factor-2';
  114.     3 : MethodStr := 'Factor-3';
  115.     4 : MethodStr := 'Factor-4';
  116.     Else
  117.         MethodStr := 'Unknown ';
  118.     End;
  119.     if (Hdr.CompSize < 1) or (Hdr.OrigSize < 1) then
  120.       Ratio := 0
  121.     else
  122.       Ratio := (100*(Hdr.OrigSize-Hdr.CompSize) div Hdr.OrigSize);
  123.     Month:=(Hdr.DateTime shr 21) and $0F;
  124.     Day:=(Hdr.DateTime shr 16) and $1F;
  125.     Year:=((Hdr.DateTime shr 25) and $7F)+80;
  126.     Hour:=(Hdr.DateTime shr 11) and $1F;
  127.     Minute:=(Hdr.DateTime shr 5) and $3F;
  128.     TimeStr := int_str(Hour, 2)+':'+int_str(Minute, 2);
  129.     DateStr := int_str(Month, 2)+'-'+int_str(Day, 2)+'-'+int_str(Year, 2);
  130.     Writeln(Pad(FileName,12)+'  '+
  131.             Pad(Long2Str(Hdr.OrigSize),8)+'  '+
  132.             MethodStr+'  '+
  133.             Pad(Long2Str(Hdr.CompSize),8)+'  '+
  134.             Pad(Long2Str(Ratio)+'%', 5)+'  '+
  135.             DateStr+'  '+
  136.             TimeStr+'  '+
  137.             HexB(Hdr.OrigCRC[4])+
  138.             HexB(Hdr.OrigCRC[3])+
  139.             HexB(Hdr.OrigCRC[2])+
  140.             HexB(Hdr.OrigCRC[1]));
  141.  
  142.     BlockRead(ArjFile,HeaderCRC,4);
  143.     BlockRead(ArjFile,ExtSize,2);
  144.     Seek(ArjFile,FilePos(ArjFile)+Hdr.CompSize);
  145.     BlockRead(ArjFile,Sig,SizeOf(Sig));
  146.   End;
  147. End.
  148.  
  149. --- QuickBBS 2.76 (Beta-5)
  150.  * Origin: NCC-1701 - Orlando, FL  Warp 9.6 HST (407) 380-1701 (1:363/1701)
  151.  
  152. @PATH: 363/1701 320 151/1003 13/13 396/1 170/400 512/0 1007 
  153.