rawfilepath-1.0.0: Use RawFilePath instead of FilePath
Copyright (C) 2004 The University of Glasgow. (C) 2017 XT et al. BSD-style (see the LICENSE file) e@xtendo.org stable POSIX None Haskell2010

RawFilePath.Directory

Description

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

Synopsis

# Documentation

A literal POSIX file path

## Nondestructive (read-only)

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.

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

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

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.

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.

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

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

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

Create a new directory.

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

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.

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

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

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

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