public InputStream getResourceInputStream(String innerPath) throws IOException {
   return resourceParser.getInputStream(innerPath);
 }
  private DataManager(File datsFolder) throws IOException, JAXBException {

    //	log.trace("DataManager initialising");

    boolean meltdown = false;
    ArrayList<InputStream> streams = new ArrayList<InputStream>();

    try {
      dataParser = new MappedDatParser(new File(datsFolder, "data.dat"));
      resourceParser = new MappedDatParser(new File(datsFolder, "resource.dat"));

      //// log.og.info("Reading Achievements...");
      //		log.debug("Reading 'data/achievements.xml'");
      InputStream achStream = dataParser.getInputStream("data/achievements.xml");
      streams.add(achStream);
      achievements = dataParser.readAchievements(achStream);

      //		log.info("Reading Blueprints...");
      //		log.debug("Reading 'data/blueprints.xml'");
      InputStream blueStream = dataParser.getInputStream("data/blueprints.xml");
      streams.add(blueStream);
      blueprints = dataParser.readBlueprints(blueStream, "blueprints.xml");

      //		log.debug("Reading 'data/autoBlueprints.xml'");
      InputStream autoBlueStream = dataParser.getInputStream("data/autoBlueprints.xml");
      streams.add(autoBlueStream);
      autoBlueprints = dataParser.readBlueprints(autoBlueStream, "autoBlueprints.xml");

      // log.info("Reading Events...");
      String[] eventsFileNames =
          new String[] {
            "events.xml",
            "newEvents.xml",
            "events_crystal.xml",
            "events_engi.xml",
            "events_mantis.xml",
            "events_rock.xml",
            "events_slug.xml",
            "events_zoltan.xml",
            "events_nebula.xml",
            "events_pirate.xml",
            "events_rebel.xml",
            "nameEvents.xml",
            "events_fuel.xml",
            "events_boss.xml"
          };

      events = new LinkedHashMap<String, Encounters>();
      for (String eventsFileName : eventsFileNames) {
        // log.debug("Reading 'data/"+ eventsFileName +"'");
        InputStream tmpStream = dataParser.getInputStream("data/" + eventsFileName);
        streams.add(tmpStream);
        Encounters tmpEncounters = dataParser.readEvents(tmpStream, eventsFileName);
        events.put(eventsFileName, tmpEncounters);
      }

      // log.info("Reading Crew Names...");
      // log.debug("Reading 'data/names.xml'");
      InputStream crewNamesStream = dataParser.getInputStream("data/names.xml");
      streams.add(crewNamesStream);
      List<CrewNameList> crewNameLists = dataParser.readCrewNames(crewNamesStream);

      // log.info("Reading Ship Events...");
      // log.debug("Reading 'data/events_ships.xml'");
      InputStream shipEventsStream = dataParser.getInputStream("data/events_ships.xml");
      streams.add(shipEventsStream);
      List<ShipEvent> shipEventList =
          dataParser.readShipEvents(shipEventsStream, "events_ships.xml");

      // log.info("Reading Background Image Lists...");
      // log.debug("Reading 'data/events_imageList.xml'");
      InputStream imageListsStream = dataParser.getInputStream("data/events_imageList.xml");
      streams.add(imageListsStream);
      List<BackgroundImageList> imageLists = dataParser.readImageLists(imageListsStream);

      // log.info("Finished reading game resources.");

      generalAchievements = new ArrayList<Achievement>();
      for (Achievement ach : achievements)
        if (ach.getShipId() == null) generalAchievements.add(ach);

      augments = new LinkedHashMap<String, AugBlueprint>();
      for (AugBlueprint augment : blueprints.getAugBlueprint())
        augments.put(augment.getId(), augment);

      drones = new LinkedHashMap<String, DroneBlueprint>();
      for (DroneBlueprint drone : blueprints.getDroneBlueprint()) drones.put(drone.getId(), drone);

      systems = new LinkedHashMap<String, SystemBlueprint>();
      for (SystemBlueprint system : blueprints.getSystemBlueprint())
        systems.put(system.getId(), system);

      weapons = new LinkedHashMap<String, WeaponBlueprint>();
      for (WeaponBlueprint weapon : blueprints.getWeaponBlueprint())
        weapons.put(weapon.getId(), weapon);

      ships = new LinkedHashMap<String, ShipBlueprint>();
      for (ShipBlueprint ship : blueprints.getShipBlueprint()) ships.put(ship.getId(), ship);

      autoShips = new LinkedHashMap<String, ShipBlueprint>();
      for (ShipBlueprint ship : autoBlueprints.getShipBlueprint())
        autoShips.put(ship.getId(), ship);

      playerShips = new ArrayList<ShipBlueprint>();
      playerShips.add(ships.get("PLAYER_SHIP_HARD"));
      playerShips.add(ships.get("PLAYER_SHIP_STEALTH"));
      playerShips.add(ships.get("PLAYER_SHIP_MANTIS"));
      playerShips.add(ships.get("PLAYER_SHIP_CIRCLE"));
      playerShips.add(ships.get("PLAYER_SHIP_FED"));
      playerShips.add(ships.get("PLAYER_SHIP_JELLY"));
      playerShips.add(ships.get("PLAYER_SHIP_ROCK"));
      playerShips.add(ships.get("PLAYER_SHIP_ENERGY"));
      playerShips.add(ships.get("PLAYER_SHIP_CRYSTAL"));

      shipAchievements = new HashMap<ShipBlueprint, List<Achievement>>();
      for (ShipBlueprint ship : playerShips) {
        List<Achievement> shipAchs = new ArrayList<Achievement>();
        for (Achievement ach : achievements)
          if (ship.getId().equals(ach.getShipId())) shipAchs.add(ach);
        shipAchievements.put(ship, shipAchs);
      }

      // These'll populate as files are requested.
      shipLayouts = new HashMap<String, ShipLayout>();
      shipChassisMap = new HashMap<String, ShipChassis>();

      crewNamesMale = new ArrayList<CrewNameList.CrewName>();
      crewNamesFemale = new ArrayList<CrewNameList.CrewName>();
      for (CrewNameList crewNameList : crewNameLists) {
        if ("male".equals(crewNameList.getSex())) crewNamesMale.addAll(crewNameList.getNames());
        else crewNamesFemale.addAll(crewNameList.getNames());
      }

      shipEvents = new LinkedHashMap<String, ShipEvent>();
      for (ShipEvent shipEvent : shipEventList) shipEvents.put(shipEvent.getId(), shipEvent);

      backgroundImageLists = new LinkedHashMap<String, BackgroundImageList>();
      for (BackgroundImageList imageList : imageLists)
        backgroundImageLists.put(imageList.getId(), imageList);

    } catch (JAXBException e) {
      meltdown = true;
      throw e;

    } catch (IOException e) {
      meltdown = true;
      throw e;

    } finally {
      for (InputStream stream : streams) {
        try {
          if (stream != null) stream.close();
        } catch (IOException f) {
        }
      }

      if (meltdown) this.close();
    }
  }
 public InputStream getDataInputStream(String innerPath) throws IOException {
   return dataParser.getInputStream(innerPath);
 }