directory001.hs 369 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
import IO

import Directory

main = do
    createDirectory "foo"
    h <- openFile "foo/bar" WriteMode
    hPutStr h "Okay\n"
    hClose h
    renameFile "foo/bar" "foo/baz"
    renameDirectory "foo" "bar"
    h <- openFile "bar/baz" ReadMode
    stuff <- hGetContents h
    putStr stuff
--    hClose h  -- an error !
    removeFile "bar/baz"
    removeDirectory "bar"