directory-ospath-streaming-0.3: Stream directory entries in constant memory in vanilla IO
Copyright(c) Sergey Vinokurov 2024
LicenseApache-2.0 (see LICENSE)
Maintainerserg.foo@gmail.com
Safe HaskellNone
LanguageHaskell2010

System.Directory.OsPath.Streaming.Internal

Description

 
Synopsis

Documentation

data DirStream Source #

Abstract handle to directory contents.

May be closed multiple times and will be automatically closed by GC when it goes out of scope.

Constructors

DirStream 

readDirStream :: DirStream -> IO (Maybe (OsPath, FileType)) Source #

Returns basename path of the directory entry.

readDirStreamFull :: DirStream -> IO (Maybe (OsPath, Basename OsPath, FileType)) Source #

Returns both basename path and full path of a directory entry relative to the passed DirStream root.

For example:

readDirStreamFull =<< openDirStream [osp|.|]
Just ("./bar",Basename {unBasename = "foo"},File Regular)
readDirStreamFull =<< openDirStream [osp|foo/|]
Just ("foo/bar",Basename {unBasename = "foo"},File Regular)
readDirStreamFull =<< openDirStream [osp|/foo/foo|]
Just ("/foo/foo/bar",Basename {unBasename = "foo"},File Regular)

This allows to avoid re-creating the full path on the client side and thus reduce allocations.

closeDirStream :: DirStream -> IO () Source #

Deallocate directory handle. It’s safe to close DirStream multiple times, unlike the underlying OS-specific directory stream handle.