George Gwilt wrote:
> I am constantly doing looking at the contents of zipped files. What 
> I do is:
>
>    EX unzip;'-l >ram1_file flp1_zipped.zip'
>
> so that the contents go to "ram1_file" from the (probably) MSDOS 
> floppy
> containing "zipped.zip".
>
> But perhaps you don't want that. The unzipping of contents ends with 
> the
> message:
>
>     "Press a key"
>
> and you may not want that.
That's right. I think it boils down to how Unzip interprets what you 
do with the EW Unzip (it has to be EW for Unzip to finish writing 
before BASIC closes the file/channel unzip writes to).

Generally EW Unzip,#channel1,#channel2;'parameters'  treats Unzip like 
a filter and primary input is #channel 1 and primary output is to 
#channel 2.

If you run a program like this:

OPEN_NEW #3,ram1_filename
EW UNZIP,#3,#3;'-lqq ram1_example_zip'
CLOSE #3
VIEW ram1_filename

It seems to work - obviously in place of VIEW ram1_filename you could 
reset the file pointer to 0 and read the filenames back one line at a 
time to read the filenames into your own array or custom print them:

OPEN_NEW #3,ram1_filename
EW UNZIP,#3,#3;'-lqq ram1_example_zip'
BGET #3\0
REPeat loop
IF EOF(#3) THEN EXIT loop
INPUT #3,t$ : PRINT t$
END REPeat loop
CLOSE #3
DELETE ram1_filename

What I'm not sure about is how Unzip treats the 2 channel number 
parameters supplied by the EW command. Both seem to need to be the 
output channel to which the list of files is written, but it can't be 
that simple surely...there must be some significance to both channel 
numbers?

The -lqq just means write normal short format zip files list, and qq 
is 'quieter mode'

You can use the ZipInfo formats too in order to get just files lists 
without the file size and other data, to make life simpler:

EW UNZIP,#3,#3;'-Z -1 ram1_example_zip'

Using -Z -1 gives a simple list of filenames only (no comments etc) 
like this:
filename1.bas
filename2.txt
filename3

and so on, whereas using -Z -2 allows headers, trailers and zipfile 
comments, so may include extra details.

Using -l or -lqq gives a list like this:

Archive:  ram1_example_zip
 Length    Date    Time    Name
 ------    ----    ----    ----
   1659  03-08-03  15:43   listkeywordsinrext.bas
   5208  03-08-03  16:30   listkeyw.txt
 ------                    -------
   6867                    2 files

And if you don't want to use a temporary filename to hold the output, 
it can be written to use pipes as in my original example, as long as 
the pipe is large enough to hold the list of files (or the program may 
lock up), and your system has the facility to open the other end of a 
pipe for input, e.g. commands like Q_PIPE in QLiberator or CONNECT in 
Turbo Toolkit:

OPEN_NEW #4,'pipe_10240'
Q_PIPE #4 TO #3
EW UNZIP,#4,#4;'-Z -1 ram1_example_zip'
CLOSE #4 : REMark force pipe EOF, but program will lock before the 
CLOSE statement if pipe not large enough
REPeat loop
IF EOF(#3) THEN EXIT loop
INPUT #3,t$ : PRINT t$
END REPeat loop
CLOSE #3

Within the loop you can read the data into an array for example, 
depending on what your program needs to do with the list.

This all seems to work, but I'm not sure I fully understand exactly 
how!

-- 
Dilwyn Jones




-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.362 / Virus Database: 267.13.4/176 - Release Date: 20/11/2005

_______________________________________________
QL-Users Mailing List
http://www.q-v-d.demon.co.uk/smsqe.htm

Reply via email to