|
Re: archived data [message #54333 is a reply to message #54325] |
Tue, 05 June 2007 10:15  |
Vince Hradil
Messages: 574 Registered: December 1999
|
Senior Member |
|
|
On Jun 5, 12:12 pm, hradilv <hrad...@yahoo.com> wrote:
> On Jun 3, 10:54 am, Wox <nom...@hotmail.com> wrote:
>
>> Hi All,
>
>> I face the following situation: I'd like to do some online data
>> processing (i.e. during measurements) using IDL. However the data is
>> directly zipped by the acquisition system. Is it possible to read and
>> search (like file_search) in a zip archive without spawning unzip and
>> extract everything? Windows explorer does it, so it must be
>> possible...
>
>> I remember a similar question beeing posted here, but I couldn't find
>> it.
>
>> Thanks
>
> I just threw this together. Your milage may vary:
>
> function byte_to_hex, bytes
>
> nbytes = n_elements(bytes)
>
> hstr = string(bytes, format="(z2.2)")
>
> vform = '(' + strtrim(nbytes,2) + 'A)'
> hval = string( reverse(hstr),format=vform )
> val = 0l
> reads, hval, val, format="(z)"
>
> return, val
> end
>
> function zipcontents, fname
>
> endsig = '504b0506'
>
> finfo = file_info(fname)
> fsize = finfo.size
> fdata = bytarr(fsize)
>
> openr, lun, fname, /get_lun
> readu, lun, fdata
> free_lun, lun
>
> fcode = '(' + strtrim(fsize,2) + 'z2.2)'
>
> sdata = string(fdata, format=fcode)
>
> fptr = strpos(sdata, endsig) / 2
>
> fptr += 8
> numentries = byte_to_hex( fdata[fptr:fptr+1] )
> fptr += 8
>
> cd_offset = byte_to_hex( fdata[fptr:fptr+3] )
> fptr = cd_offset
>
> contents = strarr(numentries)
>
> for i=0l, numentries-1 do begin
> fptr += 28
>
> fnamelen = byte_to_hex( fdata[fptr:fptr+1] )
> fptr += 2
>
> extrafieldlen = byte_to_hex( fdata[fptr:fptr+1] )
> fptr += 2
>
> fcommentlen = byte_to_hex( fdata[fptr:fptr+1] )
> fptr += 14
>
> contents[i] = string(fdata[fptr:fptr+fnamelen-1])
>
> fptr = fptr + fnamelen + extrafieldlen + fcommentlen
>
> endfor
>
> return, contents
> end
Sorry, I meant to include this link: http://www.pkware.com/documents/casestudies/APPNOTE.TXT
|
|
|
Re: archived data [message #54334 is a reply to message #54333] |
Tue, 05 June 2007 10:12  |
Vince Hradil
Messages: 574 Registered: December 1999
|
Senior Member |
|
|
On Jun 3, 10:54 am, Wox <nom...@hotmail.com> wrote:
> Hi All,
>
> I face the following situation: I'd like to do some online data
> processing (i.e. during measurements) using IDL. However the data is
> directly zipped by the acquisition system. Is it possible to read and
> search (like file_search) in a zip archive without spawning unzip and
> extract everything? Windows explorer does it, so it must be
> possible...
>
> I remember a similar question beeing posted here, but I couldn't find
> it.
>
> Thanks
I just threw this together. Your milage may vary:
function byte_to_hex, bytes
nbytes = n_elements(bytes)
hstr = string(bytes, format="(z2.2)")
vform = '(' + strtrim(nbytes,2) + 'A)'
hval = string( reverse(hstr),format=vform )
val = 0l
reads, hval, val, format="(z)"
return, val
end
function zipcontents, fname
endsig = '504b0506'
finfo = file_info(fname)
fsize = finfo.size
fdata = bytarr(fsize)
openr, lun, fname, /get_lun
readu, lun, fdata
free_lun, lun
fcode = '(' + strtrim(fsize,2) + 'z2.2)'
sdata = string(fdata, format=fcode)
fptr = strpos(sdata, endsig) / 2
fptr += 8
numentries = byte_to_hex( fdata[fptr:fptr+1] )
fptr += 8
cd_offset = byte_to_hex( fdata[fptr:fptr+3] )
fptr = cd_offset
contents = strarr(numentries)
for i=0l, numentries-1 do begin
fptr += 28
fnamelen = byte_to_hex( fdata[fptr:fptr+1] )
fptr += 2
extrafieldlen = byte_to_hex( fdata[fptr:fptr+1] )
fptr += 2
fcommentlen = byte_to_hex( fdata[fptr:fptr+1] )
fptr += 14
contents[i] = string(fdata[fptr:fptr+fnamelen-1])
fptr = fptr + fnamelen + extrafieldlen + fcommentlen
endfor
return, contents
end
|
|
|
Re: archived data [message #54335 is a reply to message #54334] |
Tue, 05 June 2007 08:15  |
jkj
Messages: 48 Registered: April 2007
|
Member |
|
|
On Jun 3, 10:54 am, Wox <nom...@hotmail.com> wrote:
> Hi All,
>
> I face the following situation: I'd like to do some online data
> processing (i.e. during measurements) using IDL. However the data is
> directly zipped by the acquisition system. Is it possible to read and
> search (like file_search) in a zip archive without spawning unzip and
> extract everything? Windows explorer does it, so it must be
> possible...
>
> I remember a similar question beeing posted here, but I couldn't find
> it.
>
> Thanks
IDL> spawn, 'unzip -l /usr/share/xmms/Skins/xmms-256.zip', result
IDL> print, result
Archive: /usr/share/xmms/Skins/xmms-256.zip Length Date
Time Name
-------- ---- ---- ---- 88386 07-15-99 12:23
Volume.bmp
96102 08-13-99 13:36 main.bmp 260874 08-17-99 19:56
Eqmain.bmp
14742 07-15-99 11:49 Cbuttons.bmp
3954 07-15-99 11:58 Numbers.bmp 156294 10-30-99 14:08
Pledit.bmp
92 07-18-99 11:52 PLEDIT.TXT 9294 07-15-99 13:18
Posbar.bmp
23514 07-15-99 13:26 Shufrep.bmp
89838 08-13-99 13:46 Titlebar.bmp
686 07-16-99 14:36 VISCOLOR.TXT 8478 07-18-99 10:02
Text.bmp
4278 07-15-99 13:15 Monoster.bmp
1206 07-15-99 13:24 Playpaus.bmp 49734 08-17-99 19:47
eq_ex.bmp
104 08-09-99 13:49 README -------- -------
807576 16 files
If you really don't want to unzip the archive, then whatever unzip
utility you use should allow you to query the archive, singly extract/
insert file[s] outof/into the archive. I would read up on the unzip
utility, figure out how to do what you want from a shell command line
and then use an approach like spawn.
-Kevin
|
|
|
Re: archived data [message #54336 is a reply to message #54335] |
Tue, 05 June 2007 07:13  |
Wox
Messages: 184 Registered: August 2006
|
Senior Member |
|
|
On Tue, 05 Jun 2007 13:15:50 -0000, Brian Larsen <balarsen@gmail.com>
wrote:
> I think there is no really easy solution... but I do have a medium
> difficulty idea.
>
> I use 7-zip (http://www.7-zip.org/) which has a command line interface
> 7za.exe and its free.
>
> So what I would suggest trying:
> - use idl to create a temp directory
> - spawn 7za.exe to extract the zip file into the temp directory
> - use the files from the temp directory
> - use idl to delete the temp directory
>
> I of course have not done this but it seems that it should work.
>
> Make sense?
>
> Brian
Ok, thanks. I was already expecting this would be the only way.
|
|
|
Re: archived data [message #54337 is a reply to message #54336] |
Tue, 05 June 2007 06:15  |
Brian Larsen
Messages: 270 Registered: June 2006
|
Senior Member |
|
|
I think there is no really easy solution... but I do have a medium
difficulty idea.
I use 7-zip (http://www.7-zip.org/) which has a command line interface
7za.exe and its free.
So what I would suggest trying:
- use idl to create a temp directory
- spawn 7za.exe to extract the zip file into the temp directory
- use the files from the temp directory
- use idl to delete the temp directory
I of course have not done this but it seems that it should work.
Make sense?
Brian
--
------------------------------------------------------------ ---------------------
Brian A Larsen
RBSP-ECT Instrument Suite Scientist
Boston University
Center for Space Physics
|
|
|
Re: archived data [message #54338 is a reply to message #54337] |
Tue, 05 June 2007 05:26  |
cmancone
Messages: 30 Registered: May 2007
|
Member |
|
|
On Jun 3, 11:54 am, Wox <nom...@hotmail.com> wrote:
> Hi All,
>
> I face the following situation: I'd like to do some online data
> processing (i.e. during measurements) using IDL. However the data is
> directly zipped by the acquisition system. Is it possible to read and
> search (like file_search) in a zip archive without spawning unzip and
> extract everything? Windows explorer does it, so it must be
> possible...
>
> I remember a similar question beeing posted here, but I couldn't find
> it.
>
> Thanks
I'm afraid I don't have any suggestions for you. I was just going to
add that windows almost certainly does it by quickly extracting the
files into memory as it reads the zip archive. It doesn't actually
extract the files for you, true, but it would have to unzip them in
order to display them (at least, I don't see how else it could do
it). Which of course is bad news for you - that would mean that the
only way you could accomplish what you want to accomplish is by having
IDL do the unzipping. Unless someone else has built zip/unzip
functionality into IDL, that means you'd have to do it yourself.
|
|
|