Created
February 14, 2012 10:29
-
-
Save qzchenwl/1825613 to your computer and use it in GitHub Desktop.
unzip file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# 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