commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ken Tanaka <Ken.Tan...@noaa.gov>
Subject Re: VFS how to read gzipped content from tar file
Date Wed, 07 Nov 2007 18:36:50 GMT
Actually the tarfile is not compressed, files inside the tar file are 
gzipped files, for example

tar tvf archive.tar
drwxrwsr-x ktanaka/ktanaka   0 2007-10-30 12:45:26 tardir/
-rw-rw-r-- ktanaka/ktanaka  56 2007-10-30 12:44:37 tardir/content.txt.gz

I'd like to directly create a content.txt file from the above archive.tar

Thanks for the posting though, you gave me an idea to try that led to a 
solution:

    
gz:tar:file:///extra/data/tryVfs/archive.tar!/tardir/content.txt.gz!content.txt

It was unclear to me from the Javadoc how to build up this name 
parameter for
FileSystemManager.resolveFile(name). Although I see after the fact that 
if I had studied
http://commons.apache.org/vfs/filesystems.html
the "Zip, Jar and Tar" section has a 5th example
"|tar:gz:http://anyhost/dir/mytar.tar.gz!/mytar.tar!/path/in/tar/README.txt|"
 From this maybe I could have deduced that multiple paths can be chained 
together
with a "!" as a separator, while file system designators ("file:", "tar:"
and "gz:") should be prepended onto the front in reverse order.

I'll update the example I started in the VFS wiki to reflect the much 
simpler name

http://wiki.apache.org/jakarta-commons/ExtractAndDecompressGzipFiles

-Ken


Mark Fortner wrote:
> You mentioned that you wanted to look into a tarball (gzipped tar 
> file), but
> the URL you gave was only for a tar file. Something like this should work:
>
> gz:tar:file:///extra/data/tryVfs/archive.tar.gz!/myfile.txt
>
> Hope this helps,
>
> Mark
>
> On 10/31/07, Ken Tanaka < Ken.Tanaka@noaa.gov> wrote:
>> Thanks for the suggestion, but I'm getting a different error when I try
>> that:
>> org.apache.commons.vfs.FileSystemException: Could not resolve file
>> "gz:tar:file:///extra/data/tryVfs/archive.tar!/!/".
...
>>
>>
>>
>> Here is the exact code corresponding to the above error:
>> FileObject contentFile = fsManager.resolveFile(
>>
>> "gz:tar:///extra/data/tryVfs/archive.tar!/tardir/content.txt.gz"
>> );
>>
>> Philippe Poulard wrote:
>>> Hi Ken,
>>>
>>> Ken Tanaka a écrit :
>>>> FileObject gzTarFile =
>>>> fsManager.resolveFile("tar:gz:/archive.tar!/tardir/content.txt.gz");
>>> try this :
>>>
>>> fsManager.resolveFile("gz:tar:/archive.tar!/tardir/content.txt.gz");
>>>
>> --
>> = Enterprise Data Services Division ===============
>> | CIRES, National Geophysical Data Center / NOAA |
>> | 303-497-6221 |
>> = Ken.Tanaka@noaa.gov =============================
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> For additional commands, e-mail: user-help@commons.apache.org
>>
>>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message