system-fileio-0.2.6: Consistent filesystem interaction across GHC versions

Portabilityportable
Maintainerjmillikin@gmail.com
Safe HaskellSafe-Infered

System.Directory

Contents

Description

Deprecated alias for Filesystem.

Synopsis

Generic operations

isFile :: FilePath -> IO BoolSource

Check if a file exists at the given path.

Any non‐directory object, including devices and pipes, are considered to be files. Symbolic links are resolved to their targets before checking their type.

This computation does not throw exceptions.

isDirectory :: FilePath -> IO BoolSource

Check if a directory exists at the given path.

Symbolic links are resolved to their targets before checking their type.

This computation does not throw exceptions.

rename :: FilePath -> FilePath -> IO ()Source

Rename a filesystem object.

This computation throws IOError on failure. See “Classifying I/O errors” in the System.IO.Error documentation for information on why the failure occured.

canonicalizePath :: FilePath -> IO FilePathSource

Resolve symlinks and ".." path elements to return a canonical path. It is intended that two paths referring to the same object will always resolve to the same canonical path.

Note that on many operating systems, it is impossible to guarantee that two paths to the same file will resolve to the same canonical path.

This computation throws IOError on failure. See “Classifying I/O errors” in the System.IO.Error documentation for information on why the failure occured.

Since: 0.1.1

listDirectory :: FilePath -> IO [FilePath]Source

List objects in a directory, excluding "." and "..". Each returned FilePath includes the path of the directory. Entries are not sorted.

This computation throws IOError on failure. See “Classifying I/O errors” in the System.IO.Error documentation for information on why the failure occured.

Creating things

createDirectorySource

Arguments

:: Bool

Succeed if the directory already exists

-> FilePath 
-> IO () 

Create a directory at a given path. The user may choose whether it is an error for a directory to already exist at that path.

This computation throws IOError on failure. See “Classifying I/O errors” in the System.IO.Error documentation for information on why the failure occured.

createTree :: FilePath -> IO ()Source

Create a directory at a given path, including any parents which might be missing.

This computation throws IOError on failure. See “Classifying I/O errors” in the System.IO.Error documentation for information on why the failure occured.

Removing things

removeFile :: FilePath -> IO ()Source

Remove a file. This will fail if the file does not exist.

This computation cannot remove directories. For that, use removeDirectory or removeTree.

This computation throws IOError on failure. See “Classifying I/O errors” in the System.IO.Error documentation for information on why the failure occured.

removeDirectory :: FilePath -> IO ()Source

Remove an empty directory.

This computation throws IOError on failure. See “Classifying I/O errors” in the System.IO.Error documentation for information on why the failure occured.

removeTree :: FilePath -> IO ()Source

Recursively remove a directory tree rooted at the given path.

This computation does not follow symlinks. If the tree contains symlinks, the links themselves will be removed, but not the objects they point to.

If the root path is a symlink, then it will be treated as if it were a regular directory.

This computation throws IOError on failure. See “Classifying I/O errors” in the System.IO.Error documentation for information on why the failure occured.

Current working directory

getWorkingDirectory :: IO FilePathSource

Get the current working directory.

This computation throws IOError on failure. See “Classifying I/O errors” in the System.IO.Error documentation for information on why the failure occured.

setWorkingDirectory :: FilePath -> IO ()Source

Set the current working directory.

This computation throws IOError on failure. See “Classifying I/O errors” in the System.IO.Error documentation for information on why the failure occured.

Commonly used paths

getHomeDirectory :: IO FilePathSource

Get the user’s home directory. This is useful for building paths to more specific directories.

For directing the user to open or safe a document, use getDocumentsDirectory.

For data files the user does not explicitly create, such as automatic saves, use getAppDataDirectory.

This computation throws IOError on failure. See “Classifying I/O errors” in the System.IO.Error documentation for information on why the failure occured.

getDesktopDirectory :: IO FilePathSource

Get the user’s desktop directory. This is a good starting point for file dialogs and other user queries. For data files the user does not explicitly create, such as automatic saves, use getAppDataDirectory.

This computation throws IOError on failure. See “Classifying I/O errors” in the System.IO.Error documentation for information on why the failure occured.

getDocumentsDirectory :: IO FilePathSource

Get the user’s documents directory. This is a good place to save user‐created files. For data files the user does not explicitly create, such as automatic saves, use getAppDataDirectory.

This computation throws IOError on failure. See “Classifying I/O errors” in the System.IO.Error documentation for information on why the failure occured.

getAppDataDirectory :: Text -> IO FilePathSource

Get the user’s application data directory, given an application label. This directory is where applications should store data the user did not explicitly create, such as databases and automatic saves.

This computation throws IOError on failure. See “Classifying I/O errors” in the System.IO.Error documentation for information on why the failure occured.

getAppCacheDirectory :: Text -> IO FilePathSource

Get the user’s application cache directory, given an application label. This directory is where applications should store caches, which might be large and can be safely deleted.

This computation throws IOError on failure. See “Classifying I/O errors” in the System.IO.Error documentation for information on why the failure occured.

getAppConfigDirectory :: Text -> IO FilePathSource

Get the user’s application configuration directory, given an application label. This directory is where applications should store their configurations and settings.

This computation throws IOError on failure. See “Classifying I/O errors” in the System.IO.Error documentation for information on why the failure occured.