MCPcopy Create free account
hub / github.com/andysworkshop/stm32plus / skip

Method skip

lib/src/device/BlockDeviceInputStream.cpp:120–154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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 /**

Callers

nothing calls this directly

Calls 4

getBlockSizeInBytesMethod · 0.45
setMethod · 0.45
readBlockMethod · 0.45

Tested by

no test coverage detected