rawfilepath-0.2.4: Use RawFilePath instead of FilePath

Copyright(C) 2004 The University of Glasgow. (C) 2017 XT et al.
LicenseBSD-style (see the LICENSE file)
Maintainere@xtendo.org
Stabilityexperimental
PortabilityPOSIX
Safe HaskellNone
LanguageHaskell2010

RawFilePath.Directory

Contents

Description

This is the module for the RawFilePath version of functions in the directory package.

Synopsis

Documentation

type RawFilePath = ByteString #

A literal POSIX file path

Nondestructive (read-only)

doesPathExist :: RawFilePath -> IO Bool Source #

Test whether the given path points to an existing filesystem object. If the user lacks necessary permissions to search the parent directories, this function may return false even if the file does actually exist.

doesFileExist :: RawFilePath -> IO Bool Source #

Return True if the argument file exists and is not a directory, and False otherwise.

doesDirectoryExist :: RawFilePath -> IO Bool Source #

Return True if the argument file exists and is either a directory or a symbolic link to a directory, and False otherwise.

getHomeDirectory :: IO (Maybe RawFilePath) Source #

Returns the current user's home directory. More specifically, the value of the HOME environment variable.

The directory returned is expected to be writable by the current user, but note that it isn't generally considered good practice to store application-specific data here; use getXdgDirectory or getAppUserDataDirectory instead.

The operation may fail with:

  • UnsupportedOperation The operating system has no notion of home directory.
  • isDoesNotExistError The home directory for the current user does not exist, or cannot be found.

getTemporaryDirectory :: IO ByteString Source #

Return the current directory for temporary files. It first returns the value of the TMPDIR environment variable or "/tmp" if the variable isn't defined.

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 ".."

ghci> listDirectory "/"
["home","sys","var","opt","lib64","sbin","usr","srv","dev","lost+found","bin","tmp","run","root","boot","proc","etc","lib"]

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 ".."

ghci> getDirectoryFiles "/"
["home","sys","var","opt","..","lib64","sbin","usr","srv","dev","lost+found","mnt","bin","tmp","run","root","boot",".","proc","etc","lib"]

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"]

Destructive

createDirectory :: RawFilePath -> IO () Source #

Create a new directory.

ghci> createDirectory "/tmp/mydir"
ghci> getDirectoryFiles "/tmp/mydir"
[".",".."]
ghci> createDirectory "/tmp/mydir/anotherdir"
ghci> getDirectoryFiles "/tmp/mydir"
[".","..","anotherdir"]

createDirectoryIfMissing Source #

Arguments

:: Bool

Create parent directories or not

-> RawFilePath

The path of the directory to create

-> IO () 

Create a new directory if it does not already exist. If the first argument is True the function will also create all parent directories when they are missing.

removeFile :: RawFilePath -> IO () Source #

Remove a file. This function internally calls unlink. If the file does not exist, an exception is thrown.

tryRemoveFile :: RawFilePath -> IO () Source #

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

removeDirectory :: RawFilePath -> IO () Source #

Remove a directory. The target directory needs to be empty; Otherwise an exception will be thrown.

removeDirectoryRecursive :: RawFilePath -> IO () Source #

Remove an existing directory dir together with its contents and subdirectories. Within this directory, symbolic links are removed without affecting their targets.