NanoByte.Common
Public Member Functions | Properties | List of all members
NanoByte.Common.Storage.AtomicWrite Class Reference

Provides a temporary path to write to and atomically inserts it at the destination location on disposal (if Commit was called). More...

Inheritance diagram for NanoByte.Common.Storage.AtomicWrite:

Public Member Functions

 AtomicWrite ([Localizable(false)] string path)
 Prepares an atomic write operation. More...
 
void Commit ()
 Allows the new file to be deployed upon Dispose. More...
 
void Dispose ()
 Replaces DestinationPath with the contents of WritePath. More...
 

Properties

string DestinationPath [get]
 The file path of the final destination. More...
 
string WritePath [get]
 The temporary file path to write to. More...
 
bool IsCommitted [get]
 true if Commit has been called. More...
 

Detailed Description

Provides a temporary path to write to and atomically inserts it at the destination location on disposal (if Commit was called).

using (var atomic = new AtomicWrite(filePath))
{
File.WriteAllBytes(atomic.WritePath, fileData);
atomic.Commit();
}
See also
AtomicRead

Constructor & Destructor Documentation

◆ AtomicWrite()

NanoByte.Common.Storage.AtomicWrite.AtomicWrite ( [Localizable(false)] string  path)
inline

Prepares an atomic write operation.

Parameters
pathThe file path of the final destination.

Member Function Documentation

◆ Commit()

void NanoByte.Common.Storage.AtomicWrite.Commit ( )

Allows the new file to be deployed upon Dispose.

◆ Dispose()

void NanoByte.Common.Storage.AtomicWrite.Dispose ( )
inline

Replaces DestinationPath with the contents of WritePath.

Property Documentation

◆ DestinationPath

string NanoByte.Common.Storage.AtomicWrite.DestinationPath
get

The file path of the final destination.

◆ IsCommitted

bool NanoByte.Common.Storage.AtomicWrite.IsCommitted
get

true if Commit has been called.

◆ WritePath

string NanoByte.Common.Storage.AtomicWrite.WritePath
get

The temporary file path to write to.


The documentation for this class was generated from the following file:
NanoByte.Common.Storage.AtomicWrite.AtomicWrite
AtomicWrite([Localizable(false)] string path)
Prepares an atomic write operation.
Definition: AtomicWrite.cs:44