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-2.8.7.0Haskell2010

System.Posix.Directory.Internals

POSIX directory support (internal module, no PVP guarantees)

  • 7 types
  • 16 values
  • Packageunix-2.8.7.0
  • Exports32
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceInternals.hsc
newtypenewtype DirType
#

The value of the d_type field of a dirent struct. Note that the possible values of that type depend on the filesystem that is queried. From readdir(3):

Currently, only some filesystems (among them: Btrfs, ext2, ext3, and ext4)
have full support for returning the file type in d_type. All applications
must properly handle a return of DT_UNKNOWN.

For example, JFS is a filesystem that does not support d_type; See https://github.com/haskell/ghcup-hs/issues/766

Furthermore, dirent or the constants represented by the associated pattern synonyms of this type may not be provided by the underlying platform. In that case none of those patterns will match and the application must handle that case accordingly.

Constructors

Instances3Eq, Ord, Show
  • Eq DirTypeDefined in unix-2.8.7.0 · System.Posix.Directory.Common
  • Ord DirTypeDefined in unix-2.8.7.0 · System.Posix.Directory.Common
  • Show DirTypeDefined in unix-2.8.7.0 · System.Posix.Directory.Common
valuereadDirStreamWith :: (DirEnt -> IO a) -> DirStream -> IO (Maybe a)
#

readDirStreamWith f dp calls readdir to obtain the next directory entry (struct dirent) for the open directory stream dp. If an entry is read, it passes the pointer to that structure to the provided function f for processing. It returns the result of that function call wrapped in a Just if an entry was read and Nothing if the end of the directory stream was reached.

NOTE: The lifetime of the pointer wrapped in the DirEnt is limited to invocation of the callback and it will be freed automatically after. Do not pass it to the outside world!

A version of readDirStreamWith that takes a pre-allocated pointer in addition to the other arguments. This pointer is used to store the pointer to the next directory entry, if there is any. This function is intended for use cases where you need to read a lot of directory entries and want to reuse the pointer for each of them. Using for example readDirStream or readDirStreamWith in this scenario would allocate a new pointer for each call of these functions.

NOTE: You are responsible for releasing the pointer after you are done.