compression example?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

compression example?

larrry
Hi, 

I'm trying to read the files in a given directory, add them to a ZipArchive, and write that ZipArchive out to another directory.

My code looks like this:

zip := ZipArchive new.
        zipArchive addDirectory: '/Users/data/files/arabic' as: 'arabic'.
fileName := 'Users/data/downloads/foo.zip'.
zip writeToFileNamed: fileName.

I'm getting an archive file with the correct name written out, but I can't access the contents of folder 'arabic'.  Do I have to add each of the files in 'arabic' explicitly to the zipArchive? Does anyone know of some example code for this they could point me to?

Thanks much and happy new year.

Larry 
Reply | Threaded
Open this post in threaded view
|

Re: compression example?

hernanmd
| zip fileName myInputDir |
myInputDir := #('Users' 'data' 'files' 'arabic') inject: '' into:
[:path :suffix | path,  FileDirectory slash , suffix].
zip := ZipArchive new.
zip addTree: ( FileDirectory default fullName , myInputDir ) match: [:
e | true ].
fileName := 'foo.zip'.
zip writeToFileNamed: fileName.

2012/1/2 Larry White <[hidden email]>:
>
> zip := ZipArchive new.
>         zipArchive addDirectory: '/Users/data/files/arabic' as: 'arabic'.
> fileName := 'Users/data/downloads/foo.zip'.
> zip writeToFileNamed: fileName.



--
Hernán Morales
Information Technology Manager,
Institute of Veterinary Genetics.
National Scientific and Technical Research Council (CONICET).
La Plata (1900), Buenos Aires, Argentina.
Telephone: +54 (0221) 421-1799.
Internal: 422
Fax: 425-7980 or 421-1799.

Reply | Threaded
Open this post in threaded view
|

Re: compression example?

larrry
Hi Hernán,

Thank you for your help.  Although the zips now seem to be getting created properly,  I'm running into another problem.  When I try to unzip them I get an error that says:

"Archive Utility
Unable to expand filename.zip into "Resources".  (Error 1 - Operation not permitted.) "

I'm running on OSX lion.

The error persists regardless of what directory I write the archive to.  Any ideas?

thanks,
larry 

On Thu, Jan 5, 2012 at 9:30 AM, Hernán Morales Durand <[hidden email]> wrote:
| zip fileName myInputDir |
myInputDir := #('Users' 'data' 'files' 'arabic') inject: '' into:
[:path :suffix | path,  FileDirectory slash , suffix].
zip := ZipArchive new.
zip addTree: ( FileDirectory default fullName , myInputDir ) match: [:
e | true ].
fileName := 'foo.zip'.
zip writeToFileNamed: fileName.

2012/1/2 Larry White <[hidden email]>:
>
> zip := ZipArchive new.
>         zipArchive addDirectory: '/Users/data/files/arabic' as: 'arabic'.
> fileName := 'Users/data/downloads/foo.zip'.
> zip writeToFileNamed: fileName.



--
Hernán Morales
Information Technology Manager,
Institute of Veterinary Genetics.
National Scientific and Technical Research Council (CONICET).
La Plata (1900), Buenos Aires, Argentina.
Telephone: <a href="tel:%2B54%20%280221%29%20421-1799" value="+542214211799">+54 (0221) 421-1799.
Internal: 422
Fax: 425-7980 or 421-1799.


Reply | Threaded
Open this post in threaded view
|

Re: compression example?

hernanmd
Hi Larry,

I cannot reproduce your problem, but I'm using Windows. Maybe someone
with an OSX box could try to check?

2012/1/8 Larry White <[hidden email]>:

> Hi Hernán,
>
> Thank you for your help.  Although the zips now seem to be getting created
> properly,  I'm running into another problem.  When I try to unzip them I get
> an error that says:
>
> "Archive Utility
> Unable to expand filename.zip into "Resources".  (Error 1 - Operation not
> permitted.) "
>
> I'm running on OSX lion.
>
> The error persists regardless of what directory I write the archive to.  Any
> ideas?
>
> thanks,
> larry
>
>
> On Thu, Jan 5, 2012 at 9:30 AM, Hernán Morales Durand
> <[hidden email]> wrote:
>>
>> | zip fileName myInputDir |
>> myInputDir := #('Users' 'data' 'files' 'arabic') inject: '' into:
>> [:path :suffix | path,  FileDirectory slash , suffix].
>> zip := ZipArchive new.
>> zip addTree: ( FileDirectory default fullName , myInputDir ) match: [:
>> e | true ].
>> fileName := 'foo.zip'.
>> zip writeToFileNamed: fileName.
>>
>> 2012/1/2 Larry White <[hidden email]>:
>> >
>> > zip := ZipArchive new.
>> >         zipArchive addDirectory: '/Users/data/files/arabic' as:
>> > 'arabic'.
>> > fileName := 'Users/data/downloads/foo.zip'.
>> > zip writeToFileNamed: fileName.
>>
>>
>>
>> --
>> Hernán Morales
>> Information Technology Manager,
>> Institute of Veterinary Genetics.
>> National Scientific and Technical Research Council (CONICET).
>> La Plata (1900), Buenos Aires, Argentina.
>> Telephone: +54 (0221) 421-1799.
>> Internal: 422
>> Fax: 425-7980 or 421-1799.
>>
>

Reply | Threaded
Open this post in threaded view
|

Re: compression example?

Igor Stasenko
In reply to this post by larrry
On 8 January 2012 17:34, Larry White <[hidden email]> wrote:

> Hi Hernán,
>
> Thank you for your help.  Although the zips now seem to be getting created
> properly,  I'm running into another problem.  When I try to unzip them I get
> an error that says:
>
> "Archive Utility
> Unable to expand filename.zip into "Resources".  (Error 1 - Operation not
> permitted.) "
>
could it be that your archive contains absolute paths somehow?
and then it tries to unzip it into directory with write protection (or
you don't have enough privileges to write to it).

> I'm running on OSX lion.
>
> The error persists regardless of what directory I write the archive to.  Any
> ideas?
>
> thanks,
> larry
>
>
> On Thu, Jan 5, 2012 at 9:30 AM, Hernán Morales Durand
> <[hidden email]> wrote:
>>
>> | zip fileName myInputDir |
>> myInputDir := #('Users' 'data' 'files' 'arabic') inject: '' into:
>> [:path :suffix | path,  FileDirectory slash , suffix].
>> zip := ZipArchive new.
>> zip addTree: ( FileDirectory default fullName , myInputDir ) match: [:
>> e | true ].
>> fileName := 'foo.zip'.
>> zip writeToFileNamed: fileName.
>>
>> 2012/1/2 Larry White <[hidden email]>:
>> >
>> > zip := ZipArchive new.
>> >         zipArchive addDirectory: '/Users/data/files/arabic' as:
>> > 'arabic'.
>> > fileName := 'Users/data/downloads/foo.zip'.
>> > zip writeToFileNamed: fileName.
>>
>>
>>
>> --
>> Hernán Morales
>> Information Technology Manager,
>> Institute of Veterinary Genetics.
>> National Scientific and Technical Research Council (CONICET).
>> La Plata (1900), Buenos Aires, Argentina.
>> Telephone: +54 (0221) 421-1799.
>> Internal: 422
>> Fax: 425-7980 or 421-1799.
>>
>



--
Best regards,
Igor Stasenko.