{"id":135,"date":"2009-12-06T02:36:52","date_gmt":"2009-12-06T07:36:52","guid":{"rendered":"http:\/\/ebixio.com\/blog\/?p=135"},"modified":"2009-12-06T02:36:52","modified_gmt":"2009-12-06T07:36:52","slug":"uncompressing-unix-z-files","status":"publish","type":"post","link":"http:\/\/ebixio.com\/blog\/2009\/12\/06\/uncompressing-unix-z-files\/","title":{"rendered":"Uncompressing UNIX *.Z files"},"content":{"rendered":"<p>I searched online for a .NET library that can be used to decompress *.Z files (compressed by the UNIX compress utility) but was unable to find anything non-commercial. I found however some code in Java that looked promising, so I ported it to C#. I integrated the resulting code with the <a href=\"http:\/\/www.icsharpcode.net\/OpenSource\/SharpZipLib\/\">SharpZipLib<\/a> library, but until that gets officially integrated and released, I decided to release a stand-alone version here.<\/p>\n<p>The code is contained in a single file (download <a href='http:\/\/ebixio.com\/blog\/wp-content\/uploads\/2009\/12\/LzwInputStream.cs'>LzwInputStream.cs<\/a>) and is pretty straight-forward to use. The following example shows how to uncompress a *.Z file using c-sharp.<\/p>\n\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\nusing System;\nusing System.IO;\n\nusing Ebixio.LZW;\n\nclass MainClass\n{\n    public static void Main(string&#x5B;] args)\n    {\n        byte&#x5B;] buffer = new byte&#x5B;4096];\n        string outFile = Path.GetFileNameWithoutExtension(args&#x5B;0]);\n\n        using (Stream inStream = new LzwInputStream(File.OpenRead(args&#x5B;0])))\n        using (FileStream outStream = File.Create(outFile)) {\n            int read;\n            while ((read = inStream.Read(buffer, 0, buffer.Length)) &gt; 0) {\n                outStream.Write(buffer, 0, read);\n            }\n        }\n    }\n}\n<\/pre>","protected":false},"excerpt":{"rendered":"<p>I searched online for a .NET library that can be used to decompress *.Z files (compressed by the UNIX compress utility) but was unable to find anything non-commercial. I found however some code in Java that looked promising, so I ported it to C#. I integrated the resulting code with the SharpZipLib library, but until [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[1],"tags":[23,10,25,24],"class_list":["post-135","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-compress","tag-csharp","tag-uncompress","tag-unix"],"_links":{"self":[{"href":"http:\/\/ebixio.com\/blog\/wp-json\/wp\/v2\/posts\/135","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/ebixio.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/ebixio.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/ebixio.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/ebixio.com\/blog\/wp-json\/wp\/v2\/comments?post=135"}],"version-history":[{"count":0,"href":"http:\/\/ebixio.com\/blog\/wp-json\/wp\/v2\/posts\/135\/revisions"}],"wp:attachment":[{"href":"http:\/\/ebixio.com\/blog\/wp-json\/wp\/v2\/media?parent=135"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/ebixio.com\/blog\/wp-json\/wp\/v2\/categories?post=135"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/ebixio.com\/blog\/wp-json\/wp\/v2\/tags?post=135"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}