home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS 1992 September / Simtel20_Sept92.cdr / msdos / arc_lbr / update.arc / UPDATE.PAS < prev   
Pascal/Delphi Source File  |  1988-09-24  |  19KB  |  648 lines

  1. {Turbo Pascal 4.0}
  2. {$I+,R+,S+,T+,D+,F-,B-,V+}
  3. {$M 16384,0,16384}
  4. program Update;
  5.  
  6. {-------------------------------------------------------------------------
  7.  
  8.      Update converts archives from PKpak to Zoo and from Zoo to PKpak.
  9. It also will re-archive a PKpak archive to try and make it smaller.  If
  10. the new archive is larger than the old archive, it will not replace the
  11. old one.  Update will keep the date and time of the archive's the same
  12. through conversion and re-archiving.  Update is configurable through
  13. enviroment strings.  It needs to know the full path name and file name
  14. of PKpak, PKunpak, and Zoo.  These are entered in the enviroment under
  15. "ARCPATH=", "UNARCPATH=", and "ZOOPATH=" respectively.  Update also needs
  16. to know what name to use for it's temporary directory.  This directory
  17. is made and removed each time Update is run.  This is stored in the
  18. enviroment string "WORKDIR=".  Update will not work across drives (i.e.
  19. Both the working and the Input directory must be on the same drive.).
  20. The command line options are "update [Input Directory] (/r || /pz || /zp)".
  21. The Input Directory is optional.  If no directory is given, the current
  22. directory will be used.  One of the three "/r","/pz","/zp" may be given.
  23. The first tells Update to Re-archive the files, the second says to convert
  24. from PKpak to Zoo, and the third says to convert from Zoo to PKpak.
  25.      This program is donated to the Public Domain.  You may do what you
  26. wish with it.  If you modify it and redistribute it, include a "signature"
  27. below mine, the date, and a short discription of the modifications done.
  28.  
  29. Derrick Hamner, 8/24/88 -- Wrote the original program.
  30.  
  31. -------------------------------------------------------------------------}
  32.  
  33. Uses
  34.   Crt,
  35.   Graph,
  36.   Dos;
  37.  
  38. const
  39.   ArcName : String[8] = 'ARCPATH=';
  40.   UnArcName : String[10] = 'UNARCPATH=';
  41.   ZooName : String[8] = 'ZOOPATH=';
  42.   WorkDirName : String[8] = 'WORKDIR=';
  43.   DefaultArc : String[20] = '\ARCHIVE\PKPAK.EXE';
  44.   DefaultUnArc : String[22] = '\ARCHIVE\PKUNPAK.EXE';
  45.   DefaultZoo : String[18] = '\ARCHIVE\ZOO.EXE';
  46.   DefaultWorkDir : String[8] = '\T_M_P';
  47.   ValidSwitches : string[12] = ' /r /pz /zp ';
  48.  
  49. type
  50.   StoreFilePtr = ^StoreFile;      {Used to store the file data for the}
  51.   StoreFile = record              {final report}
  52.                 Name : string[13];
  53.                 OrgSize, NewSize : LongInt;
  54.                 Next : StoreFilePtr;
  55.               end;
  56.  
  57. var
  58.   InDir, HomeDir : string;
  59.   Switch : String[3];
  60.   OldDiskSpace : LongInt;
  61.   Head, Current, Previous : StoreFilePtr;
  62.   Arc, UnArc, Zoo, WorkDir : String;
  63.  
  64.  
  65. {/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/}
  66. procedure Error (ErrorNumber : Byte);
  67.  
  68. begin
  69.   write(#7);
  70.   case ErrorNumber of
  71.     1 : writeln('Error in procedure DeleteFile.');
  72.     2 : writeln('Error in procedure MoveFile.');
  73.     3 : writeln('Illegal switch.');
  74.     4 : writeln('The working directory does not exist.');
  75.     5 : writeln('Sub-program (PkPak/unpak or Zoo) error.');
  76.     6 : writeln('Input directory does not exist.');
  77.     7 : writeln('Working directory has files in it.');
  78.     8 : writeln('There are no *.ARC or *.ZOO files in the Input directory.');
  79.     9 : writeln('Wrong number of parameters.');
  80.     10: writeln('Directory "',WorkDir,'" left over from previous error.');
  81.   end;
  82.   ChDir(HomeDir);
  83. {$I-}
  84.   RmDir(WorkDir);
  85. {$I+}
  86.   Halt(1);
  87. end;
  88.  
  89.  
  90. {/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/}
  91. procedure Setup;
  92.  
  93. var
  94.   I, J, TempPos : Byte;
  95.   EnviromentSegment : Word;
  96.   Enviroment : string;
  97.   TempPtr1 : ^Word;
  98.   TempPtr2 : ^Char;
  99.  
  100. {/\/\/\/\/\/\/\/\/\/\/\/\/\/}
  101. procedure GetEnviroment;
  102.  
  103. begin
  104.   TempPtr1 := Ptr(PreFixSeg, $2C);
  105.   EnviromentSegment := TempPtr1^;
  106. end;
  107.  
  108. {/\/\/\/\/\/\/\/\/\/\/\/\/\/}
  109. {/\/\/\/\/\/\/\/\/\/\/\/\/\/}
  110. begin
  111.   Arc := DefaultArc;
  112.   UnArc := DefaultUnArc;
  113.   Zoo := DefaultZoo;
  114.   WorkDir := DefaultWorkDir;
  115.   GetEnviroment;
  116.  
  117.   J := 0;
  118.   repeat
  119.     Enviroment[0] := #255;        {Read the first 255 characters of the}
  120.     for I := 1 to 255 do          {enviroment.}
  121.       begin
  122.         TempPtr2 := Ptr(EnviromentSegment,I - 1 + J * 255);
  123.         Enviroment[I] := TempPtr2^;
  124.       end;
  125.                                   {Search for ArcName in the enviroment}
  126.     TempPos := Pos(ArcName, Enviroment);
  127.     if TempPos <> 0
  128.       then begin                  {If found, set Arc equal to the}
  129.              I := 1;              {enviroment string}
  130.              repeat
  131.                Arc[I] := Enviroment[TempPos + 7 + I];
  132.                Inc(I);
  133.              until Enviroment[TempPos + 7 + I] = #0;
  134.              Arc[0] := Chr(I - 1);
  135.            end;
  136.  
  137.     TempPos := Pos(UnArcName, Enviroment);
  138.     if TempPos <> 0
  139.       then begin
  140.              I := 1;
  141.              repeat
  142.                UnArc[I] := Enviroment[TempPos + 9 + I];
  143.                Inc(I);
  144.              until Enviroment[TempPos + 7 + I] = #0;
  145.              UnArc[0] := Chr(I - 1);
  146.            end;
  147.  
  148.     TempPos := Pos(ZooName, Enviroment);
  149.     if TempPos <> 0
  150.       then begin
  151.              I := 1;
  152.              repeat
  153.                Zoo[I] := Enviroment[TempPos + 7 + I];
  154.                Inc(I);
  155.              until Enviroment[TempPos + 7 + I] = #0;
  156.              Zoo[0] := Chr(I - 1);
  157.            end;
  158.  
  159.     TempPos := Pos(WorkDirName, Enviroment);
  160.     if TempPos <> 0
  161.       then begin
  162.              I := 1;
  163.              repeat
  164.                WorkDir[I] := Enviroment[TempPos + 7 + I];
  165.                Inc(I);
  166.              until Enviroment[TempPos + 7 + I] = #0;
  167.              WorkDir[0] := Chr(I - 1);
  168.            end;
  169.     Inc(J);
  170.   until Pos(#0 + #0,Enviroment) <> 0;
  171. end;
  172.  
  173.  
  174. {/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/}
  175. procedure DeleteFile(FileName : string);
  176.  
  177.                    {Requires DOS 2.0 or later}
  178.  
  179. var
  180.   Regs : Registers;
  181.   TempFileName : array[1..255] of char;
  182.   I : Byte;
  183.  
  184. begin
  185.                                   {Convert filename to an ASCIIZ string}
  186.   for I := 1 to Ord(FileName[0]) do TempFileName[I] := FileName[I];
  187.   TempFileName[Ord(FileName[0]) + 1] := Chr(0);
  188.  
  189.   FillChar(Regs,SizeOf(Regs),0);
  190.   with Regs do
  191.     begin
  192.       AH := $41;             {DOS Delete File}
  193.       DS := Seg(TempFileName);
  194.       DX := Ofs(TempFileName);
  195.     end;
  196.   MSDos(Regs);
  197. end;
  198.  
  199.  
  200. {/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/}
  201. procedure MoveFile(OrgFileName, NewFileName : string);
  202.  
  203.                    {Requires DOS 2.0 or later}
  204.  
  205. var
  206.   Regs : Registers;
  207.   TempOrgFileName, TempNewFileName : array[1..255] of char;
  208.   I : Byte;
  209.  
  210. begin
  211.                                   {Convert filenames to ASCIIZ strings}
  212.   for I := 1 to ord(OrgFileName[0]) do
  213.     TempOrgFileName[I] := OrgFileName[I];
  214.   TempOrgFileName[Ord(OrgFileName[0]) + 1] := Chr(0);
  215.   for I := 1 to ord(OrgFileName[0]) do
  216.     TempNewFileName[I] := NewFileName[I];
  217.   TempNewFileName[Ord(NewFileName[0]) + 1] := Chr(0);
  218.  
  219.   FillChar(Regs,SizeOf(Regs),0);
  220.   with Regs do
  221.     begin
  222.       AH := $56;             {DOS Rename File}
  223.       DS := Seg(TempOrgFileName);
  224.       DX := Ofs(TempOrgFileName);
  225.       ES := Seg(TempNewFileName);
  226.       DI := Ofs(TempNewFileName);
  227.     end;
  228.   MSDos(Regs);
  229. end;
  230.  
  231.  
  232. {/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/}
  233. function GetFileSize (FileName : String) : LongInt;
  234.  
  235. var
  236.   FileHandle : File of Byte;
  237.  
  238. begin
  239.   Assign(FileHandle,FileName);
  240.   Reset(FileHandle);
  241.   GetFileSize := FileSize(FileHandle);
  242.   Close(FileHandle);
  243. end;
  244.  
  245.  
  246. {/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/}
  247. procedure SetFileDateTime (FileName : String; DateTime : LongInt);
  248.  
  249. var
  250.   FileHandle : File;
  251.  
  252. begin
  253.   Assign(FileHandle,FileName);
  254.   Reset(FileHandle);
  255.   SetFTime(FileHandle, DateTime);
  256.   Close(FileHandle);
  257. end;
  258.  
  259.  
  260. {/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/}
  261. procedure Parse;
  262.  
  263. {/\/\/\/\/\/\/\/\/\/\/\/\/\/}
  264. procedure Interpret1;
  265.  
  266. var
  267.   I : Byte;
  268.  
  269. begin
  270.   InDir := HomeDir;
  271.   Switch := ParamStr(1);
  272.   if (Pos(Switch, ValidSwitches) = 0)
  273.     then Error(3);
  274. {$I-}
  275.   ChDir(WorkDir);
  276.   if IOResult <> 0
  277.     then Error(4);
  278. {$I+}
  279. end;
  280.  
  281. {/\/\/\/\/\/\/\/\/\/\/\/\/\/}
  282. procedure Interpret2;
  283.  
  284. begin
  285.   InDir := ParamStr(1);
  286.   Switch := ParamStr(2);
  287.   if (Pos(Switch, ValidSwitches) = 0)
  288.     then Error(3);
  289. {$I-}
  290.   ChDir(InDir);
  291.   if IOResult <> 0
  292.     then Error(6);
  293.   ChDir(WorkDir);
  294.   if IOResult <> 0
  295.     then Error(4);
  296. {$I+}
  297. end;
  298.  
  299. begin
  300.   case ParamCount of
  301.     1 : Interpret1;
  302.     2 : Interpret2;
  303.     else Error(9);
  304.   end;
  305. end;
  306.  
  307.  
  308. {/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/}
  309. procedure OutPutFileChanges;
  310.  
  311. var
  312.   I : Integer;
  313.   BytesSaved : LongInt;
  314.   Dummy : Char;
  315.  
  316. {/\/\/\/\/\/\/\/\/\/\/\/\/\/}
  317. procedure ScreenBreak;
  318.  
  319. begin
  320.   write('Press any key to continue: ');
  321.   Dummy := ReadKey;
  322.   GotoXY(1,WhereY);
  323.   ClrEol;
  324. end;
  325.  
  326. {/\/\/\/\/\/\/\/\/\/\/\/\/\/}
  327. {/\/\/\/\/\/\/\/\/\/\/\/\/\/}
  328.  
  329. begin
  330.   write(#7);
  331.   Current := Head;
  332.   ClrScr;
  333.   writeln('╔══════════════╤═══════════╤═══════════╤═════════════╗');
  334.   writeln('║   File Name  │ Org. Size │ New  Size │ Bytes Saved ║');
  335.   writeln('╟──────────────┼───────────┼───────────┼─────────────╢');
  336.   I := 3;
  337.   BytesSaved := 0;
  338.   while Current <> Nil do
  339.     begin
  340.       Inc(I);
  341.       write('║ ',Current^.Name);
  342.       GotoXY(16,WhereY);
  343.       write('│ ',Current^.OrgSize);
  344.       GotoXY(28,WhereY);
  345.       write('│ ',Current^.NewSize);
  346.       GotoXY(40,WhereY);
  347.       write('│ ',Current^.OrgSize - Current^.NewSize);
  348.       BytesSaved := BytesSaved + (Current^.OrgSize - Current^.NewSize);
  349.       GotoXY(54,WhereY);
  350.       writeln('║');
  351.       if (I mod 24 = 0)
  352.         then ScreenBreak;
  353.       Current := Current^.Next;
  354.     end;
  355.     writeln('╚══════════════╧═══════════╧═══════════╧═════════════╝');
  356.     if (I > 16)
  357.       then ScreenBreak;
  358.     writeln;
  359.     writeln;
  360.     writeln('                      ╔════════╗');
  361.     writeln('                      ║ Totals ║');
  362.     writeln('       ╔══════════════╩═══╦════╩═════════════╗');
  363.     writeln('       ║ File Bytes Saved ║ Disk Space Saved ║');
  364.     writeln('       ╟──────────────────╫──────────────────╢');
  365.     write('       ║  ',BytesSaved);
  366.     GotoXY(27,WhereY);
  367.     write('║  ',(DiskFree(0) - OldDiskSpace) div 1024,'K');
  368.     GotoXY(46,WhereY);
  369.     writeln('║');
  370.     writeln('       ╚══════════════════╩══════════════════╝');
  371. end;
  372.  
  373.  
  374. {/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/}
  375. procedure ReArc;        {This will not replace the file if doing
  376.                          so will make it larger.}
  377.  
  378. var
  379.   FileRecord : SearchRec;
  380.   FileName : String;
  381.   OriginalDateTime : LongInt;
  382.   Finished : Boolean;
  383.  
  384. begin
  385.   ChDir(InDir);                   {Make sure that there are some *.ARC}
  386.   FindFirst('*.ARC',Archive,FileRecord); {files.}
  387.   If DosError <> 0
  388.     then Error(8);
  389.  
  390.   FileName := FileRecord.Name;    {Store file info}
  391.   OriginalDateTime := FileRecord.Time;
  392.   New(Head);
  393.   Current := Head;
  394.   Current^.Name := Copy(FileRecord.Name, Length(FileRecord.Name) - 13, 13);
  395.   Current^.OrgSize := FileRecord.Size;
  396.   Current^.Next := Nil;
  397.  
  398.   ClrScr;                         {UnArc file}
  399.   Exec(UnArc,FileName + ' ' + WorkDir);
  400.   if Lo(DosExitCode) <> 0
  401.     then Error(5);
  402.  
  403.   ChDir(WorkDir);                 {Arc file}
  404.   ClrScr;
  405.   Exec(Arc,'-m ' + FileName);
  406.   if Lo(DosExitCode) <> 0
  407.     then Error(5);
  408.  
  409.   Current^.NewSize := GetFileSize(FileName); {Check filesize}
  410.   if Current^.NewSize < Current^.OrgSize
  411.     then begin                    {Smaller, replace old with new file}
  412.            DeleteFile(InDir + '\' + FileName);
  413.            MoveFile(WorkDir + '\' + FileName, InDir + '\' + FileName);
  414.            SetFileDateTime(InDir + '\' + FileName, OriginalDateTime);
  415.          end
  416.     else begin                    {Larger, delete new file}
  417.            DeleteFile(WorkDir + '\' + FileName);
  418.            Current^.NewSize := Current^.OrgSize;
  419.          end;
  420.  
  421.   repeat                          {Repeat for rest of files}
  422.     Finished := False;
  423.     FindNext(FileRecord);
  424.     if DosError = 0
  425.       then begin
  426.              FileName := FileRecord.Name;
  427.              OriginalDateTime := FileRecord.Time;
  428.              Previous := Current;
  429.              New(Current);
  430.              Previous^.Next := Current;
  431.              Current^.Name := Copy(FileRecord.Name,
  432.                               Length(FileRecord.Name) - 13, 13);
  433.              Current^.OrgSize := FileRecord.Size;
  434.              Current^.Next := Nil;
  435.  
  436.              ChDir(InDir);
  437.              ClrScr;
  438.              Exec(UnArc,FileName + ' ' + WorkDir);
  439.              if Lo(DosExitCode) <> 0
  440.                then Error(5);
  441.  
  442.              ChDir(WorkDir);
  443.              ClrScr;
  444.              Exec(Arc,'-m ' + FileName);
  445.              if Lo(DosExitCode) <> 0
  446.                then Error(5);
  447.  
  448.              Current^.NewSize := GetFileSize(FileName);
  449.              if Current^.NewSize < Current^.OrgSize
  450.                then begin
  451.                       DeleteFile(InDir + '\' + FileName);
  452.                       MoveFile(WorkDir + '\' + FileName, InDir + '\' + FileName);
  453.                       SetFileDateTime(InDir + '\' + FileName, OriginalDateTime);
  454.                     end
  455.                else begin
  456.                       DeleteFile(WorkDir + '\' + FileName);
  457.                       Current^.NewSize := Current^.OrgSize;
  458.                     end;
  459.            end
  460.      else Finished := True;
  461.   until Finished;
  462. end;
  463.  
  464.  
  465. {/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/}
  466. procedure PKpakToZoo;   {This will replace the file even if it
  467.                          does make it larger.}
  468.  
  469. var
  470.   FileRecord : SearchRec;
  471.   FileName : String;
  472.   OriginalDateTime : LongInt;
  473.   Finished : Boolean;
  474.  
  475. begin
  476.   ChDir(InDir);
  477.   FindFirst('*.ARC',Archive,FileRecord);
  478.   If DosError <> 0
  479.     then Error(8);
  480.  
  481.   FileName := FileRecord.Name;
  482.   FileName[0] := chr(ord(FileName[0]) - 4);
  483.   OriginalDateTime := FileRecord.Time;
  484.   New(Head);
  485.   Current := Head;
  486.   Current^.Name := Copy(FileName, Length(FileName) - 13, 13) + '.ZOO';
  487.   Current^.OrgSize := FileRecord.Size;
  488.   Current^.Next := Nil;
  489.  
  490.   ClrScr;
  491.   Exec(UnArc,FileName + ' ' + WorkDir);
  492.   if Lo(DosExitCode) <> 0
  493.     then Error(5);
  494.  
  495.   ChDir(WorkDir);
  496.   ClrScr;
  497.   Exec(Zoo,'aM: ' + FileName + ' *');
  498.   if Lo(DosExitCode) <> 0
  499.     then Error(5);
  500.  
  501.   DeleteFile(InDir + '\' + FileName + '.ARC');
  502.   MoveFile(WorkDir + '\' + FileName + '.ZOO', InDir + '\' + FileName + '.ZOO');
  503.   SetFileDateTime(InDir + '\' + FileName + '.ZOO', OriginalDateTime);
  504.   Current^.NewSize := GetFileSize(InDir + '\' + FileName + '.ZOO');
  505.  
  506.   repeat
  507.     Finished := False;
  508.     FindNext(FileRecord);
  509.     if DosError <> 18
  510.       then begin
  511.              FileName := FileRecord.Name;
  512.              FileName[0] := chr(ord(FileName[0]) - 4);
  513.              OriginalDateTime := FileRecord.Time;
  514.              Previous := Current;
  515.              New(Current);
  516.              Previous^.Next := Current;
  517.              Current^.Name := Copy(FileName,
  518.                               Length(FileName) - 13, 13) + '.ZOO';
  519.              Current^.OrgSize:= FileRecord.Size;
  520.              Current^.Next := Nil;
  521.  
  522.              ChDir(InDir);
  523.              ClrScr;
  524.              Exec(UnArc,FileName + ' ' + WorkDir);
  525.              if Lo(DosExitCode) <> 0
  526.                then Error(5);
  527.  
  528.              ChDir(WorkDir);
  529.              ClrScr;
  530.              Exec(Zoo,'aM: ' + FileName + ' *');
  531.              if Lo(DosExitCode) <> 0
  532.                then Error(5);
  533.  
  534.              DeleteFile(InDir + '\' + FileName + '.ARC');
  535.              MoveFile(WorkDir + '\' + FileName + '.ZOO',
  536.                       InDir + '\' + FileName + '.ZOO');
  537.              SetFileDateTime(InDir + '\' + FileName + '.ZOO',
  538.                               OriginalDateTime);
  539.              Current^.NewSize := GetFileSize(InDir + '\' + FileName + '.ZOO');
  540.            end
  541.      else Finished := True;
  542.   until Finished;
  543. end;
  544.  
  545.  
  546. {/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/}
  547. procedure ZooToPKpak;
  548.  
  549. var
  550.   FileRecord : SearchRec;
  551.   FileName : String;
  552.   OriginalDateTime : LongInt;
  553.   Finished : Boolean;
  554.  
  555. begin
  556.   ChDir(InDir);
  557.   FindFirst('*.ZOO',Archive,FileRecord);
  558.   If DosError <> 0
  559.     then Error(8);
  560.  
  561.   FileName := FileRecord.Name;
  562.   FileName[0] := chr(ord(FileName[0]) - 4);
  563.   OriginalDateTime := FileRecord.Time;
  564.   New(Head);
  565.   Current := Head;
  566.   Current^.Name := Copy(FileName, Length(FileName) - 13, 13) + '.ARC';
  567.   Current^.OrgSize := FileRecord.Size;
  568.   Current^.Next := Nil;
  569.  
  570.   ClrScr;
  571.   ChDir(WorkDir);
  572.   Exec(Zoo,'x ' + InDir + '\' + FileName);
  573.   if Lo(DosExitCode) <> 0
  574.     then Error(5);
  575.  
  576.   ClrScr;
  577.   Exec(Arc,'-m ' + FileName);
  578.   if Lo(DosExitCode) <> 0
  579.     then Error(5);
  580.  
  581.   DeleteFile(InDir + '\' + FileName + '.ZOO');
  582.   MoveFile(WorkDir + '\' + FileName + '.ARC', InDir + '\' + FileName + '.ARC');
  583.   SetFileDateTime(InDir + '\' + FileName + '.ARC', OriginalDateTime);
  584.   Current^.NewSize := GetFileSize(InDir + '\' + FileName + '.ARC');
  585.  
  586.   repeat
  587.     Finished := False;
  588.     FindNext(FileRecord);
  589.     if DosError <> 18
  590.       then begin
  591.              FileName := FileRecord.Name;
  592.              FileName[0] := chr(ord(FileName[0]) - 4);
  593.              Previous := Current;
  594.              New(Current);
  595.              Previous^.Next := Current;
  596.              Current^.Name := Copy(FileName,
  597.                               Length(FileName) - 13, 13) + '.ARC';
  598.              Current^.OrgSize := FileRecord.Size;
  599.              OriginalDateTime := FileRecord.Time;
  600.              Current^.Next := Nil;
  601.  
  602.              ChDir(InDir);
  603.              ClrScr;
  604.              ChDir(WorkDir);
  605.              Exec(Zoo,'x ' + InDir + '\' + FileName);
  606.              if Lo(DosExitCode) <> 0
  607.                then Error(5);
  608.  
  609.              ClrScr;
  610.              Exec(Arc,'-m ' + FileName);
  611.              if Lo(DosExitCode) <> 0
  612.                then Error(5);
  613.  
  614.              DeleteFile(InDir + '\' + FileName + '.ZOO');
  615.              MoveFile(WorkDir + '\' + FileName + '.ARC',
  616.                       InDir + '\' + FileName + '.ARC');
  617.              SetFileDateTime(InDir + '\' + FileName + '.ARC',
  618.                               OriginalDateTime);
  619.              Current^.NewSize := GetFileSize(InDir + '\' + FileName + '.ARC');
  620.            end
  621.      else Finished := True;
  622.   until Finished;
  623. end;
  624.  
  625. {/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/}
  626. {/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/}
  627. begin
  628.   DirectVideo := False;
  629.   CheckBreak := False;
  630.   SetUp;
  631.   GetDir(0,HomeDir);
  632.   OldDiskSpace := DiskFree(0);
  633. {$I-}
  634.   MkDir(WorkDir);
  635. {$I+}
  636.   if IOResult <> 0
  637.     then Error(10);
  638.   Parse;
  639.   if Switch = '/r'
  640.     then Rearc
  641.     else if Switch = '/pz'
  642.            then PKpakToZoo
  643.            else ZooToPKpak;
  644.   ChDir(HomeDir);
  645.   RmDir(WorkDir);
  646.   ClrScr;
  647.   OutputFileChanges;
  648. end.