diff options
author | Joey Hess <joey@kitenet.net> | 2013-01-03 18:50:30 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2013-01-03 18:50:30 -0400 |
commit | fbaf52d7b852d02ec0b5bfe639715a29024b1a9b (patch) | |
tree | c6f5db7ac6fc3d9f15210ab10b3bb61c9f8ea93f /Utility/FileMode.hs | |
parent | 1c880e8692e9722967a30d4c4f59107e15360d92 (diff) |
restart UI
Browser behavior is not ideal; a new tab is opened on restart.
Browsers won't let me redirect to a file:// so I cannot use the old tab.
Diffstat (limited to 'Utility/FileMode.hs')
-rw-r--r-- | Utility/FileMode.hs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Utility/FileMode.hs b/Utility/FileMode.hs index ddb89b2aa..0f7046333 100644 --- a/Utility/FileMode.hs +++ b/Utility/FileMode.hs @@ -101,3 +101,12 @@ isSticky = checkMode stickyMode setSticky :: FilePath -> IO () setSticky f = modifyFileMode f $ addModes [stickyMode] + +{- Writes a file, ensuring that its modes do not allow it to be read + - by anyone other than the current user, before any content is written. -} +writeFileProtected :: FilePath -> String -> IO () +writeFileProtected file content = do + h <- openFile file WriteMode + modifyFileMode file $ removeModes [groupReadMode, otherReadMode] + hPutStr h content + hClose h |