Skip to content

Instantly share code, notes, and snippets.

@qzchenwl
Created February 14, 2012 10:29
Show Gist options
  • Save qzchenwl/1825613 to your computer and use it in GitHub Desktop.
Save qzchenwl/1825613 to your computer and use it in GitHub Desktop.
unzip file
{-# LANGUAGE OverloadedStrings #-}
import Codec.Archive.Zip
import Data.ByteString.Lazy (getContents, putStrLn)
import Data.ByteString.Lazy.Char8 (ByteString)
import Prelude hiding (getContents, putStrLn)
import Data.Maybe (maybe)
import System.Environment (getArgs)
import System.Exit (exitFailure)
main = do filePath <- getArgs >>= parse
zipFile <- getContents
let zipFileArchive = toArchive zipFile
let file = maybe "" fromEntry (findEntryByPath filePath zipFileArchive)
putStrLn file
parse [] = die
parse (x:_) = return x
die = exitFailure
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment