Commit c5e8640e authored by Jan-Philipp Stauffert's avatar Jan-Philipp Stauffert
Browse files

Replace call to unzip for resource extraction

parent 1e6cfa08
{-# LANGUAGE CPP #-}
import Codec.Archive.Zip
import Conduit
import Control.Monad.Extra
......@@ -24,7 +26,7 @@ appendResourceArchive ::
Args -> CopyFlags -> PackageDescription -> LocalBuildInfo -> IO ()
appendResourceArchive args flags descr info = do
let binDir = fromPathTemplate $ bindir $ installDirTemplates info
executable <- makeAbsolute $ binDir </> "decker"
executable <- makeAbsolute $ binDir </> executableName
withCurrentDirectory resourceDir $ do
files <-
glob "**/*" >>= filterM doesFileExist >>=
......@@ -103,3 +105,10 @@ fixZip zipPath adjustmentSize = do
return ()
else do
return ()
executableName :: String
#ifdef mingw32_HOST_OS
executableName = "decker.exe"
#else
executableName = "decker"
#endif
\ No newline at end of file
......@@ -8,11 +8,13 @@ module Resources
, copyDir
) where
import Codec.Archive.Zip
import Common
import Control.Exception
import Control.Monad
import Control.Monad.Extra
import Data.List.Split (splitOn)
import Data.Map.Strict (size)
import Exception
import System.Directory
import System.Environment
......@@ -56,12 +58,11 @@ extractResources = do
dataDir <- deckerResourceDir
exists <- doesDirectoryExist dataDir
unless exists $ do
unlessM (Resources.unzip ["-l", deckerExecutable]) $
numFiles <- withArchive deckerExecutable getEntries
unless ((size numFiles) > 0) $
throw $ ResourceException "No resource zip found in decker executable."
createDirectoryIfMissing True dataDir
unlessM (Resources.unzip ["-qq", "-o", "-d", dataDir, deckerExecutable]) $
throw $
ResourceException "Unable to extract resources from decker executable"
withArchive deckerExecutable (unpackInto dataDir)
putStrLn $ "# resources extracted to " ++ dataDir
unzip :: [String] -> IO Bool
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment