+checkClassTree :: [Tree CPEntry] -> IO [Tree (FilePath, Class Direct)]
+checkClassTree forest = mapFMF check forest
+ where
+ check _ (NotLoaded path) = do
+ cls <- parseClassFile path
+ return (path, cls)
+ check a (Loaded path cls) = return (a </> path, cls)
+ check a (NotLoadedJAR jar path) = do
+ cls <- readFromJAR jar (a </> path)
+ return (a </> path, cls)
+ check a (LoadedJAR _ cls) =
+ return (a </> show (thisClass cls), cls)
+
+zipJAR :: [Tree (FilePath, Class Direct)] -> Zip.Archive ()
+zipJAR forest = do
+ mapFM go forest
+ return ()
+ where
+ go (path, cls) = Zip.addFile path =<< Zip.sourceBuffer (B.unpack $ encodeClass cls)
+