FilesModule

PackageAxial.Files

Summary

NameSignatureSynopsis
Operations
writeAtomicFiles.writeAtomic path contentsWrites bytes to a sibling temporary file, flushes them to disk, then replaces the destination by rename.
cleanupStaleTempsFiles.cleanupStaleTemps path ageDeletes sibling atomic-write temporary files older than age for the target path.
writeAllTextAtomicFiles.writeAllTextAtomic path contentsEncodes text as UTF-8 and atomically replaces a file.
writeAllTextAtomicWithEncodingFiles.writeAllTextAtomicWithEncoding path contents encodingEncodes text with the supplied encoding and atomically replaces a file.
watchFiles.watch recursive pathWatches a directory (optionally recursively) or one file until consumption ends.
walkFiles.walk descend rootWalks the children of root breadth-first.
readerFiles.reader pathOpens a BOM-aware text reader, or None if the first 8192 bytes contain a NUL (except UTF-16 with a BOM).
linesFiles.lines pathStreams text in 2048-line batches.

Operations

kind:member

writeAtomic

Files.writeAtomic path contents
Member
Writes bytes to a sibling temporary file, flushes them to disk, then replaces the destination by rename.

Parameters

NameTypeDescription
pathstring
contentsbyte array

Returns

Flow<'env, FileSystemError, unit>
kind:member

cleanupStaleTemps

Files.cleanupStaleTemps path age
Member
Deletes sibling atomic-write temporary files older than age for the target path.

Parameters

NameTypeDescription
pathstring
ageTimeSpan

Returns

Flow<'env, FileSystemError, unit>
kind:member

writeAllTextAtomic

Files.writeAllTextAtomic path contents
Member
Encodes text as UTF-8 and atomically replaces a file.

Parameters

NameTypeDescription
pathstring
contentsstring

Returns

Flow<'env, FileSystemError, unit>
kind:member

writeAllTextAtomicWithEncoding

Files.writeAllTextAtomicWithEncoding path contents encoding
Member
Encodes text with the supplied encoding and atomically replaces a file.

Parameters

NameTypeDescription
pathstring
contentsstring
encodingEncoding

Returns

Flow<'env, FileSystemError, unit>
kind:member

watch

Files.watch recursive path
Member
Watches a directory (optionally recursively) or one file until consumption ends.

Parameters

NameTypeDescription
recursivebool
pathstring

Returns

FlowStream<'env, FileSystemError, FileSystemChange>
kind:member

walk

Files.walk descend root
Member
Walks the children of root breadth-first. Directories are listed only when pulled and permitted by descend.

Parameters

NameTypeDescription
descendstring -> bool
rootstring

Returns

FlowStream<'env, FileSystemError, FileSystemEntry>
kind:member

reader

Files.reader path
Member
Opens a BOM-aware text reader, or None if the first 8192 bytes contain a NUL (except UTF-16 with a BOM).

Parameters

NameTypeDescription
pathstring

Returns

Resource<'env, FileSystemError, TextReader option>
kind:member

lines

Files.lines path
Member
Streams text in 2048-line batches. Binary files produce no lines; stopping early closes the reader.

Parameters

NameTypeDescription
pathstring

Returns

FlowStream<'env, FileSystemError, string>