SECCompressFile::Seek
longSECCompressFile::Seek(longlOff, UINTnFrom)
Seeks to the specified location.
Defined in: compfile.cpp
Return Value
If the requested position is legal, Seek returns the new byte offset from the beginning of the file. Otherwise, the return value is undefined and a CFileException object is thrown.
Parameters
lOff
Number of bytes to move the pointer
nFrom
Pointer movement mode. Must be one of the following values:
CFile::begin
Move the file pointer lOff bytes forward from the beginning of the file.
CFile::current
Move the file pointer lOff bytes from the current position in the file.
CFile::end
Move the file pointer backward lOff bytes from the end of the file.
Comments
Repositions the pointer in a previously opened file. The Seek function permits random access to a file's contents by moving the pointer a specified amount, absolutely or relatively. No data is actually read during the seek. When a file is opened, the file pointer is positioned at offset 0, the beginning of the file.
Developer Notes
Seek() always assumes the file contains uncompressed data, and will always seek to an absolute position in the file without regard to compression.
Since SECCompressFile compresses its data as a whole, it is not possible to seek to the middle of a compressed data block to partially decompress a block.
However, by switching back and forth between compressed mode and normal CFile mode, compressed data can be written to a file in different locations. Also, a jump table might be placed at the beginning of the file to store seek locations of the different compressed blocks.
SECCompressFile has no logic to determine where compressed blocks begin and end, so it is up to the developer to either treat an entire file as a single compressed block, or be able to Seek() to the beginning of compresssed data and read in the correct number of compressed bytes.
See Also
SECCompressFile SeekToBegin SeekToEnd Read ReadHuge Write WriteHuge