DirectoryReader
classin packageklyn.io
public class DirectoryReader implements AutoClosable
DirectoryReader
All Implemented Interfaces: AutoClosable

Streaming directory enumeration cursor.

Reads a directory in bounded batches without materializing the entire directory listing at once or populating global path-type caches. On Windows, directory enumeration supplies entry types and file sizes directly; on POSIX, directory entry types (d_type) classify subdirectories and regular files without extra system calls unless includeFileBytes or followSymlinks requires metadata resolution.

Always close the reader when finished, preferably with try reader = folder.openReader():.

import klyn.io

try reader = Path.cwd.openReader():
    exhausted = false
    while not exhausted:
        batch = reader.read(256)
        for name in batch.fileNames:
            print(name)
        exhausted = batch.exhausted
Constructors
Modifier and Type Member Description
public DirectoryReader
DirectoryReader( folder as FolderPath, includeFileNames as Boolean = true, includeFileBytes as Boolean = false, followSymlinks as Boolean = false ) throws IOException
Opens a streaming cursor on a directory.
Methods
Modifier and Type Member Description
public close
close() as Void
Releases the underlying OS directory handle.
public read
read(maximum as Int = 256) as DirectoryBatch throws IOException
Reads up to maximum directory entries (1..4096).
Inherited Methods
methodInherited Methods from AutoClosable: close