4 ms·
An API for Atomic operations with files. There are APIs in windows apparently. A quick Google search reveals function like CreateDirectoryTransacted, and anoth
by sqeaky 10y ago
An API for Atomic operations with files.
There are APIs in windows apparently. A quick Google search reveals function like CreateDirectoryTransacted, and another quick search reveals that the Kernel leaves this kind of thing up to the filesystem. So on Linux filesystems like ZFA and BTRFS just use the normal posix file APIs and others can optionally provide other functions if they choose to.
So yeah... The whole make a file and rename it thing is dirty hack.
EDIT - Grammar
- poizan42 10y ago> [Microsoft strongly recommends developers utilize alternative means to achieve your application’s needs. Many scenarios that TxF was developed for can be achieved through simpler and more readily available techniques. Furthermore, TxF may not be available in future versions of Microsoft Windows. For more information, and alternatives to TxF, please see Alternatives to using Transactional NTFS.]
- dom0 10y ago> An API for Atomic operations with files. Windows has TxF (used in Windows Update and Installer to tame the eeeenormous complexity a tiny bit; TxF and VSS also use similar mechanisms), but no other mainstream OS has anything remotely close.
- sqeaky 10y agoI don't know how, but I misspelled "ZFS". In ZFS every single file write is atomic. That is kind of close and supported on Linux, Mac OS X and a few Unix flavors.
- dom0 10y agoThat kinda doesn't matter with ZFS or btrfs, though; as real CoW file systems their consistency properties are similar to a fully journaled FS (not only metadata but also data, like ext4 in journal=data mode). In that case you don't need to care anymore as an application developer about file committing patterns, as long as it's only about one file.