[Haskell-cafe] System.Posix.Files.isDirectory and System.Posix.Files.isSymbolicLink

Erik de Castro Lopo mle+cl at mega-nerd.com
Sun Feb 1 17:49:26 EST 2009


Hi all,

The following code creates a symbolic link in the current directory
and then uses System.Posix.Files.getFileStatus to get the status of
the link.

However, isDirectory returns True and isSymbolicLink returns False
which is very different from what the stat() system call on a POSIX
system would return. I consider this a bug.

I'm using ghc-6.8.2. Has this been fixed in a later version?

Cheers,
Erik


module Main where

import qualified System.Directory
import qualified System.Posix.Files

main :: IO ()
main = do
	let linkName = "tmp-link"
	cwd <- System.Directory.getCurrentDirectory
	System.Posix.Files.createSymbolicLink "/tmp" linkName
	stat <- System.Posix.Files.getFileStatus linkName
	if System.Posix.Files.isDirectory stat
		then putStrLn "Is a directory?????"
		else putStrLn "Not a directory."
	if System.Posix.Files.isSymbolicLink stat
		then putStrLn "Is a symlink"
		else putStrLn "Not a symlink?????"



-- 
-----------------------------------------------------------------
Erik de Castro Lopo
-----------------------------------------------------------------
"Anyone who considers arithmetical methods of producing random
digits is, of course, in a state of sin." - John Von Neumann (1951)


More information about the Haskell-Cafe mailing list