klyn.io.FolderPath.openReader
method
public openReader(
includeFileNames as Boolean = true,
includeFileBytes as Boolean = false,
followSymlinks as Boolean = false
) as DirectoryReader throws IOException
Description

Opens a streaming cursor over this directory.

Unlike listNames() or list(), openReader(...) enumerates entries in bounded batches and separates subdirectories from regular files directly from OS directory metadata without materializing the full directory at once.

Parameters
ParameterDescription
includeFileNamesRetain regular file names in DirectoryBatch.fileNames.
includeFileBytesAccumulate logical file sizes in DirectoryBatch.bytes.
followSymlinksFollow symbolic links instead of counting them as skipped.
Returns

An open DirectoryReader cursor to use with try reader = folder.openReader():.

Throws
  • IOException If the directory does not exist or cannot be enumerated.
Example
import klyn.io

try reader = Path.cwd.openReader():
    batch = reader.read(256)
    print(batch.folders.size)
    print(batch.fileNames.size)