system-fileio-0.1: High-level filesystem interaction

Portabilityportable
Maintainerjmillikin@gmail.com

System.Directory

Contents

Description

Simple FilePath‐aware wrappers around standard System.Directory computations. See the linked documentation for each computation for details on exceptions and operating system interaction.

Synopsis

File and directory attributes

isFile :: FilePath -> IO BoolSource

Check if a file exists at the given path.

See: doesFileExist

isDirectory :: FilePath -> IO BoolSource

Check if a directory exists at the given path.

See: doesDirectoryExist

fileSize :: FilePath -> IO IntegerSource

Get the size of an object at a given path. For special objects like links or directories, the size is filesystem‐ and platform‐dependent.

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

Rename a filesystem object. Some operating systems have restrictions on what objects can be renamed; see linked documentation for details.

See: renameFile and renameDirectory

modified :: FilePath -> IO UTCTimeSource

Get when the object at a given path was last modified.

listDirectory :: FilePath -> IO [FilePath]Source

List contents of a directory, excluding "." and "..".

See: getDirectoryContents

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.

See: createDirectory.

createTree :: FilePath -> IO ()Source

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

See: createDirectoryIfMissing

Removing things

removeFile :: FilePath -> IO ()Source

Remove a file.

See: removeFile

removeDirectory :: FilePath -> IO ()Source

Remove an empty directory.

See: removeDirectory

removeTree :: FilePath -> IO ()Source

Recursively remove a directory tree rooted at the given path.

See: removeDirectoryRecursive

Current working directory

getWorkingDirectory :: IO FilePathSource

Get the current working directory.

See: getCurrentDirectory

setWorkingDirectory :: FilePath -> IO ()Source

Set the current working directory.

See: setCurrentDirectory

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.

See: getHomeDirectory

getDesktopDirectory :: IO FilePathSource

Get the user’s home 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.

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.

See: getUserDocumentsDirectory

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.

See: getAppUserDataDirectory

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.

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.