C# Class Journaler.FileBlockWriter

Inheritance: IBlockWriter
Mostrar archivo Open project: odeheurles/Journaler-net

Public Methods

Method Description
Dispose ( ) : void

Dispose the instance

FileBlockWriter ( string path, int blockSizeInBytes ) : System

Create a new FileBlockWriter

SetSize ( int blocksCount ) : void

Pre-allocates the file on disk with the given size. This improves speed compared to a fragmented file.

Write ( byte block, bool moveToNextBlock ) : void

Write a block to disk and move to next block if specified

Private Methods

Method Description
CreateFile ( String fileName, int desiredAccess, FileShare shareMode, IntPtr securityAttrs, FileMode creationDisposition, int flagsAndAttributes, IntPtr templateFile ) : SafeFileHandle
GetDiskFreeSpace ( string path, uint &sectorsPerCluster, uint &bytesPerSector, uint &numberOfFreeClusters, uint &totalNumberOfClusters ) : bool
GetDriveSectorSize ( string path ) : uint

Return the sector size of the volume the specified filepath lives on.

OpenStream ( string path, FileMode mode, FileAccess acc, FileShare share, bool sequential, bool useAsync, int blockSize ) : FileStream

Method Details

Dispose() public method

Dispose the instance
public Dispose ( ) : void
return void

FileBlockWriter() public method

Create a new FileBlockWriter
If blockSizeInBytes is smaller or equal to 0. if path is null or empty or if blockSize is not a multiple of the disk sector size.
public FileBlockWriter ( string path, int blockSizeInBytes ) : System
path string full path of the new file.
blockSizeInBytes int size of the blocks in bytes
return System

SetSize() public method

Pre-allocates the file on disk with the given size. This improves speed compared to a fragmented file.
public SetSize ( int blocksCount ) : void
blocksCount int Size of the files in number of blocks (size of the file is blockCount * blockSize)
return void

Write() public method

Write a block to disk and move to next block if specified
public Write ( byte block, bool moveToNextBlock ) : void
block byte The block to write to disk
moveToNextBlock bool True to move to the next block, False otherwise.
return void