atomic-write 0.2.0.3 → 0.2.0.4
raw patch · 2 files changed
+12/−9 lines, 2 filesdep ~basePVP: minor bump suggested
API additions: PVP suggests at least a minor version bump
Dependency ranges changed: base
API changes (from Hackage documentation)
+ System.AtomicWrite.Writer.String: atomicWithFile :: FilePath -> (Handle -> IO ()) -> IO ()
Files
atomic-write.cabal view
@@ -1,7 +1,7 @@ name: atomic-write-version: 0.2.0.3+version: 0.2.0.4 synopsis: Atomically write to a file-+homepage: https://github.com/stackbuilders/atomic-write description: . Atomically write to a file on POSIX-compliant systems while preserving@@ -58,7 +58,7 @@ other-modules: System.AtomicWrite.Internal - build-depends: base >=4.5 && <4.8+ build-depends: base >= 4.5 && < 4.9 , temporary , unix-compat , directory@@ -75,14 +75,13 @@ hs-source-dirs: spec, src main-is: Spec.hs - build-depends: base >=4.5 && <4.8+ build-depends: base >= 4.5 && < 4.9 , temporary , unix-compat , directory , filepath , text , bytestring >= 0.10.4- , hspec default-language: Haskell2010
src/System/AtomicWrite/Writer/String.hs view
@@ -1,8 +1,8 @@-module System.AtomicWrite.Writer.String (atomicWriteFile) where+module System.AtomicWrite.Writer.String (atomicWriteFile, atomicWithFile) where import System.AtomicWrite.Internal (closeAndRename, tempFileFor) -import System.IO (hPutStr)+import System.IO (Handle, hPutStr) -- | Creates a file atomically on POSIX-compliant systems while preserving -- permissions.@@ -10,5 +10,9 @@ FilePath -- ^ The path where the file will be updated or created -> String -- ^ The content to write to the file -> IO ()-atomicWriteFile f txt =- tempFileFor f >>= \(tmpPath, h) -> hPutStr h txt >> closeAndRename h tmpPath f+atomicWriteFile = (. flip hPutStr) . atomicWithFile++-- | A general version of 'atomicWriteFile'+atomicWithFile :: FilePath -> (Handle -> IO ()) -> IO ()+atomicWithFile f action = + tempFileFor f >>= \(tmpPath, h) -> action h >> closeAndRename h tmpPath f