C# Class GSF.IO.FileStructure.Media.DiskMedium

Provides read/write access to all of the different types of disk types to use to store the file structure.
Inheritance: IDisposable
Mostra file Open project: GridProtectionAlliance/openHistorian Class Usage Examples

Public Methods

Method Description
ChangeExtension ( string extension, bool isReadOnly, bool isSharingEnabled ) : void

Changes the extension of the current file.

ChangeShareMode ( bool isReadOnly, bool isSharingEnabled ) : void

Reopens the file with different permissions.

CommitChanges ( FileHeaderBlock header ) : void

Occurs when committing the following data to the disk. This will copy any pending data to the disk in a manner that will protect against corruption.

CreateFile ( CustomFileStream stream, MemoryPool pool, int fileStructureBlockSize ) : DiskMedium

Creates a DiskMedium from a stream. This will initialize the stream as an empty file structure.

This will not check if the file is truely a new file. If calling this with an existing archive file, it will overwrite the table of contents, corrupting the file.

CreateIoSession ( ) : BinaryStreamIoSessionBase

Creates a BinaryStreamIoSessionBase that can be used to read from this disk medium.

CreateMemoryFile ( MemoryPool pool, int fileStructureBlockSize ) : DiskMedium

Creates a DiskMedium that is entirely based in memory.

Dispose ( ) : void

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

OpenFile ( CustomFileStream stream, MemoryPool pool, int fileStructureBlockSize ) : DiskMedium

Creates a DiskMedium from a stream. This will read the existing header from the stream.

RollbackChanges ( ) : void

Occurs when rolling back a transaction. This will free up any temporary space allocated for the change.

Private Methods

Method Description
DiskMedium ( IDiskMediumCoreFunctions disk, FileHeaderBlock header ) : System

Class is created through static methods of this class.

Method Details

ChangeExtension() public method

Changes the extension of the current file.
public ChangeExtension ( string extension, bool isReadOnly, bool isSharingEnabled ) : void
extension string the new extension
isReadOnly bool If the file should be reopened as readonly
isSharingEnabled bool If the file should share read privileges.
return void

ChangeShareMode() public method

Reopens the file with different permissions.
public ChangeShareMode ( bool isReadOnly, bool isSharingEnabled ) : void
isReadOnly bool If the file should be reopened as readonly
isSharingEnabled bool If the file should share read privileges.
return void

CommitChanges() public method

Occurs when committing the following data to the disk. This will copy any pending data to the disk in a manner that will protect against corruption.
public CommitChanges ( FileHeaderBlock header ) : void
header FileHeaderBlock
return void

CreateFile() public static method

Creates a DiskMedium from a stream. This will initialize the stream as an empty file structure.
This will not check if the file is truely a new file. If calling this with an existing archive file, it will overwrite the table of contents, corrupting the file.
public static CreateFile ( CustomFileStream stream, MemoryPool pool, int fileStructureBlockSize ) : DiskMedium
stream CustomFileStream An open to use. The /// will assume ownership of this .
pool GSF.IO.Unmanaged.MemoryPool the to allocate data from
fileStructureBlockSize int the block size of the file structure. Usually 4kb.
return DiskMedium

CreateIoSession() public method

Creates a BinaryStreamIoSessionBase that can be used to read from this disk medium.
public CreateIoSession ( ) : BinaryStreamIoSessionBase
return GSF.IO.Unmanaged.BinaryStreamIoSessionBase

CreateMemoryFile() public static method

Creates a DiskMedium that is entirely based in memory.
public static CreateMemoryFile ( MemoryPool pool, int fileStructureBlockSize ) : DiskMedium
pool GSF.IO.Unmanaged.MemoryPool the to allocate data from
fileStructureBlockSize int the block size of the file structure. Usually 4kb.
return DiskMedium

Dispose() public method

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public Dispose ( ) : void
return void

OpenFile() public static method

Creates a DiskMedium from a stream. This will read the existing header from the stream.
public static OpenFile ( CustomFileStream stream, MemoryPool pool, int fileStructureBlockSize ) : DiskMedium
stream CustomFileStream An open to use. The /// will assume ownership of this .
pool GSF.IO.Unmanaged.MemoryPool The to allocate data from.
fileStructureBlockSize int the block size of the file structure. Usually 4kb.
return DiskMedium

RollbackChanges() public method

Occurs when rolling back a transaction. This will free up any temporary space allocated for the change.
public RollbackChanges ( ) : void
return void