/** Constructor for FatFileSystem in specified readOnly mode */ public FatFileSystem(Device device, boolean readOnly, FatFileSystemType type) throws FileSystemException { super(device, readOnly, type); // false = read/write mode try { bs = new BootSector(512); bs.read(getApi()); // if (!bs.isaValidBootSector()) throw new FileSystemException( // "Can't mount this partition: Invalid BootSector"); // System.out.println(bs); Fat[] fats = new Fat[bs.getNrFats()]; rootDir = new FatLfnDirectory(this, bs.getNrRootDirEntries()); FatType bitSize; if (bs.getMediumDescriptor() == 0xf8) { bitSize = FatType.FAT16; } else { bitSize = FatType.FAT12; } for (int i = 0; i < fats.length; i++) { Fat fat = new Fat( bitSize, bs.getMediumDescriptor(), bs.getSectorsPerFat(), bs.getBytesPerSector()); fats[i] = fat; fat.read(getApi(), FatUtils.getFatOffset(bs, i)); } for (int i = 1; i < fats.length; i++) { if (!fats[0].equals(fats[i])) { System.out.println("FAT " + i + " differs from FAT 0"); } } fat = fats[0]; rootDir.read(getApi(), FatUtils.getRootDirOffset(bs)); rootEntry = new FatRootEntry(rootDir); // files = new FatFile[fat.getNrEntries()]; } catch (IOException ex) { throw new FileSystemException(ex); } catch (Exception e) { // something bad happened in the FAT boot // sector... just ignore this FS throw new FileSystemException(e); } }