1module Util.System(tempfile,withTempdir,rmFile,catchIO) where
3-- System helper functions.
4import Control.Monad (when)
5import System.Directory (getTemporaryDirectory
7 , removeDirectoryRecursive
8 , createDirectoryIfMissing
10import System.FilePath ((</>), normalise)
13import Control.Exception as CE
15catchIO :: IO a -> (IOError -> IO a) -> IO a
18throwIO :: IOError -> IO a
21tempfile :: IO (FilePath, Handle)
22tempfile = do dir <- getTemporaryDirectory
23 openTempFile (normalise dir) "idris"
25withTempdir :: String -> (FilePath -> IO a) -> IO a
26withTempdir subdir callback
27 = do dir <- getTemporaryDirectory
28 let tmpDir = (normalise dir) </> subdir
29 removeLater <- catchIO (createDirectoryIfMissing True tmpDir >> return True)
30 (\ ioError -> if isAlreadyExistsError ioError then return False
33 result <- callback tmpDir
34 when removeLater $ removeDirectoryRecursive tmpDir
37rmFile :: FilePath -> IO ()
38rmFile f = do putStrLn $ "Removing " ++ f
39 catchIO (removeFile f)
40 (\ioerr -> putStrLn $ "WARNING: Cannot remove file "
41 ++ f ++ ", Error msg:" ++ show ioerr)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list