RE: Haskell threads & pipes & UNIX processes
| So what's going on? How can the goal be achieved? I don't know, but here's a different suggestion, using bzip2 (you could do the same with zlib for .gz files): use the foreign import mechanism to make BZ2_bzopen, BZ2_bzwrite and BZ2_bzclose available in your program. Then: do bz2 <- bzopen "output.bz2" "w" let chars_to_write = ... :: String bzwrite bz2 (packString chars_to_write) (length chars_to_write) -- the above as many times as you like bzclose bz2 and link your program with libbz2.a or libbz2.so. Almost the same trick works with the zlib library for directly reading/writing .gz files. This strikes me as far more convenient than messing round with pipes, etc. J
Thu, 15 Feb 2001 08:50:41 -0800, Julian Seward (Intl Vendor) <v-julsew@microsoft.com> pisze:
use the foreign import mechanism to make BZ2_bzopen, BZ2_bzwrite and BZ2_bzclose available in your program.
bzlib and zlib wrappers are available in <http://www.sourceforge.net/projects/qforeign/> (for ghc >= 4.08 and nhc98 >= 1.02). zlib can write and read true .gz headers only when working with files (FILE * in C). The in-memory interface provides raw compressed contents only. I haven't made wrappers for these FILE * functions for real .gz files, so these wrappers cannot be used yet to read and write true .gz files. bzlib does not have this problem: its in-memory compressed data is identical to .bz2 file contents. Both wrappres include functions for lazy compression and decompression of strings (String -> String). -- __("< Marcin Kowalczyk * qrczak@knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZASTÊPCZA QRCZAK
Hello Marcin,
Thu, 15 Feb 2001 08:50:41 -0800, Julian Seward (Intl Vendor) <v-julsew@microsoft.com> pisze:
use the foreign import mechanism to make BZ2_bzopen, BZ2_bzwrite and BZ2_bzclose available in your program.
bzlib and zlib wrappers are available in <http://www.sourceforge.net/projects/qforeign/> (for ghc >= 4.08 and nhc98 >= 1.02).
bzlib does not have this problem: its in-memory compressed data is identical to .bz2 file contents.
Both wrappres include functions for lazy compression and decompression of strings (String -> String).
The wrapper works fine, except for - when bunzipping a file - bunzip complains like this: bunzip: wbg-5-11-0.xml.bz2: trailing garbage after EOF ignored Indeed, the file produced by the Haskell program is one byte longer than the file produced by bzip (called from the command line). Michael
Fri, 16 Feb 2001 12:16:51 +0100 (CET), Michael Marte <marte@pms.informatik.uni-muenchen.de> pisze:
Indeed, the file produced by the Haskell program is one byte longer than the file produced by bzip (called from the command line).
Sorry, it works for me (bzip2-1.0.1, ghc fresh from CVS). -- __("< Marcin Kowalczyk * qrczak@knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZASTÊPCZA QRCZAK
participants (3)
-
Julian Seward (Intl Vendor) -
Michael Marte -
qrczak@knm.org.pl