home *** CD-ROM | disk | FTP | other *** search
/ Computer Installation Guide - Dragon Clan Series / CD2.iso / ZIP / WWPACK / WWP304 / PASCAL / DEMO_2.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-01-05  |  1.9 KB  |  54 lines

  1. {  DEMO_2.PAS  Copyright (c) 1995-96 by Piotr Warezak and Rafal Wierzbicki
  2.  
  3.    This program demonstrates how to use WWP_DATA unit.
  4.  
  5.    DEMO_2.PAS lets you unpack WWPACKed data files without using WWPACK
  6.    compressor.
  7.  
  8.    Usage: DEMO_2.EXE FileName
  9.      where FileName is the name of a file you want to unpack.
  10.  
  11.    =======================================================================
  12.  
  13.    This program is public domain and may be freely distributed.
  14.  
  15.    =======================================================================   }
  16.  
  17. program demo2;
  18. uses wwp_data;                                                  {use WWP_DATA unit}
  19. var f1:file;
  20.     f2:file_ww;
  21.     buf:array [1..30000] of byte;
  22.     counter:longint;
  23.     read:word;
  24.  
  25. begin
  26.   if paramstr(1)='' then                                        {source filename is required!}
  27.   begin
  28.     writeln('Filename required!');halt;
  29.   end;
  30.   counter:=0;
  31.  
  32.   assign(f1,'UNPACKED.FIL');rewrite(f1,1);                      {create destination (unpacked) file}
  33.   assign_ww(f2,paramstr(1));reset_ww(f2);                       {open compressed data file}
  34.   if ioresult_ww=250 then                                       {is that WWPACK data file?}
  35.   begin
  36.     writeln('Not WWPACKed data file!');
  37.     erase(f1);halt;
  38.   end;
  39.   if ioresult_ww=251 then                                       {is that future version of WWPACK data file?}
  40.   begin
  41.     writeln('Unrecognized version WWPACK data file!');
  42.     erase(f1);halt;
  43.   end;
  44.  
  45.   repeat
  46.     blockread_ww(f2,buf,sizeof(buf),read);                      {read source file and decompress}
  47.     blockwrite(f1,buf,read);                                    {save decompressed data}
  48.     inc(counter,read);
  49.     writeln('Decompressed: ',counter,' bytes.');
  50.   until read<sizeof(buf);
  51.  
  52.   close(f1);                                                    {close all files}
  53.   close_ww(f2);
  54. end.