-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Write output to disk atomically
--   
--   This package implements utilities to perform atomic output so as to
--   avoid the problem of partial intermediate files.
@package safeio
@version 0.0.5.0

module System.IO.SafeWrite

-- | Variation of <tt>withFile</tt> for output files.
--   
--   Output is written to a temporary file. Once the action has completed,
--   this file is then sync'ed to disk (see |syncFile|) and renamed to its
--   final destination. In Posix, this is an atomic operation. If an
--   exception is raised, then the temporary output file will be deleted
--   and not saved to disk. Thus, the result file will either contain the
--   complete result or will be empty.
withOutputFile :: (MonadMask m, MonadIO m) => FilePath -> (Handle -> m a) -> m a

-- | Sync a file to disk
--   
--   On Windows, this is a fake function.
syncFile :: FilePath -> IO ()
allocateTempFile :: FilePath -> IO (FilePath, Handle)
finalizeTempFile :: FilePath -> Bool -> (FilePath, Handle) -> IO ()

module Data.Conduit.SafeWrite

-- | Write to file <tt>finalname</tt> using a temporary file and atomic
--   move.
--   
--   The file is only written if the sink runs to completion without
--   errors. Any form of early termination will cause the output to be
--   removed.
--   
--   This function is deprecated in favor of <a>SinkFileCautious</a>
safeSinkFile :: (MonadResource m) => FilePath -> Sink ByteString m ()

-- | Conduit using a Handle in an atomic way
atomicConduitUseFile :: (MonadResource m) => FilePath -> (Handle -> ConduitM i o m a) -> ConduitM i o m a
