@Override protected Block allocate() { syncNeeded = true ; return file.allocate(blockSize) ; }
@Override public void close() { closed = true ; file.close() ; }
@Override public boolean isEmpty() { return file.isEmpty() ; }
@Override public void write(Block block) { syncNeeded = true ; file.write(block) ; }
private Block getBlock(long id) { Block block = file.read(id) ; return block ; }
@Override public void sync() { if ( syncNeeded ) file.sync() ; else syncNeeded = true; syncNeeded = false ; }
@Override public boolean valid(int id) { return file.valid(id) ; }
@Override public void overwrite(Block block) { syncNeeded = true ; file.overwrite(block) ; }
/*package*/ BlockMgrFileAccess(BlockAccess blockAccess, int blockSize) { super(blockAccess.getLabel(), blockSize) ; file = blockAccess ; }
@Test public void fileaccess_02() { Block b = data(file, blkSize) ; file.write(b) ; }
@Override public void syncForce() { file.sync() ; }
@After public void after() { file.close() ; }
@Test public void fileaccess_01() { assertTrue(file.isEmpty()) ; }
protected static Block data(BlockAccess file, int len) { Block b = file.allocate(len) ; for (int i = 0 ; i < len ; i++ ) b.getByteBuffer().put((byte)(i&0xFF)) ; return b ; }
@Test public void fileaccess_02() { Block b = data(file, blkSize) ; file.write(b) ; }
@After public void after() { file.close() ; }