{"id":67,"date":"2007-10-08T13:08:25","date_gmt":"2007-10-08T20:08:25","guid":{"rendered":"http:\/\/wahlers.com.br\/claus\/blog\/fzip-alpha-release-create-and-modify-zip-archives\/"},"modified":"2008-11-26T03:31:48","modified_gmt":"2008-11-26T10:31:48","slug":"fzip-alpha-release-create-and-modify-zip-archives","status":"publish","type":"post","link":"http:\/\/wahlers.com.br\/claus\/blog\/fzip-alpha-release-create-and-modify-zip-archives\/","title":{"rendered":"FZip Alpha Release: Create And Modify ZIP Archives"},"content":{"rendered":"<p>FZip has been around for some time now, and people seem to like it. However one feature has been asked for repeatedly: In addition to reading ZIP archive, people want to be able to create new (and modify existing) archives.<\/p>\n<p>So i finally sat down this weekend and added that.<\/p>\n<p>The code is not tested very well (it works for me but may not work for you)  and has no ASDocs yet, so i release it as an alpha version, with the hope of massive bug feedback.. :)<\/p>\n<p>Download: <a href=\"http:\/\/codeazur.com.br\/lab\/fzip\/download\/fzip_1_0_52_alpha.zip\" style=\"text-decoration: line-through\" title=\"FZip 1.0.52 Alpha\">fzip_1_0_52_alpha.zip<\/a> <a href=\"http:\/\/codeazur.com.br\/lab\/fzip\/download\/fzip.zip\" title=\"FZip\">fzip.zip<\/a><\/p>\n<p>New methods in class FZip:<\/p>\n<ul>\n<li>addFile(name:String, date:Date, content:ByteArray)<\/li>\n<li>addFileAt(index:uint, name:String, date:Date, content:ByteArray)<\/li>\n<li>removeFileAt(index:uint)<\/li>\n<li>serialize(stream:IDataOutput)<\/li>\n<\/ul>\n<p>Sample code:<\/p>\n<pre style=\"margin-left: 20px\"><code><span style=\"color: #808080; font-style: italic\">\/\/ Create file contents<\/span>\r\n<span style=\"color: #000000; font-weight: bold\">var<\/span> ba:ByteArray = <span style=\"color: #000000; font-weight: bold\">new<\/span> ByteArray<span style=\"color: #66cc66\">(<\/span><span style=\"color: #66cc66\">)<\/span>;\r\nba.<span style=\"color: #006600\">writeUTFBytes<\/span><span style=\"color: #66cc66\">(<\/span><span style=\"color: #ff0000\">\"Hello World!\"<\/span><span style=\"color: #66cc66\">)<\/span>;\r\n<span style=\"color: #808080; font-style: italic\">\/\/ Create ZIP archive and add file<\/span>\r\n<span style=\"color: #000000; font-weight: bold\">var<\/span> zip:FZip = <span style=\"color: #000000; font-weight: bold\">new<\/span> FZip<span style=\"color: #66cc66\">(<\/span><span style=\"color: #66cc66\">)<\/span>;\r\nzip.<span style=\"color: #006600\">addFile<\/span><span style=\"color: #66cc66\">(<\/span><span style=\"color: #ff0000\">\"hello.txt\"<\/span>, <span style=\"color: #000000; font-weight: bold\">null<\/span>, ba<span style=\"color: #66cc66\">)<\/span>;\r\n<span style=\"color: #808080; font-style: italic\">\/\/ Serialize ZIP into a new file<\/span>\r\n<span style=\"color: #808080; font-style: italic\">\/\/ (we use the Adobe AIR specific class FileStream here,<\/span>\r\n<span style=\"color: #808080; font-style: italic\">\/\/ but you can as well use ByteArray <\/span><\/code><code><span style=\"color: #808080; font-style: italic\">or anything that<\/span><\/code><code><span style=\"color: #808080; font-style: italic\"><\/span>\r\n<span style=\"color: #808080; font-style: italic\">\/\/ implements IDataOutput)<\/span>\r\n<span style=\"color: #000000; font-weight: bold\">var<\/span> file:File = File.<span style=\"color: #006600\">applicationStorageDirectory<\/span>;\r\nfile = file.<span style=\"color: #006600\">resolvePath<\/span><span style=\"color: #66cc66\">(<\/span><span style=\"color: #ff0000\">\"hello.zip\"<\/span><span style=\"color: #66cc66\">)<\/span>;\r\n<span style=\"color: #000000; font-weight: bold\">var<\/span> stream:FileStream = <span style=\"color: #000000; font-weight: bold\">new<\/span> FileStream<span style=\"color: #66cc66\">(<\/span><span style=\"color: #66cc66\">)<\/span>;\r\nstream.<span style=\"color: #006600\">open<\/span><span style=\"color: #66cc66\">(<\/span>file, FileMode.<span style=\"color: #006600\">WRITE<\/span><span style=\"color: #66cc66\">)<\/span>;\r\nzip.<span style=\"color: #006600\">serialize<\/span><span style=\"color: #66cc66\">(<\/span>stream<span style=\"color: #66cc66\">)<\/span>;\r\nstream.<span style=\"color: #0066cc\">close<\/span><span style=\"color: #66cc66\">(<\/span><span style=\"color: #66cc66\">)<\/span>;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>FZip has been around for some time now, and people seem to like it. However one feature has been asked for repeatedly: In addition to reading ZIP archive, people want to be able to create new (and modify existing) archives. &hellip; <a href=\"http:\/\/wahlers.com.br\/claus\/blog\/fzip-alpha-release-create-and-modify-zip-archives\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,8,4,9,3],"tags":[],"class_list":["post-67","post","type-post","status-publish","format-standard","hentry","category-air","category-as3","category-flash","category-flex-2","category-webdev"],"_links":{"self":[{"href":"http:\/\/wahlers.com.br\/claus\/blog\/wp-json\/wp\/v2\/posts\/67","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/wahlers.com.br\/claus\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/wahlers.com.br\/claus\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/wahlers.com.br\/claus\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/wahlers.com.br\/claus\/blog\/wp-json\/wp\/v2\/comments?post=67"}],"version-history":[{"count":4,"href":"http:\/\/wahlers.com.br\/claus\/blog\/wp-json\/wp\/v2\/posts\/67\/revisions"}],"predecessor-version":[{"id":84,"href":"http:\/\/wahlers.com.br\/claus\/blog\/wp-json\/wp\/v2\/posts\/67\/revisions\/84"}],"wp:attachment":[{"href":"http:\/\/wahlers.com.br\/claus\/blog\/wp-json\/wp\/v2\/media?parent=67"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/wahlers.com.br\/claus\/blog\/wp-json\/wp\/v2\/categories?post=67"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/wahlers.com.br\/claus\/blog\/wp-json\/wp\/v2\/tags?post=67"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}