refactor
This commit is contained in:
parent
18970377df
commit
bbd2efede3
1 changed files with 7 additions and 5 deletions
|
@ -58,6 +58,12 @@ readModes = [ownerReadMode, groupReadMode, otherReadMode]
|
||||||
executeModes :: [FileMode]
|
executeModes :: [FileMode]
|
||||||
executeModes = [ownerExecuteMode, groupExecuteMode, otherExecuteMode]
|
executeModes = [ownerExecuteMode, groupExecuteMode, otherExecuteMode]
|
||||||
|
|
||||||
|
otherGroupModes :: [FileMode]
|
||||||
|
otherGroupModes =
|
||||||
|
[ groupReadMode, otherReadMode
|
||||||
|
, groupWriteMode, otherWriteMode
|
||||||
|
]
|
||||||
|
|
||||||
{- Removes the write bits from a file. -}
|
{- Removes the write bits from a file. -}
|
||||||
preventWrite :: FilePath -> IO ()
|
preventWrite :: FilePath -> IO ()
|
||||||
preventWrite f = modifyFileMode f $ removeModes writeModes
|
preventWrite f = modifyFileMode f $ removeModes writeModes
|
||||||
|
@ -147,9 +153,5 @@ setSticky f = modifyFileMode f $ addModes [stickyMode]
|
||||||
writeFileProtected :: FilePath -> String -> IO ()
|
writeFileProtected :: FilePath -> String -> IO ()
|
||||||
writeFileProtected file content = withUmask 0o0077 $
|
writeFileProtected file content = withUmask 0o0077 $
|
||||||
withFile file WriteMode $ \h -> do
|
withFile file WriteMode $ \h -> do
|
||||||
void $ tryIO $ modifyFileMode file $
|
void $ tryIO $ modifyFileMode file $ removeModes otherGroupModes
|
||||||
removeModes
|
|
||||||
[ groupReadMode, otherReadMode
|
|
||||||
, groupWriteMode, otherWriteMode
|
|
||||||
]
|
|
||||||
hPutStr h content
|
hPutStr h content
|
||||||
|
|
Loading…
Add table
Reference in a new issue