1module Util.System(tempfile,withTempdir,rmFile,catchIO) where
3-- System helper functions.
4import Control.Monad (when)
5import Distribution.Text (display)
6import System.Directory (getTemporaryDirectory
8 , removeDirectoryRecursive
9 , createDirectoryIfMissing
11import System.FilePath ((</>), normalise)
14import Control.Exception as CE
16catchIO :: IO a -> (IOError -> IO a) -> IO a
19throwIO :: IOError -> IO a
22tempfile :: IO (FilePath, Handle)
23tempfile = do dir <- getTemporaryDirectory
24 openTempFile (normalise dir) "idris"
26withTempdir :: String -> (FilePath -> IO a) -> IO a
27withTempdir subdir callback
28 = do dir <- getTemporaryDirectory
29 let tmpDir = (normalise dir) </> subdir
30 removeLater <- catchIO (createDirectoryIfMissing True tmpDir >> return True)
31 (\ ioError -> if isAlreadyExistsError ioError then return False
34 result <- callback tmpDir
35 when removeLater $ removeDirectoryRecursive tmpDir
38rmFile :: FilePath -> IO ()
39rmFile f = do putStrLn $ "Removing " ++ f
40 catchIO (removeFile f)
41 (\ioerr -> putStrLn $ "WARNING: Cannot remove file "
42 ++ 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