--------------------------------------
| 218 | |
| 219 | //-------------------------------------- |
| 220 | bool ZipSubRStream::setPosition(const U32 in_newPosition) |
| 221 | { |
| 222 | AssertFatal(m_pStream != NULL, "Error, not attached"); |
| 223 | |
| 224 | if (in_newPosition == 0) |
| 225 | { |
| 226 | Stream* pStream = getStream(); |
| 227 | U32 resetPosition = m_originalSlavePosition; |
| 228 | U32 uncompressedSize = m_uncompressedSize; |
| 229 | detachStream(); |
| 230 | pStream->setPosition(resetPosition); |
| 231 | attachStream(pStream); |
| 232 | setUncompressedSize(uncompressedSize); |
| 233 | return true; |
| 234 | } |
| 235 | else |
| 236 | { |
| 237 | if (in_newPosition > m_uncompressedSize) |
| 238 | return false; |
| 239 | |
| 240 | U32 newPosition = in_newPosition; |
| 241 | if (newPosition < m_currentPosition) |
| 242 | { |
| 243 | Stream* pStream = getStream(); |
| 244 | U32 resetPosition = m_originalSlavePosition; |
| 245 | U32 uncompressedSize = m_uncompressedSize; |
| 246 | detachStream(); |
| 247 | pStream->setPosition(resetPosition); |
| 248 | attachStream(pStream); |
| 249 | setUncompressedSize(uncompressedSize); |
| 250 | } |
| 251 | else |
| 252 | { |
| 253 | newPosition -= m_currentPosition; |
| 254 | } |
| 255 | |
| 256 | bool bRet = true; |
| 257 | char *buffer = new char[2048]; |
| 258 | while (newPosition >= 2048) |
| 259 | { |
| 260 | newPosition -= 2048; |
| 261 | if (!_read(2048,buffer)) |
| 262 | { |
| 263 | bRet = false; |
| 264 | break; |
| 265 | } |
| 266 | }; |
| 267 | if (bRet && newPosition > 0) |
| 268 | { |
| 269 | if (!_read(newPosition,buffer)) |
| 270 | { |
| 271 | bRet = false; |
| 272 | }; |
| 273 | }; |
| 274 | |
| 275 | delete [] buffer; |
| 276 | |
| 277 | return bRet; |
no test coverage detected