Class DurableFileWriter
Prevents partial write (e.g. power cut)
by writing to a temporary file first.
As a final step the following options are supported:
- Replacement with taking a backup:
It replaces the target file with the temp file using
OS Replace API.
Replace method also does a backup of the target file first.
If the file is corrupted the backup file
contains the latest content prior to the crash.
https://source.dot.net/#System.Private.CoreLib/FileSystem.Unix.cs
See more details: https://github.com/dotnet/runtime/issues/18034
- Replacement with ReplaceAPI but without a backup:
Renaming a file in the same volume is atomic operation.
In this mode Replace call uses
Interop.Sys.Rename(sourceFullPath, destFullPath)
internally.
Inheritance
DurableFileWriter
Assembly: ZoneTree.dll
Syntax
public sealed class DurableFileWriter
Constructors
|
Improve this Doc
View Source
DurableFileWriter(IFileStreamProvider)
Declaration
public DurableFileWriter(IFileStreamProvider fileStreamProvider)
Parameters
Methods
|
Improve this Doc
View Source
ReadAllBytes(string)
Declaration
public byte[] ReadAllBytes(string file)
Parameters
Type |
Name |
Description |
string |
file |
|
Returns
|
Improve this Doc
View Source
ReadAllBytesFromBackup(string)
Declaration
public byte[] ReadAllBytesFromBackup(string path)
Parameters
Type |
Name |
Description |
string |
path |
|
Returns
|
Improve this Doc
View Source
ReadAllText(string)
Declaration
public string ReadAllText(string file)
Parameters
Type |
Name |
Description |
string |
file |
|
Returns
|
Improve this Doc
View Source
ReadAllTextFromBackup(string)
Declaration
public string ReadAllTextFromBackup(string path)
Parameters
Type |
Name |
Description |
string |
path |
|
Returns
|
Improve this Doc
View Source
WriteAllBytes(string, byte[])
Declaration
public void WriteAllBytes(string path, byte[] bytes)
Parameters
|
Improve this Doc
View Source
WriteAllBytesWithBackup(string, byte[])
Declaration
public void WriteAllBytesWithBackup(string path, byte[] bytes)
Parameters
|
Improve this Doc
View Source
WriteAllText(string, string)
Declaration
public void WriteAllText(string path, string text)
Parameters
|
Improve this Doc
View Source
WriteAllTextWithBackup(string, string)
Declaration
public void WriteAllTextWithBackup(string path, string text)
Parameters