Commit 7874e6e0 authored by Armin Bernstetter's avatar Armin Bernstetter
Browse files

improve imports and readability

parent 7b91593d
......@@ -2,17 +2,17 @@
module Resources
( extractResources
, getResourceString
, getOldResources
, deckerResourceDir
, writeExampleProject
, copyDir
, getOldResources
) where
import Common
import Control.Exception
import Control.Monad
import Control.Monad.Extra
import Data.List.Split as Split
import Data.List.Split (splitOn)
import Exception
import System.Directory
import System.Environment
......@@ -28,19 +28,21 @@ deckerResourceDir =
("decker" ++
"-" ++ deckerVersion ++ "-" ++ deckerGitBranch ++ "-" ++ deckerGitCommitId)
-- | Get the absolute paths of resource folders
-- with version numbers older than the current one
getOldResources :: IO [FilePath]
getOldResources = do
dir <- getXdgDirectory XdgData []
files <- listDirectory dir
return $ map (dir </>) $ filter oldVersion files
where
deckerRegex = "decker-([0-9]+)[.]([0-9]+)[.]([0-9]+)-" :: String
convert = map (read :: String -> Int)
current = convert (splitOn "." deckerVersion)
currentVersion = convert (splitOn "." deckerVersion)
deckerRegex = "decker-([0-9]+)[.]([0-9]+)[.]([0-9]+)-" :: String
oldVersion name =
case getAllTextSubmatches (name =~ deckerRegex) :: [String] of
[] -> False
_:x:y:z:vs -> convert [x, y, z] < current
_:x:y:z:_ -> convert [x, y, z] < currentVersion
getResourceString :: FilePath -> IO String
getResourceString path = do
......
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