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


-- | Portable temporary file and directory support
--   
--   Functions for creating temporary files and directories.
@package temporary
@version 1.3


-- | Functions to create temporary files and directories.
--   
--   Most functions come in two flavours: those that create
--   files/directories under the system standard temporary directory and
--   those that use the user-supplied directory.
--   
--   The functions that create files/directories under the system standard
--   temporary directory will return canonical absolute paths (see
--   <a>getCanonicalTemporaryDirectory</a>). The functions use the
--   user-supplied directory do not canonicalize the returned path.
--   
--   The action inside <a>withTempFile</a> or <a>withTempDirectory</a> is
--   allowed to remove the temporary file/directory if it needs to.
--   
--   <h2>Templates and file names</h2>
--   
--   The treatment of templates differs somewhat for files vs directories.
--   
--   For files, the template has form <tt>name.ext</tt>, and a random
--   number will be placed between between the name and the extension to
--   yield a unique file name, e.g. <tt>name1804289383846930886.ext</tt>.
--   
--   For directories, no extension is recognized. A random hexadecimal
--   string (whose length depends on the system's word size) is appended to
--   the end of the template. For instance, the directory template
--   <tt>dir</tt> may result in a directory named
--   <tt>dir-e4bd89e5d00acdee</tt>.
--   
--   You shouldn't rely on the specific form of file or directory names
--   generated by the library; it has changed in the past and may change in
--   the future.
module System.IO.Temp

-- | Create, open, and use a temporary file in the system standard
--   temporary directory.
--   
--   The temp file is deleted after use.
--   
--   Behaves exactly the same as <a>withTempFile</a>, except that the
--   parent temporary directory will be that returned by
--   <a>getCanonicalTemporaryDirectory</a>.
withSystemTempFile :: (MonadIO m, MonadMask m) => String -> (FilePath -> Handle -> m a) -> m a

-- | Create and use a temporary directory in the system standard temporary
--   directory.
--   
--   Behaves exactly the same as <a>withTempDirectory</a>, except that the
--   parent temporary directory will be that returned by
--   <a>getCanonicalTemporaryDirectory</a>.
withSystemTempDirectory :: (MonadIO m, MonadMask m) => String -> (FilePath -> m a) -> m a

-- | Create, open, and use a temporary file in the given directory.
--   
--   The temp file is deleted after use.
withTempFile :: (MonadIO m, MonadMask m) => FilePath -> String -> (FilePath -> Handle -> m a) -> m a

-- | Create and use a temporary directory inside the given directory.
--   
--   The directory is deleted after use.
withTempDirectory :: (MonadMask m, MonadIO m) => FilePath -> String -> (FilePath -> m a) -> m a

-- | Like <a>openBinaryTempFile</a>, but uses 666 rather than 600 for the
--   permissions.
--   
--   Equivalent to <a>openBinaryTempFileWithDefaultPermissions</a>.
openNewBinaryFile :: FilePath -> String -> IO (FilePath, Handle)

-- | Create a temporary directory.
createTempDirectory :: FilePath -> String -> IO FilePath

-- | Create a unique new file, write (text mode) a given data string to it,
--   and close the handle again. The file will not be deleted
--   automatically, and only the current user will have permission to
--   access the file.
writeTempFile :: FilePath -> String -> String -> IO FilePath

-- | Like <a>writeTempFile</a>, but use the system directory for temporary
--   files.
writeSystemTempFile :: String -> String -> IO FilePath

-- | Create a unique new empty file. (Equivalent to <a>writeTempFile</a>
--   with empty data string.) This is useful if the actual content is
--   provided by an external process.
emptyTempFile :: FilePath -> String -> IO FilePath

-- | Like <a>emptyTempFile</a>, but use the system directory for temporary
--   files.
emptySystemTempFile :: String -> IO FilePath
openTempFile :: FilePath -> String -> IO (FilePath, Handle)
openBinaryTempFile :: FilePath -> String -> IO (FilePath, Handle)

-- | Return the absolute and canonical path to the system temporary
--   directory.
--   
--   <pre>
--   &gt;&gt;&gt; setCurrentDirectory "/home/feuerbach/"
--   
--   &gt;&gt;&gt; setEnv "TMPDIR" "."
--   
--   &gt;&gt;&gt; getTemporaryDirectory
--   "."
--   
--   &gt;&gt;&gt; getCanonicalTemporaryDirectory
--   "/home/feuerbach"
--   </pre>
getCanonicalTemporaryDirectory :: IO FilePath
