system-canonicalpath-0.3.0.0: Abstract data type for canonical paths with some utilities

Copyright(c) Boris Buliga, 2014
LicenseMIT
Maintainerd12frosted@icloud.com
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Filesystem.CanonicalPath.Directory

Description

Redefinition of some functions from System.Directory module. Some of them have different signature, because they need to work with CanonicalPath. For example, we can't create functions createDirectory :: CanonicalPath -> IO (), because it has no sense. How can we create directory that already exists? Instead we have function createDirectory :: CanonicalPath -> FilePath -> IO CanonicalPath, that creates new directory in base existing directory with provided name. And also it returns CanonicalPath of newly created directory. Isn't it nice?

A lot of functions come in two variants: one that returns resulting @CanonicalPath and second that ignores result (they end with '_' symbol).

Happy Haskell Hacking!

Synopsis

Documentation

createDirectory Source

Arguments

:: MonadIO m 
=> CanonicalPath

base directory

-> FilePath

name of new directory

-> m CanonicalPath

CanonicalPath of created directory

createDirectory base dir creates new directory dir in existing base directory and returns CanonicalPath of created directory.

For more information look for documentation of createDirectory.

Since 0.1.1.0

createDirectory_ :: MonadIO m => CanonicalPath -> FilePath -> m () Source

Variant of createDirectory that ignores resulting CanonicalPath.

Since 0.2.2.0

createDirectoryIfMissing Source

Arguments

:: MonadIO m 
=> Bool

Create its parents too?

-> CanonicalPath

base directory

-> FilePath

name of new directory

-> m CanonicalPath

CanonicalPath of created directory

createDirectoryIfMissing parents dir creates a new directory dir in base directory. If the first argument is True the function will also create all parent directories if they are missing. Function returns CanonicalPath of created directory.

For more information look for documentation of createDirectoryIfMissing.

Since 0.1.1.0

createDirectoryIfMissing_ :: MonadIO m => Bool -> CanonicalPath -> FilePath -> m () Source

Variant of createDirectoryIfMissing that ignores resulting CanonicalPath.

Since 0.2.2.0

removeDirectory :: MonadIO m => CanonicalPath -> m () Source

removeDirectory dir removes an existing directory dir.

For more information look for documentation of removeDirectory.

Since 0.1.1.0

removeDirectoryRecursive :: MonadIO m => CanonicalPath -> m () Source

removeDirectoryRecursive dir removes an existing directory dir together with its content and all subdirectories. Be careful, if the directory contains symlinks, the function will follow them.

For more information look for documentation of removeDirectoryRecursive.

Since 0.1.1.0

renameDirectory Source

Arguments

:: MonadIO m 
=> CanonicalPath

old directory

-> FilePath

new directory (should be just name of directory)

-> m CanonicalPath

CanonicalPath of new directory

renameDirectory old new changes the name of an existing directory from old to new and returns CanonicalPath of new directory.

For more information look for documentation of renameDirectory.

Since 0.1.1.0

renameDirectory_ :: MonadIO m => CanonicalPath -> FilePath -> m () Source

Variant of renameDirectory that ignores resulting CanonicalPath.

Since 0.2.2.0

getDirectoryContents :: MonadIO m => CanonicalPath -> m [FilePath] Source

getDirectoryContents dir returns a list of all entries in dir. If you want to have list of CanonicalPath instead use function getDirectoryContents'.

For more information look for documentation of getDirectoryContents.

Since 0.1.1.0

getDirectoryContents' :: MonadIO m => CanonicalPath -> m [CanonicalPath] Source

The same as getDirectoryContents, but returns list of CanonicalPath instead of FilePath.

Since 0.1.1.0

getDirectoryContents'' :: MonadIO m => CanonicalPath -> m [Text] Source

The same as getDirectoryContents, but returns list of Text instead of FilePath.

Since 0.2.2.0

getCurrentDirectory :: MonadIO m => m CanonicalPath Source

If the operating system has a notion of current directories, getCurrentDirectory returns an CanonicalPath to the current directory of the calling process.

For more information look for documentation of getCurrentDirectory.

Since 0.1.1.0

setCurrentDirectory :: MonadIO m => CanonicalPath -> m () Source

If the operating system has a notion of current directories, setCurrentDirectory dir changes the current directory of the calling process to dir.

For more information look for documentation of setCurrentDirectory.

Since 0.1.1.0

getHomeDirectory :: MonadIO m => m CanonicalPath Source

Returns the current user's home directory.

For more information look for documentation of getHomeDirectory.

Since 0.1.1.0

getAppUserDataDirectory :: MonadIO m => Text -> m FilePath Source

Returns the CanonicalPath of a directory in which application-specific data for the current user can be stored. The result of getAppUserDataDirectory for a given application is specific to the current user.

For more information look for documentation of getAppUserDataDirectory.

Since 0.1.1.0

getUserDocumentsDirectory :: MonadIO m => m CanonicalPath Source

Returns the current user's document directory.

For more information look for documentation of getUserDocumentsDirectory.

Since 0.1.1.0

getTemporaryDirectory :: MonadIO m => m FilePath Source

Returns the current directory for temporary files.

For more information look for documentation of getUserDocumentsDirectorygetTemporaryDirectory.

Since 0.1.1.0

removeFile :: MonadIO m => CanonicalPath -> m () Source

removeFile file removes the directory entry for an existing file file, where file is not itself a directory.

For more information look for documentation of removeFile.

Since 0.1.1.0

renameFile Source

Arguments

:: MonadIO m 
=> CanonicalPath

CanonicalPath of file you want to rename

-> FilePath

new name of file

-> m CanonicalPath

CanonicalPath of new file

renameFile old new changes the name of an existing file system object from old to new.

For more information look for documentation of renameFile.

Since 0.1.1.0

renameFile_ :: MonadIO m => CanonicalPath -> FilePath -> m () Source

Variant of renameFile that ignores resulting CanonicalPath.

Since 0.2.2.0

copyFile Source

Arguments

:: MonadIO m 
=> CanonicalPath

CanonicalPath of file you want to copy

-> FilePath

name of new file (actually it can be path relative to directory of old

-> m CanonicalPath

CanonicalPath of new file

copyFile old new copies the existing file from old to new. If the new file already exists, it is atomically replaced by the old file. Neither path may refer to an existing directory. The permissions of old are copied to new, if possible.

For more information look for documentation of copyFile.

Since 0.1.1.0