+ #if USE_IOCACHE
+ if( Volume->CacheHandle )
+ {
+ int done = 0;
+ while( done < BlockCount )
+ {
+ while( done < BlockCount && IOCache_Read(Volume->CacheHandle, BlockNum+done, Dest) == 1 )
+ done ++, Dest = (char*)Dest + Volume->BlockSize;
+ size_t first_uncached = done;
+ void *uncache_buf = Dest;
+ LOG("%i/%i: cached", done, BlockCount);
+ while( done < BlockCount && IOCache_Read(Volume->CacheHandle, BlockNum+done, Dest) == 0 )
+ done ++, Dest = (char*)Dest + Volume->BlockSize;
+ LOG("%i/%i: uncached", done, BlockCount);
+ size_t count = done-first_uncached;
+ if( count ) {
+ Volume->Type->Read(Volume->Ptr, BlockNum+first_uncached, count, uncache_buf);
+ while(count--)
+ {
+ IOCache_Add(Volume->CacheHandle, BlockNum+first_uncached, uncache_buf);
+ first_uncached ++;
+ uncache_buf = (char*)uncache_buf + Volume->BlockSize;
+ }
+ }
+ }
+ return done;
+ }
+ else
+ #endif
+ return Volume->Type->Read(Volume->Ptr, BlockNum, BlockCount, Dest);