1 import System.Directory
2 import Control.Exception
6 dir = "getDirContents001.dir"
9 try cleanup :: IO (Either IOException ())
10 bracket (createDirectory dir) (const cleanup) $ \_ -> do
11 getDirectoryContents dir >>= print . sort
12 mapM_ (\s -> writeFile (dir </> ('f':show s)) (show s)) [1..100]
13 getDirectoryContents dir >>= print . sort
16 files <- getDirectoryContents dir
17 mapM_ (removeFile . (dir </>)) (filter (not . ("." `isPrefixOf`)) files)