| 118 | */ |
| 119 | |
| 120 | bool BlockDeviceInputStream::skip(uint32_t howMuch) { |
| 121 | |
| 122 | uint32_t newBlock,newIndex; |
| 123 | |
| 124 | // bump forward as many whole blocks as required |
| 125 | |
| 126 | newBlock=_blockIndex+(howMuch / _device.getBlockSizeInBytes()); |
| 127 | |
| 128 | // and by how much in addition to whole blocks |
| 129 | |
| 130 | newIndex=_blockIndex+(howMuch % _device.getBlockSizeInBytes()); |
| 131 | |
| 132 | // gone past a block boundary? update if so |
| 133 | |
| 134 | if(newIndex>=_device.getBlockSizeInBytes()) { |
| 135 | newBlock++; |
| 136 | newIndex-=_device.getBlockSizeInBytes(); |
| 137 | } |
| 138 | |
| 139 | // check for end of device |
| 140 | |
| 141 | if(newBlock>=_device.getTotalBlocksOnDevice()) |
| 142 | return errorProvider.set(ErrorProvider::ERROR_PROVIDER_BLOCK_DEVICE_INPUT_STREAM,E_INVALID_SEEK_POSITION); |
| 143 | |
| 144 | // update positions and read in the new block |
| 145 | |
| 146 | if(newBlock!=_blockIndex) |
| 147 | if(!_device.readBlock(_block,newBlock)) |
| 148 | return false; |
| 149 | |
| 150 | _blockIndex=newBlock; |
| 151 | _indexInBlock=newIndex; |
| 152 | |
| 153 | return true; |
| 154 | } |
| 155 | |
| 156 | |
| 157 | /** |
nothing calls this directly
no test coverage detected