List of zip archives using zip-conduit

Using a library zip-conduit

, I want to list the entries in a ZIP archive. I want to print them just the filename per line - similar to unzip -l

but without additional information.

Note: This question was answered using Q&A style and therefore does not show any research on purpose!

+3


source to share


1 answer


You can use the function entryNames

. By modifying the ZIP extraction example , we can print the names instead of extracting.

The following program example takes a ZIP file name from the first command line parameter and uses it mapM_ putStrLn

to print:



import Codec.Archive.Zip (withArchive, entryNames)
import System.Environment (getArgs)

main = do
    -- ZIP file name: First commandline arg
    zipPath:_ <- getArgs
    names <- withArchive zipPath $ entryNames
    mapM_ putStrLn names

      

+2


source







All Articles