HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Moduleunix-compat-0.7.4.1Haskell2010

System.PosixCompat.Files

This module makes the operations exported by System.Posix.Files available on all platforms. On POSIX systems it re-exports operations from System.Posix.Files. On other platforms it emulates the operations as far as possible.

/NOTE: the portable implementations are not well tested, in some cases functions are only stubs./

  • 2 types
  • 64 values

File modes

19 declarations

Setting file modes

valuesetFileMode :: FilePath -> FileMode -> IO ()
#

setFileMode path mode changes permission of the file given by path to mode. This operation may fail with throwErrnoPathIfMinus1_ if path doesn't exist or if the effective user ID of the current process is not that of the file's owner.

Note: calls chmod.

valuesetFdMode :: Fd -> FileMode -> IO ()
#

setFdMode fd mode acts like setFileMode but uses a file descriptor fd instead of a FilePath.

Note: calls fchmod.

setFileCreationMask mode sets the file mode creation mask to mode. Modes set by this operation are subtracted from files and directories upon creation. The previous file creation mask is returned.

Note: calls umask.

Checking file existence and permissions

valuefileAccess :: FilePath -> Bool -> Bool -> Bool -> IO Bool
#

fileAccess name read write exec checks if the file (or other file system object) name can be accessed for reading, writing and/or executing. To check a permission set the corresponding argument to True.

Note: calls access.

File status

1 declaration
newtypenewtype FileStatus
#

POSIX defines operations to get information, such as owner, permissions, size and access times, about a file. This information is represented by the FileStatus type.

Note: see chmod.

Limitations: Support for high resolution timestamps is filesystem dependent:

  • HFS+ volumes on OS X only support whole-second times.

Obtaining file status

getFileStatus path calls gets the FileStatus information (user ID, size, access times, etc.) for the file path.

Note: calls stat.

valuegetFdStatus :: Fd -> IO FileStatus
#

getFdStatus fd acts as getFileStatus but uses a file descriptor fd.

Note: calls fstat.

Querying file status

Size of the file in bytes. If this file is a symbolic link the size is the length of the pathname it contains.

Time of last status change (i.e. owner, group, link count, mode, etc.) in sub-second resolution. Depends on the timestamp resolution of the underlying filesystem.

Creation

2 declarations
valuecreateNamedPipe :: FilePath -> FileMode -> IO ()
#

createNamedPipe fifo mode creates a new named pipe, fifo, with permissions based on mode. May fail with throwErrnoPathIfMinus1_ if a file named name already exists or if the effective user ID of the current process doesn't have permission to create the pipe.

Note: calls mkfifo.

Hard links

2 declarations

Symbolic links

2 declarations

Renaming files

1 declaration
valuerename :: FilePath -> FilePath -> IO ()
#

rename old new renames a file or directory from old to new.

Note: calls rename.

Changing file ownership

3 declarations
valuesetOwnerAndGroup :: FilePath -> UserID -> GroupID -> IO ()
#

setOwnerAndGroup path uid gid changes the owner and group of path to uid and gid, respectively.

If uid or gid is specified as -1, then that ID is not changed.

Note: calls chown.

Changing file timestamps

2 declarations
valuesetFileTimes :: FilePath -> EpochTime -> EpochTime -> IO ()
#

setFileTimes path atime mtime sets the access and modification times associated with file path to atime and mtime, respectively.

Note: calls utime.

valuetouchFile :: FilePath -> IO ()
#

touchFile path sets the access and modification times associated with file path to the current time.

Note: calls utime.

Setting file sizes

2 declarations
valuesetFileSize :: FilePath -> FileOffset -> IO ()
#

Truncates the file down to the specified length. If the file was larger than the given length before this operation was performed the extra is lost.

Note: calls truncate.

Find system-specific limits for a file

3 declarations
valuegetPathVar :: FilePath -> PathVar -> IO Limit
#

getPathVar var path obtains the dynamic value of the requested configurable file limit or option associated with file or directory path. For defined file limits, getPathVar returns the associated value. For defined file options, the result of getPathVar is undefined, but not failure.

Note: calls pathconf.

valuegetFdPathVar :: Fd -> PathVar -> IO Limit
#

getFdPathVar var fd obtains the dynamic value of the requested configurable file limit or option associated with the file or directory attached to the open channel fd. For defined file limits, getFdPathVar returns the associated value. For defined file options, the result of getFdPathVar is undefined, but not failure.

Note: calls fpathconf.