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
|
| 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. |
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 | |
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. >> > |
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.) " > 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. |
Free forum by Nabble | Edit this page |