Exemplo n.º 1
0
  @Override
  public void close() throws IOException {
    // Write back the mapping file if it has been changed
    if (sectorMappingDirty) {
      writeMappingFile();
    }

    sectorDevice.close();
  }
Exemplo n.º 2
0
 @Override
 public void readSector(int sectorNumber, byte[] buffer, int offset) throws IOException {
   int mappedSectorNumber = mapSector(sectorNumber);
   if (mappedSectorNumber >= 0) {
     sectorDevice.readSector(mappedSectorNumber, buffer, offset);
   } else {
     Arrays.fill(buffer, offset, offset + sectorLength, (byte) 0);
   }
 }
Exemplo n.º 3
0
  @Override
  public void writeSector(int sectorNumber, byte[] buffer, int offset) throws IOException {
    int freeSectorNumber = getFreeSectorNumber();
    if (freeSectorNumber < 0) {
      throw new IOException(String.format("Sector Device '%s' is full", mappingFile));
    }

    sectorDevice.writeSector(freeSectorNumber, buffer, offset);
    setSectorMapping(freeSectorNumber, sectorNumber);
  }