rawfilepath-0.1.1: Use RawFilePath instead of FilePath

Copyright(c) XT 2016
LicenseApache 2.0
Maintainere@xtendo.org
Stabilityexperimental
PortabilityPOSIX
Safe HaskellSafe
LanguageHaskell2010

System.RawFilePath

Contents

Description

Higher-level API for the RawFilePath-variants of functions in the unix module.

Synopsis

Documentation

type RawFilePath = ByteString #

A literal POSIX file path

Process

callProcess Source #

Arguments

:: RawFilePath

Command to run

-> [ByteString]

Command arguments

-> IO () 

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

callProcessSilent Source #

Arguments

:: RawFilePath

Command to run

-> [ByteString]

Command arguments

-> IO ExitCode 

Same as callProcess except the child process will share the parent's stdout and stderr, meaning it won't print anything.

readProcess Source #

Arguments

:: RawFilePath

Command to run

-> [ByteString]

Command arguments

-> IO ByteString

The output from the command

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"

readProcessEither Source #

Arguments

:: RawFilePath

Command to run

-> [ByteString]

Command arguments

-> IO (Either ByteString ByteString)

Either the stedrr output from the command if it finished with a nonzero exit code, or the stdout data if it finished normally.

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"

Directory

listDirectory Source #

Arguments

:: RawFilePath

The path of directory to inspect

-> IO [RawFilePath]

A list of files in the directory

Get a list of files in the specified directory, excluding "." and ".."

*System.RawFilePath> listDirectory "src"
["..","System","."]

getDirectoryFiles Source #

Arguments

:: RawFilePath

The path of directory to inspect

-> IO [RawFilePath]

A list of files in the directory

Get a list of files in the specified directory, including "." and ".."

*System.RawFilePath> getDirectoryFiles "src"
["..","System","."]

getDirectoryFilesRecursive Source #

Arguments

:: RawFilePath

The path of directory to inspect

-> IO [RawFilePath]

A list of relative paths

Recursively get all files in all subdirectories of the specified directory.

*System.RawFilePath> getDirectoryFilesRecursive "src"
["src/System/RawFilePath.hs"]

copyFile Source #

Arguments

:: RawFilePath

The source path

-> RawFilePath

The destination path

-> IO () 

Copy a file from the source path to the destination path.

getHomeDirectory :: IO RawFilePath Source #

Returns the current user's home directory.

doesFileExist :: RawFilePath -> IO Bool Source #

Returns True if the argument file exists and is not a directory.

doesDirectoryExist :: RawFilePath -> IO Bool Source #

Returns True if the argument file exists and is a directory.

setCurrentDirectory :: RawFilePath -> IO () Source #

Change the working directory to the given path.

tryRemoveFile :: RawFilePath -> IO () Source #

A function that "tries" to remove a file. If the file does not exist, nothing happens.