No documented Win32 or native user-mode sequence establishes the requested standard-user guarantee that an NTFS replacement or newly created directory name binding will survive an operating-system crash or sudden power loss.
1. Directory flushing from user mode
The filesystem protocol specification defines the required underlying operation: flushing an open DirectoryFile flushes its filesystem metadata, ensures the directory structure is persisted to stable storage, and flushes the underlying physical storage. The Windows product-behavior appendix says this behavior is implemented by NTFS ^1^ ^2^.
The available API contracts do not, however, document how an ordinary application can issue that operation successfully on a directory:
-
FlushFileBuffersrequires a handle withGENERIC_WRITE. Its documented volume-wide form requires administrative privileges ^3^. - A directory handle can be obtained with
CreateFileWandFILE_FLAG_BACKUP_SEMANTICS, but the directory-handle documentation does not listFlushFileBuffersamong the supported consumers of that handle ^4^. -
NtFlushBuffersFileEx(FileHandle, 0, NULL, 0, ...)is documented to flush file data and metadata and synchronize underlying storage. It supports NTFS and has a minimum client of Windows 8, but its documented error contract requires write or append access ^5^. -
NtCreateFileexplicitly says not to requestFILE_WRITE_DATAorFILE_APPEND_DATAfor a directory; generic access rights likewise cannot be specified for a directory ^6^.
Consequently, the documentation does not supply a reconcilable required access mask, create options, or sharing mode for a supported directory-flush call. Although NtFlushBuffersFileEx describes the filesystem operation and the protocol describes its directory effect, that is insufficient to define the requested application-level contract. Observed success with a particular access combination or Windows build would not fill this contractual gap.
2. Replacement publication
MoveFileExW with:
MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH
performs replacement when ACL requirements are met. However, the specific documented write-through guarantee says that a move performed as copy-and-delete is flushed at the end of the copy operation ^7^.
That wording does not explicitly guarantee persistence of the destination directory entry for a same-volume NTFS rename/replacement after a crash. It therefore should not be used as the contractual basis for the stronger namespace-durability acceptance requirement.
This distinction remains:
- Publication/atomicity: consumers should not observe a partially written JSON payload when a completed temporary file is published by replacement.
- Crash durability: the public contract does not establish that the new destination binding must be the binding recovered after every crash or power interruption.
Flushing the temporary file first remains necessary for its contents. Windows documents that file metadata is cached and can be forced out by flushing the file, but this does not document flushing the separate parent-directory namespace change ^8^.
ReplaceFileW does not close the gap: its nominal REPLACEFILE_WRITE_THROUGH flag is explicitly documented as unsupported ^9^.
3. First-time Profile\workspaces creation
Creating workspaces adds an entry to the parent directory’s directory-entry table ^10^. The protocol-level operation that would persist that structure is a flush of the open parent Profile directory.
The public API documentation does not expose a supported standard-user sequence for performing that parent-directory flush, so it also does not establish:
- a durable first-time-directory-creation guarantee;
- an exact parent-directory access mask;
- whether additional ancestor flushes are required.
No further-ancestor rule should be inferred without an explicit contract.
4. Failure boundaries
Even a documented flush depends on the complete storage stack honoring it:
- Filesystem and filter drivers that maintain internal buffers must handle flush requests to preserve data or metadata across shutdowns ^11^.
- Storage devices can have volatile write-back caches. Some do not support cache synchronization or write-through, and power failure can lose cached data when no battery-backed protection exists ^12^.
- NTFS logging restores filesystem consistency after a system failure; that does not independently promise which unconfirmed application namespace update will be recovered ^13^.
Filesystem filters, storage drivers, controller firmware, device cache behavior, and physical power-loss protection therefore remain part of the acceptance boundary. No Windows file API can compensate for hardware or firmware that falsely acknowledges durable completion.
5. Supported design alternatives
For the current JSON design:
- Continue writing a complete temporary file in the destination directory.
- Flush the temporary file before publication.
- Replace the destination on the same volume.
- Include a revision and integrity check in every record.
- On startup, validate the published record and recover from retained previous, backup, or journal records.
- Treat an absent, old, or invalid record as an explicit recovery state rather than assuming the last successful call survived.
Microsoft recommends the write-new-file-then-replace approach for atomic updates to a single document-like file, while discouraging new dependencies on Transactional NTFS because TxF may not remain available ^14^.
If the acceptance requirement needs a documented durable commit and crash recovery rather than recoverable file publication, use ESE. ESE provides ACID transactions and crash recovery; durability can be waived only through optional lazy-commit behavior ^15^ ^16^.
For a formal guarantee covering a specific Windows build range, filter stack, and storage configuration beyond these public contracts, obtain a written determination through Microsoft Developer Support.
References
- [IP Address] Server Requests Flushing Cached Data
- 5 Appendix A: Product Behavior
- FlushFileBuffers function (fileapi.h)
- Directory Handles
- NtFlushBuffersFileEx function (ntifs.h)
- NtCreateFile function (ntifs.h)
- MoveFileExW function (winbase.h)
- File Caching
- ReplaceFileW function (winbase.h)
- About Directory Management
- DispatchFlushBuffers Routines
- Querying for the Write Cache Property
- NTFS overview
- Alternatives to using Transactional NTFS
- Extensible Storage Engine
- Transactions (Windows Events)