[Haskell-cafe] setPermissions bug?

David Roundy droundy at abridgegame.org
Wed Feb 18 07:19:53 EST 2004


I've run into a problem using Directory.setPermissions (or equivalently
System.Directory.setPermissions).

Basically the problem is that

getPermissions f >>= setPermissions f

is not a noop.  Instead it is equivalent to

chmod o-r f
chmod g-r f
etc

I presume that this is a bug in setPermissions?

The documentation claims that

    Note that to change some, but not all permissions, a construct on the
    following lines must be used.

    makeReadable f = do
        p <- getPermissions f
        setPermissions f (p {readable = True})

Which certainly implies that it is possible to change only some
permissions, contrary to what happens in the actual implementation.  It
also seems that the Permissions data type could include in it additional
(hidden, since it isn't portable perhaps) information in order to make the
above code work.  Then the only major question would be whether

        setPermissions f (p {writeable = True}) 

should make the file world-writeable or just user-writeable.  I don't know
about that.  But at a minimum, it should preserve world-readability.
-- 
David Roundy
http://www.abridgegame.org


More information about the Haskell-Cafe mailing list