/** * Return the configured army tables directory, if set, otherwise return the * default path, relative to the configured data directory. * * @return {@link File} containing the path to the army tables directory. */ public static File armyTablesDir() { lock.readLock().lock(); try { return (army_tables_dir != null) ? army_tables_dir : new File( dataDir(), DEFAULT_DIR_NAME_ARMY_TABLES); } finally { lock.readLock().unlock(); } }
/** * Return the configured names directory, if set, otherwise return the * default path, relative to the configured data directory. * * @return {@link File} containing the path to the names directory. */ public static File namesDir() { lock.readLock().lock(); try { return (names_dir != null) ? names_dir : new File(dataDir(), DEFAULT_DIR_NAME_NAMES); } finally { lock.readLock().unlock(); } }
/** * Return the configured sounds directory, if set, otherwise return the * default path, relative to the configured data directory. * * @return {@link File} containing the path to the sounds directory. */ public static File soundsDir() { lock.readLock().lock(); try { return (sounds_dir != null) ? sounds_dir : new File(dataDir(), DEFAULT_DIR_NAME_SOUNDS); } finally { lock.readLock().unlock(); } }
/** * Return the configured units directory, if set, otherwise return the * default path, relative to the configured data directory. * * @return {@link File} containing the path to the units directory. */ public static File unitsDir() { lock.readLock().lock(); try { return (units_dir != null) ? units_dir : new File(dataDir(), DEFAULT_DIR_NAME_UNITS); } finally { lock.readLock().unlock(); } }
/** * Return the configured fonts data directory, if set, otherwise return the * default path, relative to the configured data directory. * * @return {@link File} containing the path to the force generator directory. */ public static File fontsDir() { lock.readLock().lock(); try { return (fonts_dir != null) ? fonts_dir : new File( dataDir(), DEFAULT_DIR_NAME_FONTS); } finally { lock.readLock().unlock(); } }
/** * Return the configured boards directory, if set, otherwise return the * default path, relative to the configured data directory. * * @return {@link File} containing the path to the boards directory. */ public static File boardsDir() { lock.readLock().lock(); try { return (boards_dir != null) ? boards_dir : new File(dataDir(), DEFAULT_DIR_NAME_BOARDS); } finally { lock.readLock().unlock(); } }
/** * Return the configured images directory, if set, otherwise return the * default path, relative to the configured data directory. * * @return {@link File} containing the path to the images directory. */ public static File imagesDir() { lock.readLock().lock(); try { return (images_dir != null) ? images_dir : new File(dataDir(), DEFAULT_DIR_NAME_IMAGES); } finally { lock.readLock().unlock(); } }
/** * Return the configured scenarios directory, if set, otherwise return the * default path, relative to the configured data directory. * * @return {@link File} containing the path to the scenarios directory. */ public static File scenariosDir() { lock.readLock().lock(); try { return (scenarios_dir != null) ? scenarios_dir : new File( dataDir(), DEFAULT_DIR_NAME_SCENARIOS); } finally { lock.readLock().unlock(); } }
/** * Return the configured force generator data directory, if set, otherwise return the * default path, relative to the configured data directory. * * @return {@link File} containing the path to the force generator directory. */ public static File forceGeneratorDir() { lock.readLock().lock(); try { return (force_generator_dir != null) ? force_generator_dir : new File( dataDir(), DEFAULT_DIR_NAME_FORCE_GENERATOR); } finally { lock.readLock().unlock(); } }
/** * Return the configured file that maps an image file to a location within * an image atlas, if set, otherwise return the default path, relative to * the configured data directory. * * @return {@link File} containing the path to the image file to atlas loc file. */ public static File imageFileAtlasMapFile() { lock.readLock().lock(); try { return (imgFileAtlasMapFile != null) ? imgFileAtlasMapFile : new File(dataDir(), DEFAULT_FILE_NAME_IMG_FILE_ATLAS_MAP); } finally { lock.readLock().unlock(); } }
/** * Reads in the values from the canonUnitQuirks.xml file and stores them in memory. * * @throws IOException If the file cannot be read. */ public static void initQuirksList() throws IOException { // Get the path to the canonUnitQuirks.xml file. String userDir = System.getProperty("user.dir"); if (!userDir.endsWith(File.separator)) { userDir += File.separator; } // Load the canon quirks list. String filePath = Configuration.dataDir().getAbsolutePath() + File.separator + "canonUnitQuirks.xml"; canonQuirkMap = loadQuirksFile(filePath); // Load the custom quirks list. filePath = userDir + "mmconf" + File.separator + "unitQuirksOverride.xml"; customQuirkMap = loadQuirksFile(filePath); initialized.set(true); }
File f = new MegaMekFile(Configuration.dataDir(), FILE_LOC).getFile(); FileInputStream is = null; BufferedReader reader = null;
/** * Test method for {@link megamek.common.Configuration#dataDir()}. */ @Test public final void testDataDir() { assertEquals("data", Configuration.dataDir().toString()); }
/** * Test method for * {@link megamek.common.Configuration#setDataDir(java.io.File)}. */ @Test public final void testSetDataDir() { Configuration.setDataDir(new File("mydata")); assertEquals("mydata", Configuration.dataDir().toString()); // Should rest to default. Configuration.setDataDir(null); assertEquals("data", Configuration.dataDir().toString()); }