-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Use RawFilePath instead of FilePath -- -- Please see README.md @package rawfilepath @version 0.1.1 -- | Higher-level API for the RawFilePath-variants of functions in -- the unix module. module System.RawFilePath -- | A literal POSIX file path type RawFilePath = ByteString -- | Creates a new process to run the specified command with the given -- arguments, and waits for it to finish. Throws an exception if the -- process returns a nonzero exit code. -- --
-- *System.RawFilePath> callProcess "ls" ["-a", "src"] -- . .. System --callProcess :: RawFilePath -> [ByteString] -> IO () -- | Same as callProcess except the child process will share the -- parent's stdout and stderr, meaning it won't print anything. callProcessSilent :: RawFilePath -> [ByteString] -> IO ExitCode -- | Runs a command, reads its standard output strictly, blocking until the -- process terminates, and returns the output as ByteString. -- --
-- *System.RawFilePath> readProcess "date" ["+%s"] -- "1469999314\n" --readProcess :: RawFilePath -> [ByteString] -> IO ByteString -- | A 'safer' approach to readProcess. Depending on the exit status -- of the process, this function will return output either from stderr or -- stdout. -- --
-- *System.RawFilePath> readProcessEither "date" ["%s"] -- Left "date: invalid date \226\128\152%s\226\128\153\n" -- *System.RawFilePath> readProcessEither "date" ["+%s"] -- Right "1469999817\n" --readProcessEither :: RawFilePath -> [ByteString] -> IO (Either ByteString ByteString) -- | Get a list of files in the specified directory, excluding "." and ".." -- --
-- *System.RawFilePath> listDirectory "src" -- ["..","System","."] --listDirectory :: RawFilePath -> IO [RawFilePath] -- | Get a list of files in the specified directory, including "." and ".." -- --
-- *System.RawFilePath> getDirectoryFiles "src" -- ["..","System","."] --getDirectoryFiles :: RawFilePath -> IO [RawFilePath] -- | Recursively get all files in all subdirectories of the specified -- directory. -- --
-- *System.RawFilePath> getDirectoryFilesRecursive "src" -- ["src/System/RawFilePath.hs"] --getDirectoryFilesRecursive :: RawFilePath -> IO [RawFilePath] -- | Copy a file from the source path to the destination path. copyFile :: RawFilePath -> RawFilePath -> IO () -- | Returns the current user's home directory. getHomeDirectory :: IO RawFilePath -- | Returns True if the argument file exists and is not a -- directory. doesFileExist :: RawFilePath -> IO Bool -- | Returns True if the argument file exists and is a directory. doesDirectoryExist :: RawFilePath -> IO Bool -- | Change the working directory to the given path. setCurrentDirectory :: RawFilePath -> IO () -- | A function that "tries" to remove a file. If the file does not exist, -- nothing happens. tryRemoveFile :: RawFilePath -> IO () -- | Welcome to System.Process.RawFilePath, a small part of the -- Haskell community's effort to purge String for the Greater -- Good. -- -- With this module, you can create (and interact with) sub-processes -- without the encoding problem of String. The command and its -- arguments, all ByteStrings, never get converted from/to -- String internally on its way to the actual syscall. It also -- avoids the time/space waste of String. -- -- The interface, unlike the original process package, uses -- types to prevent unnecessary runtime errors when obtaining -- Handles. This is inspired by the typed-process package -- which is awesome, although this module is much simpler; it doesn't -- introduce any new requirement of language extension or library package -- (for the sake of portability). -- -- Handle (accessible with processStdin, -- processStdout, and processStderr) is what you can use to -- interact with the sub-process. For example, use hGetContents -- from Data.ByteString to read from a Handle as a -- ByteString. -- --
-- {-# language OverloadedStrings #-}
--
-- import System.Process.RawFilePath
-- import qualified Data.ByteString as B
--
-- main :: IO ()
-- main = do
-- p <- startProcess $ proc "echo" ["hello"]
-- `setStdout` CreatePipe
-- result <- B.hGetContents (processStdout p)
-- _ <- waitForProcess p
--
-- print (result == "hello\n")
--
module System.Process.RawFilePath
-- | The process configuration that is needed for creating new processes.
-- Use proc to make one.
data ProcessConf stdin stdout stderr
-- | Create a process configuration with the default settings.
proc :: RawFilePath -> [ByteString] -> ProcessConf Inherit Inherit Inherit
-- | The class of types that determine the standard stream of a
-- sub-process. You can decide how to initialize the standard streams
-- (stdin, stdout, and stderr) of a sub-process with the instances of
-- this class.
class StreamType c where mbFd = undefined willCreateHandle = undefined
-- | Create a new pipe for the stream. You get a new Handle.
data CreatePipe
CreatePipe :: CreatePipe
-- | Inherit the parent (current) process handle. The child will share the
-- stream. For example, if the child writes anything to stdout, it will
-- all go to the parent's stdout.
data Inherit
Inherit :: Inherit
-- | No stream handle will be passed. Use when you don't want to
-- communicate with a stream. For example, to run something silently.
data NoStream
NoStream :: NoStream
-- | Use the supplied Handle.
data UseHandle
UseHandle :: Handle -> UseHandle
-- | Control how the standard input of the process will be initialized.
setStdin :: (StreamType newStdin) => ProcessConf oldStdin stdout stderr -> newStdin -> ProcessConf newStdin stdout stderr
infixl 4 `setStdin`
-- | Control how the standard output of the process will be initialized.
setStdout :: (StreamType newStdout) => ProcessConf stdin oldStdout stderr -> newStdout -> ProcessConf stdin newStdout stderr
infixl 4 `setStdout`
-- | Control how the standard error of the process will be initialized.
setStderr :: (StreamType newStderr) => ProcessConf stdin stdout oldStderr -> newStderr -> ProcessConf stdin stdout newStderr
infixl 4 `setStderr`
-- | The process type. The three type variables denote how its standard
-- streams were initialized.
data Process stdin stdout stderr
-- | Start a new sub-process with the given configuration.
startProcess :: (StreamType stdin, StreamType stdout, StreamType stderr) => ProcessConf stdin stdout stderr -> IO (Process stdin stdout stderr)
-- | Take a process and return its standard input handle.
processStdin :: Process CreatePipe stdout stderr -> Handle
-- | Take a process and return its standard output handle.
processStdout :: Process stdin CreatePipe stderr -> Handle
-- | Take a process and return its standard error handle.
processStderr :: Process stdin stdout CreatePipe -> Handle
-- | Stop a sub-process. For now it simply calls terminateProcess
-- and then waitForProcess.
stopProcess :: Process stdin stdout stderr -> IO ExitCode
-- | Terminate a sub-process by sending SIGTERM to it.
terminateProcess :: Process stdin stdout stderr -> IO ()
-- | Wait (block) for a sub-process to exit and obtain its exit code.
waitForProcess :: Process stdin stdout stderr -> IO ExitCode
-- | A drop-in replacement of Data.ByteString from the
-- bytestring package that provides file I/O functions with
-- RawFilePath instead of FilePath.
module Data.ByteString.RawFilePath
-- | A literal POSIX file path
type RawFilePath = ByteString
-- | Read an entire file at the RawFilePath strictly into a
-- ByteString.
readFile :: RawFilePath -> IO ByteString
-- | Write a ByteString to a file at the RawFilePath.
writeFile :: RawFilePath -> ByteString -> IO ()
-- | Append a ByteString to a file at the RawFilePath.
appendFile :: RawFilePath -> ByteString -> IO ()
-- | Acquire a file handle and perform an I/O action. The file will be
-- closed on exit or when this I/O action throws an exception.
withFile :: RawFilePath -> IOMode -> (Handle -> IO r) -> IO r