Commits (7)
The `directory` Package [![Hackage](https://img.shields.io/hackage/v/directory.svg)](https://hackage.haskell.org/package/directory) [![Build Status](https://travis-ci.org/haskell/directory.svg?branch=master)](https://travis-ci.org/haskell/directory)
=======================
`directory` [![Hackage][1]][2] [![Build Status][3]][4]
===========
See [`directory` on Hackage](http://hackage.haskell.org/package/directory) for
more information.
Documentation can be found on [Hackage][2].
Installing from Git
-------------------
Building from Git repository
----------------------------
To build this package using Cabal directly from Git, you must run
`autoreconf -i` before the usual Cabal build steps (`cabal
{configure,build,install}`). The program `autoreconf` is part of
[GNU autoconf](http://www.gnu.org/software/autoconf/). There is no
need to run the `configure` script: `cabal configure` will do this for
you.
When building this package directly from the Git repository, one must run
`autoreconf -i` to generate the `configure` script needed by `cabal
configure`. This requires [Autoconf][5] to be installed.
autoreconf -i
cabal install
There is no need to run the `configure` script manually however, as `cabal
configure` does that automatically.
[1]: https://img.shields.io/hackage/v/directory.svg
[2]: https://hackage.haskell.org/package/directory
[3]: https://travis-ci.org/haskell/directory.svg?branch=master
[4]: https://travis-ci.org/haskell/directory
[5]: https://gnu.org/software/autoconf
......@@ -44,6 +44,7 @@ module System.Directory
, copyFile
, canonicalizePath
, makeAbsolute
, makeRelativeToCurrentDirectory
, findExecutable
, findExecutables
......@@ -736,24 +737,27 @@ copyFile fromFPath toFPath =
ignoreIOExceptions io = io `catchIOError` (\_ -> return ())
-- | Given a path referring to a file or directory, returns a
-- canonicalized path. The intent is that two paths referring
-- to the same file\/directory will map to the same canonicalized
-- path.
-- | Canonicalize the path of an existing file or directory. The intent is
-- that two paths referring to the same file\/directory will map to the same
-- canonicalized path.
--
-- Note that it is impossible to guarantee that the
-- implication (same file\/dir \<=\> same canonicalizedPath) holds
-- in either direction: this function can make only a best-effort
-- attempt.
-- __Note__: if you only require an absolute path, consider using
-- @'makeAbsolute'@ instead, which is more reliable and does not have
-- unspecified behavior on nonexistent paths.
--
-- The precise behaviour is that of the C realpath function
-- GetFullPathNameW on Windows). In particular, the behaviour
-- on paths that do not exist is known to vary from platform
-- to platform. Some platforms do not alter the input, some
-- do, and on some an exception will be thrown.
-- It is impossible to guarantee that the implication (same file\/dir \<=\>
-- same canonicalized path) holds in either direction: this function can make
-- only a best-effort attempt.
--
-- The precise behaviour is that of the POSIX @realpath@ function (or
-- @GetFullPathNameW@ on Windows). In particular, the behaviour on paths that
-- don't exist can vary from platform to platform. Some platforms do not
-- alter the input, some do, and some throw an exception.
--
-- An empty path is considered to be equivalent to the current directory.
--
-- /Known bug(s)/: on Windows, this function does not resolve symbolic links.
--
-- If passed an empty string, behaviour is equivalent to
-- calling canonicalizePath on the current directory.
canonicalizePath :: FilePath -> IO FilePath
canonicalizePath "" = canonicalizePath "."
canonicalizePath fpath =
......@@ -778,6 +782,18 @@ foreign import ccall unsafe "realpath"
-> IO CString
#endif
-- | Make a path absolute by prepending the current directory (if it isn't
-- already absolute) and applying @'normalise'@ to the result.
--
-- The operation may fail with the same exceptions as @'getCurrentDirectory'@.
--
-- /Since: 1.2.2.0/
makeAbsolute :: FilePath -> IO FilePath
makeAbsolute = fmap normalise . absolutize
where absolutize path -- avoid the call to `getCurrentDirectory` if we can
| isRelative path = fmap (</> path) getCurrentDirectory
| otherwise = return path
-- | 'makeRelative' the current directory.
makeRelativeToCurrentDirectory :: FilePath -> IO FilePath
makeRelativeToCurrentDirectory x = do
......
# Changelog for [`directory` package](http://hackage.haskell.org/package/directory)
Changelog for the [`directory`][1] package
==========================================
## 1.2.2.0 *Mar 2015*
## 1.2.2.0 (Mar 2015)
* Bundled with GHC 7.10.1
* make `getModificationTime` support sub-second resolution on windows
* Make `getModificationTime` support sub-second resolution on Windows
* Fix silent failure in `createDirectoryIfMissing`
* Replace `throw` by better defined `throwIO`s
* Avoid stack overflow in `getDirectoryContents` [#17](https://github.com/haskell/directory/pull/17)
* [#17](https://github.com/haskell/directory/pull/17):
Avoid stack overflow in `getDirectoryContents`
* Expose `findExecutables` [#14](https://github.com/haskell/directory/issues/14)
* [#14](https://github.com/haskell/directory/issues/14):
Expose `findExecutables`
* `removeDirectoryRecursive` no longer follows symlinks under any
circumstances, fixing the inconsistency as noted in
[#15](https://github.com/haskell/directory/issues/15)
* [#15](https://github.com/haskell/directory/issues/15):
`removeDirectoryRecursive` no longer follows symlinks under any
circumstances
* Allow trailing path separators in `getPermissions` on Windows
(fixes [#9](https://github.com/haskell/directory/issues/9))
* [#9](https://github.com/haskell/directory/issues/9):
Allow trailing path separators in `getPermissions` on Windows
* `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). See
[pull request #8](https://github.com/haskell/directory/pull/8).
* [#8](https://github.com/haskell/directory/pull/8):
`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
## 1.2.1.0 *Mar 2014*
* Add `makeAbsolute`, which should be preferred over `canonicalizePath`
unless one requires symbolic links to be resolved
## 1.2.1.0 (Mar 2014)
* Bundled with GHC 7.8.1
......@@ -45,3 +51,5 @@
* Fix `findExecutable` to check that file permissions indicate executable
* New convenience functions `findFiles` and `findFilesWith`
[1]: https://hackage.haskell.org/package/directory
......@@ -4,10 +4,11 @@ version: 1.2.2.0
license: BSD3
license-file: LICENSE
maintainer: libraries@haskell.org
bug-reports: http://ghc.haskell.org/trac/ghc/newticket?component=libraries/directory
synopsis: library for directory handling
bug-reports: https://github.com/haskell/directory/issues
synopsis: Platform-agnostic library for filesystem operations
description:
This package provides a library for handling directories.
This library provides a basic set of operations for manipulating files and
directories in a portable way.
category: System
build-type: Configure
cabal-version: >= 1.10
......@@ -72,7 +73,7 @@ Library
build-depends:
base >= 4.5 && < 4.9,
time >= 1.4 && < 1.6,
filepath >= 1.3 && < 1.4
filepath >= 1.3 && < 1.5
if os(windows)
build-depends: Win32 >= 2.2.2 && < 2.4
else
......
......@@ -81,8 +81,6 @@ tryCreateSymbolicLink target link = createSymbolicLink target link
#ifdef mingw32_HOST_OS
`catchIOError` \ e ->
if isPermissionError e
then do
copyPathRecursive (takeDirectory link </> target) link
hPutStrLn stderr "warning: didn't test symlinks due to Group Policy"
then copyPathRecursive (takeDirectory link </> target) link
else ioError e
#endif