Seek Moves the file pointer to a specified location Params offset - number of bytes from origin origin - initial position SEEK_CUR SEEK_END SEEK_SET Return offset, in bytes, of the new position from the beginning of the file -1 - error *****************************************/
| 385 | -1 - error |
| 386 | *****************************************/ |
| 387 | long CUT_FileDataSource::Seek(long offset, int origin) |
| 388 | { |
| 389 | // When we reading the line of text we use buffering. Thats why |
| 390 | // actual file position will not match. Fix this problem by subtractng |
| 391 | // number of bytes read in buffer from current file position |
| 392 | if(origin == SEEK_CUR && m_nLoadedDataSize > 0) { |
| 393 | long lCurPos = m_file.Seek(0, SEEK_CUR) - m_nLoadedDataSize; |
| 394 | if(lCurPos > 0) |
| 395 | m_file.Seek(lCurPos, SEEK_SET); |
| 396 | } |
| 397 | |
| 398 | m_nLoadedDataSize = 0; |
| 399 | |
| 400 | return m_file.Seek(offset, origin); |
| 401 | } |
| 402 | |
| 403 | // ================================================================= |
| 404 | // CUT_BufferDataSource class |
nothing calls this directly
no outgoing calls
no test coverage detected