Bounded UTF-8 file I/O in Raven.
func Load(path: string, limit: int) -> Result<string, FileReadError> {
let text = File.ReadAllText(path, limit)?
return Ok(text)
}Load propagates a read failure or returns the decoded String. The complete sample creates or replaces neoclr-file-demo.txt in its working directory, reads it back, and checks that an oversized write leaves the previous content intact. Run it in a disposable sample directory.
Behavior and limits.
.NET File names are familiar; explicit byte limits and Result outcomes are different contracts. These are host file operations, not a complete filesystem abstraction. Writes are not transactional or guaranteed atomic, and errors can occur after opening a file.
Detailed contract and comparisons →PROPOSED DIRECTION
Where we’re heading.
The System.Storage namespace leaves room for storage providers. A future Storage model would include StorageItem, File, Directory and storage providers, with Task-based file operations. None of that model is implemented by this namespace rename. A FileSystem capability and separate readable, writable and seekable stream contracts are proposed. They could support testing and virtual namespaces, but require lifetime, scheduling and error policies. Current whole-file helpers do not implement those proposals.
Related proposals and open questions →What would you try?
Bring a small use case, the code you tried and the behavior you expected. Which part of this contract helps, and which part should change?
Share feedback on GitHub ↗