1module Util.System(tempfile,withTempdir,rmFile,catchIO, isWindows) where
3-- System helper functions.
4import Control.Monad (when)
5import System.Directory (getTemporaryDirectory
7 , removeDirectoryRecursive
8 , createDirectoryIfMissing
10import System.FilePath ((</>), normalise)
14import Control.Exception as CE
16catchIO :: IO a -> (IOError -> IO a) -> IO a
19throwIO :: IOError -> IO a
23isWindows = os `elem` ["win32", "mingw32", "cygwin32"]
25tempfile :: IO (FilePath, Handle)
26tempfile = do dir <- getTemporaryDirectory
27 openTempFile (normalise dir) "idris"
29withTempdir :: String -> (FilePath -> IO a) -> IO a
30withTempdir subdir callback
31 = do dir <- getTemporaryDirectory
32 let tmpDir = (normalise dir) </> subdir
33 removeLater <- catchIO (createDirectoryIfMissing True tmpDir >> return True)
34 (\ ioError -> if isAlreadyExistsError ioError then return False
37 result <- callback tmpDir
38 when removeLater $ removeDirectoryRecursive tmpDir
41rmFile :: FilePath -> IO ()
42rmFile f = do putStrLn $ "Removing " ++ f
43 catchIO (removeFile f)
44 (\ioerr -> putStrLn $ "WARNING: Cannot remove file "
45 ++ 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