Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- setModificationTime :: FilePath -> UTCTime -> IO ()
- createFileLink :: FilePath -> FilePath -> IO ()
- pathIsSymbolicLink :: FilePath -> IO Bool
- getSymbolicLinkTarget :: FilePath -> IO FilePath
Documentation
setModificationTime :: FilePath -> UTCTime -> IO () #
Change the time at which the file or directory was last modified.
The operation may fail with:
isPermissionError
if the user is not permitted to alter the modification time; orisDoesNotExistError
if the file or directory does not exist.
Some caveats for POSIX systems:
- Not all systems support
utimensat
, in which case the function can only emulate the behavior by reading the access time and then setting both the access and modification times together. On systems whereutimensat
is supported, the modification time is set atomically with nanosecond precision. - If compiled against a version of
unix
prior to2.7.0.0
, the function would not be able to set timestamps with sub-second resolution. In this case, there would also be loss of precision in the access time.
Since: directory-1.2.3.0
Create a file symbolic link. The target path can be either absolute or relative and need not refer to an existing file. The order of arguments follows the POSIX convention.
To remove an existing file symbolic link, use removeFile
.
Although the distinction between file symbolic links and directory symbolic links does not exist on POSIX systems, on Windows this is an intrinsic property of every symbolic link and cannot be changed without recreating the link. A file symbolic link that actually points to a directory will fail to dereference and vice versa. Moreover, creating symbolic links on Windows may require privileges unavailable to users outside the Administrators group. Portable programs that use symbolic links should take both into consideration.
On Windows, the function is implemented using CreateSymbolicLink
. Since
1.3.3.0, the SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE
flag is included
if supported by the operating system. On POSIX, the function uses symlink
and is therefore atomic.
Windows-specific errors: This operation may fail with permissionErrorType
if the user lacks the privileges to create symbolic links. It may also
fail with illegalOperationErrorType
if the file system does not support
symbolic links.
Since: directory-1.3.1.0
pathIsSymbolicLink :: FilePath -> IO Bool #
Check whether an existing path
is a symbolic link. If path
is a
regular file or directory, False
is returned. If path
does not exist
or is otherwise inaccessible, an exception is thrown (see below).
On Windows, this checks for FILE_ATTRIBUTE_REPARSE_POINT
. In addition to
symbolic links, the function also returns true on junction points. On
POSIX systems, this checks for S_IFLNK
.
The operation may fail with:
isDoesNotExistError
if the symbolic link does not exist; orisPermissionError
if the user is not permitted to read the symbolic link.
Since: directory-1.3.0.0
getSymbolicLinkTarget :: FilePath -> IO FilePath #
Retrieve the target path of either a file or directory symbolic link. The returned path may not be absolute, may not exist, and may not even be a valid path.
On Windows systems, this calls DeviceIoControl
with
FSCTL_GET_REPARSE_POINT
. In addition to symbolic links, the function
also works on junction points. On POSIX systems, this calls readlink
.
Windows-specific errors: This operation may fail with
illegalOperationErrorType
if the file system does not support symbolic
links.
Since: directory-1.3.1.0