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

A functional wrapper around a FileStream specific to how the TransactionalFileStructure uses the FileStream.
Inheritance: IDisposable
Datei anzeigen 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.

CreateFile ( string fileName, int ioBlockSize, int fileStructureBlockSize ) : CustomFileStream

Creates a file with the supplied name

Dispose ( ) : void

Releases all the resources used by the CustomFileStream object.

FlushFileBuffers ( ) : void

Flushes any temporary data to the disk. This also calls WindowsAPI function to have the OS flush to the disk.

OpenFile ( string fileName, int ioBlockSize, int &fileStructureBlockSize, bool isReadOnly, bool isSharingEnabled ) : CustomFileStream

Opens a file

Read ( long position, IntPtr locationToCopyData ) : void

Reads an entire page at the provided location. Also computes the checksum information.

ReadRaw ( long position, byte buffer, int length ) : int

Reads data from the disk

Write ( long currentEndOfCommitPosition, MemoryPoolStreamCore stream, long length, bool waitForWriteToDisk ) : void

Writes all of the dirty blocks passed onto the disk subsystem. Also computes the checksum for the data.

WriteRaw ( long position, byte buffer, int length ) : void

Writes data to the disk

Private Methods

Method Description
CustomFileStream ( ) : System

Creates a resource list that everyone shares.

CustomFileStream ( FileStream stream, int ioSize, int fileStructureBlockSize, string fileName, bool isReadOnly, bool isSharingEnabled ) : System

Creates a new CustomFileStream

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

CreateFile() public static method

Creates a file with the supplied name
public static CreateFile ( string fileName, int ioBlockSize, int fileStructureBlockSize ) : CustomFileStream
fileName string the name of the file
ioBlockSize int the number of bytes to do all io with
fileStructureBlockSize int the number of bytes in the file structure so checksums can be properly computed.
return CustomFileStream

Dispose() public method

Releases all the resources used by the CustomFileStream object.
public Dispose ( ) : void
return void

FlushFileBuffers() public method

Flushes any temporary data to the disk. This also calls WindowsAPI function to have the OS flush to the disk.
public FlushFileBuffers ( ) : void
return void

OpenFile() public static method

Opens a file
public static OpenFile ( string fileName, int ioBlockSize, int &fileStructureBlockSize, bool isReadOnly, bool isSharingEnabled ) : CustomFileStream
fileName string the name of the file.
ioBlockSize int the number of bytes to do all of the io
fileStructureBlockSize int The number of bytes in the file structure
isReadOnly bool if the file should be opened in read only
isSharingEnabled bool if the file should be opened with read sharing permissions.
return CustomFileStream

Read() public method

Reads an entire page at the provided location. Also computes the checksum information.
public Read ( long position, IntPtr locationToCopyData ) : void
position long The stream position. May be any position inside the desired block
locationToCopyData System.IntPtr The place where to write the data to.
return void

ReadRaw() public method

Reads data from the disk
public ReadRaw ( long position, byte buffer, int length ) : int
position long The starting position
buffer byte the byte buffer of data to read
length int the number of bytes to read
return int

Write() public method

Writes all of the dirty blocks passed onto the disk subsystem. Also computes the checksum for the data.
public Write ( long currentEndOfCommitPosition, MemoryPoolStreamCore stream, long length, bool waitForWriteToDisk ) : void
currentEndOfCommitPosition long the last valid byte of the file system where this data will be appended to.
stream GSF.IO.Unmanaged.MemoryPoolStreamCore the source of the data to dump to the disk
length long The number by bytes to write to the file system.
waitForWriteToDisk bool True to wait for a complete commit to disk before returning from this function.
return void

WriteRaw() public method

Writes data to the disk
public WriteRaw ( long position, byte buffer, int length ) : void
position long The starting position
buffer byte the byte buffer of data to write
length int the number of bytes to write
return void