module Text.LaTeX.Guide.Update (
updateGuide
) where
import System.Directory (
getCurrentDirectory
, setCurrentDirectory
, createDirectoryIfMissing
, getAppUserDataDirectory
, copyFile
)
import System.FilePath ((</>),(<.>))
import Text.LaTeX.Guide.Info (sectionList,otherResources)
updateGuide :: FilePath -> IO ()
updateGuide fp = do
d0 <- getCurrentDirectory
setCurrentDirectory fp
appd <- getAppUserDataDirectory "hatex-guide"
putStrLn "Updating 'src'..."
createDirectoryIfMissing True $ appd </> "src"
mapM_ (\s -> let d = "src" </> s <.> "htxg"
in copyFile d $ appd </> d) sectionList
putStrLn "Updating 'res'..."
createDirectoryIfMissing True $ appd </> "res"
mapM_ (\r -> let d = "res" </> r
in copyFile d $ appd </> d) otherResources
setCurrentDirectory d0