whatwg / fs

File System Standard
https://fs.spec.whatwg.org/
Other
224 stars 19 forks source link

Add new locking modes to file handle primitives #151

Open nathanmemmott opened 10 months ago

nathanmemmott commented 10 months ago

Add new locking modes to file handle primitives

Writable file streams and sync access handles can now be created with an optional "mode" parameter.

For sync access handles, "mode" can be "readwrite", "readonly", or "readwrite-unsafe". "readwrite" is the current behavior and the default if "mode" is not specified. Only one sync access handle can be open on a file handle in this mode. The two new modes, "readonly" and "readwrite-unsafe", are shared modes which are added to support multiple readers and writers.

For writable file streams, "mode" can be "exclusive" or "siloed". "siloed" is the current behavior and the default if "mode" is not specified. This mode allows multiple writers to clobber each other. The new "exclusive" mode is added to prevent this clobbering.

For a more detailed explanation, see Multiple Readers and Writers explainer: https://github.com/whatwg/fs/blob/main/proposals/MultipleReadersWriters.md.

(See WHATWG Working Mode: Changes for more details.)


Preview | Diff

nathanmemmott commented 9 months ago

cc @jesup @szewai @annevk Can you take a look at this?