/** * Flush all changed structures to the device. * * @throws IOException */ public void flush() throws IOException { final BlockDeviceAPI api = getApi(); if (bs.isDirty()) { bs.write(api); } for (FatFile f : files.values()) { f.flush(); } if (fat.isDirty()) { for (int i = 0; i < bs.getNrFats(); i++) { fat.write(api, FatUtils.getFatOffset(bs, i)); } } if (rootDir.isDirty()) { rootDir.flush(); } }