[darcs-users] darcs patch: eliminate autogeneration of Workaround.hs (and 1 more)

Petr Rockai me at mornfall.net
Sat Oct 11 15:20:23 UTC 2008


Hi,

"David Roundy" <droundy at darcs.net> writes:
>> On Windows:
>>> +setExecutable :: FilePath -> Bool -> IO ()
>>> +setExecutable _ _ = return ()
>> Elsewhere:
>>> +setExecutable :: FilePath -> Bool -> IO ()
>>> +setExecutable f ex =
>>> +  do st <- getFileStatus f
>>> +     umask <- setFileCreationMask 0
>>> +     setFileCreationMask umask
>>> +     let rw = fileMode st .&.
>>> +              (ownerReadMode .|. ownerWriteMode .|.
>>> +               groupReadMode .|. groupWriteMode .|.
>>> +               otherReadMode .|. otherWriteMode)
>>> +         total = if ex then rw .|.
>>> +                           ((ownerExecuteMode .|. groupExecuteMode .|. otherExecuteMode)
>>> +                            .&. complement umask)
>>> +                       else rw
>>> +     setFileMode f total
>>
>> Unchanged.  But maybe this function belows in Darcs.Utils so that we can
>> reserve the Workarounds module for functions that we are trying to use
>> from libraries.
>
> Sure, I'd love to eliminate Workaround.

Would it be feasible to use this instead?

import System.Directory ( getPermissions, setPermissions, executable )

setExecutable :: FilePath -> Bool -> IO ()
setExecutable fp e = do p <- getPermissions fp
                        setPermissions fp $ p { executable = e }

It does require System.Directory which might be unavailable in older GHC maybe?
Or is that a hackage module? Can't recall and don't have anything but GHC 6.8
around... Anyhow, it should be portable to windows, where this is either
hopefully a noop or it might involve NTFS ACLs, again, I have no idea. Maybe
some GHC folks might want to comment.

Yours,
   Petr.

-- 
Peter Rockai | me()mornfall!net | prockai()redhat!com
 http://blog.mornfall.net | http://web.mornfall.net

"In My Egotistical Opinion, most people's C programs should be
 indented six feet downward and covered with dirt."
     -- Blair P. Houghton on the subject of C program indentation


More information about the darcs-users mailing list