HORIZON HASKELLDocslts/ghc-10.0.x2b276322026-10-31Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 2b27632 · 2026-10-31

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./

Contents
  1. File modes
  2. Setting file modes
  3. Checking file existence and permissions
  4. File status
  5. Obtaining file status
  6. Querying file status
  7. Creation
  8. Hard links
  9. Symbolic links
  10. Renaming files
  11. Changing file ownership
  12. Changing file timestamps
  13. Setting file sizes
  14. Find system-specific limits for a file
Synopsis

File modes

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.

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

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

Querying file status

Creation

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

Symbolic links

Renaming files

Changing file ownership

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

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

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

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.

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.