Example #1
0
 /**
  * Loads all valid mods from a specified directory.
  *
  * @param directory The directory to load from.
  */
 private static void loadModDirectory(File directory) {
   if (directory != null && directory.isDirectory()) {
     LogBuilder lb = new LogBuilder(64);
     lb.add("In ", directory.getPath(), " found mod:");
     lb.mark();
     for (File f : directory.listFiles(MOD_FILTER)) {
       try {
         FreeColModFile fcmf = new FreeColModFile(f);
         allMods.put(fcmf.getId(), fcmf);
         lb.add(" ", fcmf.getId());
       } catch (IOException e) {
         logger.log(Level.WARNING, "Bad mod in " + f.getPath(), e);
       }
     }
     if (lb.grew()) lb.log(logger, Level.INFO);
   }
 }
Example #2
0
 @Override
 public boolean accept(File f) {
   final String name = f.getName();
   if (name.startsWith(".")) {
     // Ignore `hidden' files.
     return false;
   } else if (f.isDirectory()) {
     return true;
   } else {
     for (String ending : FreeColModFile.getFileEndings()) {
       if (name.endsWith(ending)) {
         return true;
       }
     }
     return false;
   }
 }