Platform-agnostic library for filesystem operations

Version on this page:
LTS Haskell 22.30:
Stackage Nightly 2024-07-23:
Latest on Hackage:

See all snapshots directory appears in

BSD-3-Clause licensed
Maintained by [email protected]
This version can be pinned in stack with:directory-,2734

Module documentation for

  • System


Hackage Build status Windows build status

Documentation can be found on Hackage.

Building from Git repository

When building this package directly from the Git repository, one must run autoreconf -fi to generate the configure script needed by cabal configure. This requires Autoconf to be installed.

autoreconf -fi
cabal install

There is no need to run the configure script manually however, as cabal configure does that automatically.


Changelog for the directory package (December 2016)

  • Drop trailing slashes in canonicalizePath (#63)

  • Rename isSymbolicLink to pathIsSymbolicLink. The old name will remain available but may be removed in the next major release. (#52)

  • Changed canonicalizePath to dereference symbolic links even if it points to a file and is not the last path segment

  • On Windows, canonicalizePath now canonicalizes the letter case too

  • On Windows, canonicalizePath now also dereferences symbolic links

  • When exceptions are thrown, the error location will now contain additional information about the internal function(s) used. (November 2016)

  • Don’t abort removePathForcibly if files or directories go missing. In addition, keep going even if an exception occurs. (#60) (August 2016)

  • Remove deprecated C bits. This means HsDirectory.h and its functions are no longer available. (#50)

  • Add doesPathExist and getFileSize (#57)

  • Add renamePath (#58)

  • Add removePathForcibly (#59) (May 2016)

  • Add missing import of (<*>) on Windows for base earlier than (#53) (April 2016)

  • Bundled with GHC 8.0.1

  • Fix typo in file time functions when utimensat is not available and version of unix package is lower than (April 2016)

  • Fix mistake in file time functions when utimensat is not available (#47) (April 2016)

  • Make findExecutable, findExecutables, findExecutablesInDirectories, findFile, and findFilesWith lazier (#43)

  • Add findFileWith

  • Add copyFileWithMetadata, which copies additional metadata (#40)

  • Improve error message of removeDirectoryRecursive when used on a directory symbolic link on Windows.

  • Add isSymbolicLink

  • Drop support for Hugs. (February 2016)

  • Improve error message of getCurrentDirectory when the current working directory no longer exists (#39)

  • Fix the behavior of trailing path separators in canonicalizePath as well as makeAbsolute when applied to the current directory; they should now match the behavior of canonicalizePath prior to (when the bug was introduced) (#42)

  • Set the location in IO errors from makeAbsolute. (December 2015)

  • Add listDirectory, which is similar to getDirectoryContents but omits . and .. (#36)

  • Remove support for --with-cc= in configure; use the CC= flag instead (ghc:D1608) (September 2015)

  • Work around lack of #const_str when cross-compiling (haskell-cafe)

  • Add findExecutablesInDirectories (#33)

  • Add exeExtension (August 2015)

  • Restore support for Safe Haskell with base < 4.8 (#30) (July 2015)

  • Add support for XDG Base Directory Specification (#6)

  • Implement setModificationTime counterpart to getModificationTime (#13)

  • Implement getAccessTime and setAccessTime

  • Set the filename in IO errors from the file time functions

  • Fix canonicalizePath so that it always returns a reasonable result even if the path is inaccessible and will not throw exceptions unless the current directory cannot be obtained (#23)

  • Corrected the trailing slash behavior of makeAbsolute so that makeAbsolute "" == makeAbsolute "."

  • Deprecate use of HsDirectory.h and HsDirectoryConfig.h

  • Implement withCurrentDirectory (Apr 2015)

  • Fix dependency problem on NixOS when building with tests (#24) (Mar 2015)

  • Bundled with GHC 7.10.1

  • Make getModificationTime support sub-second resolution on Windows

  • Fix silent failure in createDirectoryIfMissing

  • Replace throw by better defined throwIOs

  • Avoid stack overflow in getDirectoryContents (#17)

  • Expose findExecutables (#14)

  • removeDirectoryRecursive no longer follows symlinks under any circumstances (#15)

  • Allow trailing path separators in getPermissions on Windows (#9)

  • renameFile now always throws the correct error type (InappropriateType) when the destination is a directory, as long as the filesystem is not being modified concurrently (#8)

  • Add makeAbsolute, which should be preferred over canonicalizePath unless one requires symbolic links to be resolved (Mar 2014)

  • Bundled with GHC 7.8.1

  • Add support for sub-second precision in getModificationTime when linked against unix>=

  • Fix createDirectoryIfMissing _ "." in C:\ on Windows

  • Remove support for NHC98 compiler

  • Update package to cabal-version >= 1.10 format

  • Enhance Haddock documentation for doesDirectoryExist and canonicalizePath

  • Fix findExecutable to check that file permissions indicate executable

  • New convenience functions findFiles and findFilesWith