Function finish [src]

Combination of flush followed by renameIntoPlace.

Prototype

pub fn finish(af: *AtomicFile) FinishError!void

Parameters

af: *AtomicFile

Possible Errors

AccessDenied WriteError

File descriptor does not hold the required rights to write to it.

AntivirusInterference RenameError

On Windows, antivirus software is enabled by default. It can be disabled, but Windows Update sometimes ignores the user's preference and re-enables it. When enabled, antivirus software on Windows intercepts file system operations and makes them significantly slower in addition to possibly failing with this error code.

BadPathName RenameError
BrokenPipe WriteError
ConnectionResetByPeer WriteError

Connection reset by peer.

DeviceBusy WriteError
DiskQuota WriteError
FileBusy RenameError
FileNotFound RenameError
FileTooBig WriteError
InputOutput WriteError
InvalidArgument WriteError
InvalidUtf8 RenameError

WASI-only; file paths must be valid UTF-8.

InvalidWtf8 RenameError

Windows-only; file paths provided by the user must be valid WTF-8. https://simonsapin.github.io/wtf-8/

IsDir RenameError
LinkQuotaExceeded RenameError
LockViolation WriteError

The process cannot access the file because another process has locked a portion of the file. Windows-only.

MessageTooBig WriteError

The socket type requires that message be sent atomically, and the size of the message to be sent made this impossible. The message is not transmitted.

NameTooLong RenameError
NetworkNotFound RenameError

On Windows, \\server or \\server\share was not found.

NoDevice WriteError

This error occurs when a device gets disconnected before or mid-flush while it's being written to - errno(6): No such device or address.

NoSpaceLeft WriteError
NotDir RenameError
NotOpenForWriting WriteError
OperationAborted WriteError
PathAlreadyExists RenameError
PermissionDenied WriteError
PipeBusy RenameError
ProcessNotFound WriteError

This error occurs in Linux if the process being written to no longer exists.

ReadOnlyFileSystem RenameError
RenameAcrossMountPoints RenameError
SharingViolation RenameError
SymLinkLoop RenameError
SystemResources WriteError
Unexpected UnexpectedError

The Operating System returned an undocumented error code.

This error is in theory not possible, but it would be better to handle this error than to invoke undefined behavior.

When this error code is observed, it usually means the Zig Standard Library needs a small patch to add the error code to the error set for the respective function.

WouldBlock WriteError

This error occurs when no global event loop is configured, and reading from the file descriptor would block.

Source

pub fn finish(af: *AtomicFile) FinishError!void { try af.flush(); try af.renameIntoPlace(); }