C# 클래스 MongoDB.GridFS.GridFileStream

Stream for reading and writing to a file in GridFS.
When using the stream for random io it is possible to produce chunks in the begining and middle of the file that are not full size followed by other chunks that are full size. This only affects the md5 sum that is calculated on the file on close. Because of this do not rely on the md5 sum of a file when doing random io. Writing to the stream sequentially works fine and will produce a consistent md5.
상속: Stream
파일 보기 프로젝트 열기: sdether/mongodb-csharp 1 사용 예제들

공개 메소드들

메소드 설명
Close ( ) : void

Close the stream and flush any changes to the database.

Flush ( ) : void

Flushes any changes to current chunk to the database. It can be called in client code at any time or it will automatically be called on Close() and when the stream position moves off the bounds of the current chunk.

GridFileStream ( GridFileInfo gridfileinfo, IMongoCollection files, IMongoCollection chunks, FileAccess access ) : System
Read ( byte array, int offset, int count ) : int

Reads data from the stream into the specified array. It will fill the array in starting at offset and adding count bytes returning the number of bytes read from the stream.

Seek ( long offset, SeekOrigin origin ) : long

Seek to any location in the stream. Seeking past the end of the file is allowed. Any writes to that location will cause the file to grow to that size. Any holes that may be created from the seek will be zero filled on close.

SetLength ( long value ) : void

Sets the length of this stream to the given value.

Write ( byte array, int offset, int count ) : void

Copies from the source array into the grid file.

보호된 메소드들

메소드 설명
Dispose ( bool disposing ) : void

비공개 메소드들

메소드 설명
CalcChunkNum ( long position ) : int
EnsureNoHoles ( ) : void

Makes sure that at least a skelton chunk exists for all numbers. If not the MD5 calculation will fail on a sparse file.

LoadOrCreateChunk ( int num ) : void

Loads a chunk from the chunks collection if it exists. Otherwise it creates a blank chunk Document.

MoveTo ( long position ) : void

Moves the current position to the new position. If this causes a new chunk to need to be loaded it will take care of flushing the buffer and loading a new chunk.

TruncateAfter ( long value ) : void

Deletes all chunks after the specified position and clears out any extra bytes if the position doesn't fall on a chunk boundry.

ValidateReadState ( byte array, int offset, int count ) : void
ValidateWriteState ( byte array, int offset, int count ) : void

메소드 상세

Close() 공개 메소드

Close the stream and flush any changes to the database.
public Close ( ) : void
리턴 void

Dispose() 보호된 메소드

protected Dispose ( bool disposing ) : void
disposing bool
리턴 void

Flush() 공개 메소드

Flushes any changes to current chunk to the database. It can be called in client code at any time or it will automatically be called on Close() and when the stream position moves off the bounds of the current chunk.
public Flush ( ) : void
리턴 void

GridFileStream() 공개 메소드

public GridFileStream ( GridFileInfo gridfileinfo, IMongoCollection files, IMongoCollection chunks, FileAccess access ) : System
gridfileinfo GridFileInfo
files IMongoCollection
chunks IMongoCollection
access FileAccess
리턴 System

Read() 공개 메소드

Reads data from the stream into the specified array. It will fill the array in starting at offset and adding count bytes returning the number of bytes read from the stream.
public Read ( byte array, int offset, int count ) : int
array byte
offset int
count int
리턴 int

Seek() 공개 메소드

Seek to any location in the stream. Seeking past the end of the file is allowed. Any writes to that location will cause the file to grow to that size. Any holes that may be created from the seek will be zero filled on close.
public Seek ( long offset, SeekOrigin origin ) : long
offset long
origin SeekOrigin
리턴 long

SetLength() 공개 메소드

Sets the length of this stream to the given value.
public SetLength ( long value ) : void
value long /// A ///
리턴 void

Write() 공개 메소드

Copies from the source array into the grid file.
public Write ( byte array, int offset, int count ) : void
array byte /// A The source array to copy from. ///
offset int /// A The offset within the source array. ///
count int /// A The number of bytes from within the source array to copy. ///
리턴 void