unix-2.8.6.0: POSIX functionality
Copyright(c) The University of Glasgow 2022
LicenseBSD-style (see the file libraries/base/LICENSE)
Maintainerlibraries@haskell.org
Stabilityprovisional
Portabilitynon-portable (requires POSIX)
Safe HaskellSafe-Inferred
LanguageHaskell2010

System.Posix.Directory.Internals

Description

POSIX directory support (internal module, no PVP guarantees)

Synopsis

Documentation

newtype DirStream Source #

Constructors

DirStream (Ptr CDir) 

newtype DirStreamWithPath a Source #

Since: 2.8.6.0

Constructors

DirStreamWithPath (a, Ptr CDir) 

fromDirStreamWithPath :: DirStreamWithPath a -> DirStream Source #

Convert a DirStreamWithPath to a DirStream. Note that the underlying pointer is shared by both values, hence any modification to the resulting DirStream will also modify the original DirStreamWithPath.

Since: 2.8.6.0

toDirStreamWithPath :: a -> DirStream -> DirStreamWithPath a Source #

Construct a DirStreamWithPath from a DirStream. Note that the underlying pointer is shared by both values, hence any modification to the pointer of the resulting DirStreamWithPath will also modify the original DirStream.

Since: 2.8.6.0

newtype DirEnt Source #

Since: 2.8.6.0

Constructors

DirEnt (Ptr CDirent) 

Instances

Instances details
Storable DirEnt Source # 
Instance details

Defined in System.Posix.Directory.Common

dirEntName :: DirEnt -> IO CString Source #

Since: 2.8.6.0

dirEntType :: DirEnt -> IO DirType Source #

Since: 2.8.6.0

newtype DirType Source #

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.

Since: 2.8.6.0

Constructors

DirType CChar 

Bundled Patterns

pattern UnknownType :: DirType

The DirType refers to an entry of unknown type.

pattern NamedPipeType :: DirType

The DirType refers to an entry that is a named pipe.

pattern CharacterDeviceType :: DirType

The DirType refers to an entry that is a character device.

pattern DirectoryType :: DirType

The DirType refers to an entry that is a directory.

pattern BlockDeviceType :: DirType

The DirType refers to an entry that is a block device.

pattern RegularFileType :: DirType

The DirType refers to an entry that is a regular file.

pattern SymbolicLinkType :: DirType

The DirType refers to an entry that is a symbolic link.

pattern SocketType :: DirType

The DirType refers to an entry that is a socket.

pattern WhiteoutType :: DirType

The DirType refers to an entry that is a whiteout.

Instances

Instances details
Show DirType Source # 
Instance details

Defined in System.Posix.Directory.Common

Eq DirType Source # 
Instance details

Defined in System.Posix.Directory.Common

Methods

(==) :: DirType -> DirType -> Bool #

(/=) :: DirType -> DirType -> Bool #

Ord DirType Source # 
Instance details

Defined in System.Posix.Directory.Common

isUnknownType :: DirType -> Bool Source #

Checks if this DirType refers to an entry of unknown type.

Since: 2.8.6.0

isNamedPipeType :: DirType -> Bool Source #

Checks if this DirType refers to a named pipe entry.

Since: 2.8.6.0

isCharacterDeviceType :: DirType -> Bool Source #

Checks if this DirType refers to a character device entry.

Since: 2.8.6.0

isDirectoryType :: DirType -> Bool Source #

Checks if this DirType refers to a directory entry.

Since: 2.8.6.0

isBlockDeviceType :: DirType -> Bool Source #

Checks if this DirType refers to a block device entry.

Since: 2.8.6.0

isRegularFileType :: DirType -> Bool Source #

Checks if this DirType refers to a regular file entry.

Since: 2.8.6.0

isSymbolicLinkType :: DirType -> Bool Source #

Checks if this DirType refers to a symbolic link entry.

Since: 2.8.6.0

isSocketType :: DirType -> Bool Source #

Checks if this DirType refers to a socket entry.

Since: 2.8.6.0

isWhiteoutType :: DirType -> Bool Source #

Checks if this DirType refers to a whiteout entry.

Since: 2.8.6.0

readDirStreamWith :: (DirEnt -> IO a) -> DirStream -> IO (Maybe a) Source #

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!

Since: 2.8.6.0

readDirStreamWithPtr :: Ptr DirEnt -> (DirEnt -> IO a) -> DirStream -> IO (Maybe a) Source #

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.

Since: 2.8.6.0