blob: 3bc8096baa784c865794d3a69f4a04af9d06215a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
module Main (main) where
import Control.Exception
import Prelude hiding (catch)
import System.Directory
main :: IO ()
main = do doit ""
doit "/no/such/file"
doit :: FilePath -> IO ()
doit fp = do fp' <- canonicalizePath fp
print (fp, mangle fp')
`catch` \e -> putStrLn ("Exception: " ++ show (e :: IOException))
where -- On Windows, "/no/such/file" -> "C:\\no\\such\\file", so
-- we remove the drive letter so as to get consistent output
mangle (_ : ':' : xs) = "drive:" ++ xs
mangle xs = xs
|