module Java.JAR
(readManifest,
readJAR,
+ readMainClass,
addJAR
) where
files <- Zip.fileNames []
return $ mapF (NotLoadedJAR jarfile) (buildTree $ filter good files)
where
- good name = str `isPrefixOf` name
+ good name = (str `isPrefixOf` name) && (".class" `isSuffixOf` name)
+
+-- | Read MainClass Entry of a MANIFEST.MF file
+readMainClass :: FilePath -> IO (Maybe String)
+readMainClass jarfile = do
+ Zip.withArchive [] jarfile $ do
+ m <- readManifest
+ case m of
+ Nothing -> return Nothing
+ Just mf -> return $ mainClass mf
-- | Read entries from JAR file, using MANIFEST.MF if it exists.
readJAR :: FilePath -> IO [Tree CPEntry]
return (Just forest)
case r of
Nothing -> readAllJAR jarfile
+ Just [] -> readAllJAR jarfile
Just f -> return f
-- | Add given JAR file to ClassPath