[Pkg-haskell-commits] [SCM] haskell-testpack branch, master, updated. debian/1.0.2-1-4-gb0d6b36

John Goerzen jgoerzen at complete.org
Fri Apr 23 14:49:42 UTC 2010


The following commit has been merged in the master branch:
commit 9be6fa96afac738c1bf24e4d11572122ae127fda
Author: John Goerzen <jgoerzen at complete.org>
Date:   Sat Dec 4 06:07:55 2004 +0100

    Checkpointing
    
    Keywords:
    
    
    (jgoerzen at complete.org--projects/missingh--head--0.7--patch-25)

diff --git a/ChangeLog b/ChangeLog
index de1576e..c342121 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,18 @@
 # arch-tag: automatic-ChangeLog--jgoerzen at complete.org--projects/missingh--head--0.7
 #
 
+2004-12-03 23:07:55 GMT	John Goerzen <jgoerzen at complete.org>	patch-25
+
+    Summary:
+      Checkpointing
+    Revision:
+      missingh--head--0.7--patch-25
+
+
+    modified files:
+     ChangeLog libsrc/MissingH/FileArchive/GZip.hs
+
+
 2004-12-03 22:53:40 GMT	John Goerzen <jgoerzen at complete.org>	patch-24
 
     Summary:
diff --git a/libsrc/MissingH/FileArchive/GZip.hs b/libsrc/MissingH/FileArchive/GZip.hs
index 3d4cbc3..894c9e1 100644
--- a/libsrc/MissingH/FileArchive/GZip.hs
+++ b/libsrc/MissingH/FileArchive/GZip.hs
@@ -30,6 +30,7 @@ import Data.Bits
 import Control.Monad.Error
 import Data.Char
 import Data.Word
+import MissingH.Bits
 
 type GZipError = String
 
@@ -58,10 +59,42 @@ split1 s = (head s, tail s)
 -}
 
 decompress :: String -> Either GZipError String
+{-
 decompress s = 
     do x <- read_header s
        let rem = snd x
        return $ inflate_string rem
+-}
+decompress s = do x <- read_sections s
+                  return $ concatMap snd x
+
+-- | Read all sections.  Returns (Header, ThisSection)
+read_sections :: String -> Either GZipError [(Header, String)]
+read_sections [] = Right []
+read_sections s = do x <- read_section s
+                     case x of
+                            (head, this, remain) -> do 
+                                                    next <- read_sections remain
+                                                    return $ (head, this) : next
+
+-- | Read one section, returning (Header, ThisSection, Remainder)
+read_section :: String -> Either GZipError (Header, String, String)
+read_section s =
+        do x <- read_header s
+           let headerrem = snd x
+           let (decompressed, crc32, remainder) = read_data headerrem
+           let (crc32str, rem) = splitAt 4 remainder
+           let (sizestr, rem2) = splitAt 4 rem
+           let filecrc32 = fromBytes $
+                           map (fromIntegral . ord) crc32str
+           
+           if filecrc32 == crc32 
+              then return $ (fst x, decompressed, rem2)
+              else throwError $ "CRC MISMATCH; calculated: " ++
+                                (show crc32)
+                                ++ ", recorded: " ++ (show filecrc32)
+           
+    
 
 -- | Read the file's compressed data, returning
 -- (Decompressed, CRC32, Remainder)

-- 
haskell-testpack



More information about the Pkg-haskell-commits mailing list