MCPcopy Create free account
hub / github.com/AppleWin/AppleWin / ProDOS_BlockGetFirstFree

Function ProDOS_BlockGetFirstFree

source/ProDOS_FileSystem.h:233–260  ·  view source on GitHub ↗

------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

231
232 // ------------------------------------------------------------------------
233 int ProDOS_BlockGetFirstFree ( uint8_t *pDiskBytes, size_t nDiskSize, ProDOS_VolumeHeader_t *pVolume )
234 {
235 if( !pVolume )
236 {
237 return 0;
238 }
239
240 int bitmap = pVolume->meta.bitmap_block;
241 int offset = bitmap * PRODOS_BLOCK_SIZE;
242 const size_t size = (nDiskSize + 7) / 8;
243 int block = 0;
244
245 for( int byte = 0; byte < size; byte++ )
246 {
247 int mask = 0x80;
248 do
249 {
250 if( pDiskBytes[ offset + byte ] & mask )
251 return block;
252
253 mask >>= 1;
254 block++;
255 }
256 while( mask );
257 }
258
259 return 0;
260 }
261
262 // ------------------------------------------------------------------------
263 int ProDOS_BlockGetPathOffset ( uint8_t *pDiskBytes, ProDOS_VolumeHeader_t *pVolume, const char *pProDOSPath )

Callers 2

Util_ProDOS_AddFileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected