home *** CD-ROM | disk | FTP | other *** search
- { DEMO_2.PAS Copyright (c) 1995-96 by Piotr Warezak and Rafal Wierzbicki
-
- This program demonstrates how to use WWP_DATA unit.
-
- DEMO_2.PAS lets you unpack WWPACKed data files without using WWPACK
- compressor.
-
- Usage: DEMO_2.EXE FileName
- where FileName is the name of a file you want to unpack.
-
- =======================================================================
-
- This program is public domain and may be freely distributed.
-
- ======================================================================= }
-
- program demo2;
- uses wwp_data; {use WWP_DATA unit}
- var f1:file;
- f2:file_ww;
- buf:array [1..30000] of byte;
- counter:longint;
- read:word;
-
- begin
- if paramstr(1)='' then {source filename is required!}
- begin
- writeln('Filename required!');halt;
- end;
- counter:=0;
-
- assign(f1,'UNPACKED.FIL');rewrite(f1,1); {create destination (unpacked) file}
- assign_ww(f2,paramstr(1));reset_ww(f2); {open compressed data file}
- if ioresult_ww=250 then {is that WWPACK data file?}
- begin
- writeln('Not WWPACKed data file!');
- erase(f1);halt;
- end;
- if ioresult_ww=251 then {is that future version of WWPACK data file?}
- begin
- writeln('Unrecognized version WWPACK data file!');
- erase(f1);halt;
- end;
-
- repeat
- blockread_ww(f2,buf,sizeof(buf),read); {read source file and decompress}
- blockwrite(f1,buf,read); {save decompressed data}
- inc(counter,read);
- writeln('Decompressed: ',counter,' bytes.');
- until read<sizeof(buf);
-
- close(f1); {close all files}
- close_ww(f2);
- end.