summaryrefslogtreecommitdiff
path: root/Utility/FileMode.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Utility/FileMode.hs')
-rw-r--r--Utility/FileMode.hs10
1 files changed, 7 insertions, 3 deletions
diff --git a/Utility/FileMode.hs b/Utility/FileMode.hs
index 5c4001ed8..201b8451c 100644
--- a/Utility/FileMode.hs
+++ b/Utility/FileMode.hs
@@ -124,7 +124,7 @@ withUmask _ a = a
#endif
combineModes :: [FileMode] -> FileMode
-combineModes [] = undefined
+combineModes [] = 0
combineModes [m] = m
combineModes (m:ms) = foldl unionFileModes m ms
@@ -151,7 +151,11 @@ setSticky f = modifyFileMode f $ addModes [stickyMode]
- as writeFile.
-}
writeFileProtected :: FilePath -> String -> IO ()
-writeFileProtected file content = withUmask 0o0077 $
+writeFileProtected file content = writeFileProtected' file
+ (\h -> hPutStr h content)
+
+writeFileProtected' :: FilePath -> (Handle -> IO ()) -> IO ()
+writeFileProtected' file writer = withUmask 0o0077 $
withFile file WriteMode $ \h -> do
void $ tryIO $ modifyFileMode file $ removeModes otherGroupModes
- hPutStr h content
+ writer h