Example #1
0
  /** initialization. load all files. */
  private void init() {
    URL home = getClass().getResource("..");
    File local;
    if (home != null) {
      System.out.println("looks like you are not starting from a jar-package");
      local = new File(home.getPath() + "/" + helproot + "/" + language + "/");
      System.out.println("local: " + local.getAbsolutePath());
      initFile(local);
      try {
        local =
            new File(
                new File(home.getPath()).getParentFile().getParentFile(),
                helproot + "/" + language);
        System.out.println("local: " + local.getAbsolutePath());
        initFile(local);
      } catch (Exception e) {
        System.out.println("but not loading from the developer workbench?!");
      }

    } else {
      System.out.println("looks like you are starting from a jar-package");
      local = CommandLoader.getLocation();
      initJar(local);
    }
    List<String> l = getLanguages();
    for (String aL : l) {
      System.out.println("language found: " + aL);
    }
  }
Example #2
0
 /**
  * automatically generate non-existing help html files for existing commands in the CommandLoader
  *
  * @param cl the CommandLoader where you look for the existing commands
  */
 public void createHelpText(CommandLoader cl) {
   File dir = new File((getClass().getResource("..").getPath()));
   dir = new File(dir, language);
   if (!dir.exists() && !dir.mkdirs()) {
     System.out.println("Failed to create " + dir.getAbsolutePath());
     return;
   }
   for (String mnemo : cl.getMnemoList()) {
     if (!exists(mnemo)) {
       File file = new File(dir, mnemo + ".htm");
       try {
         file.createNewFile();
         BufferedOutputStream os = new BufferedOutputStream(new FileOutputStream(file));
         PrintStream ps = new PrintStream(os);
         ps.println("<html>\n<head>\n<title>" + mnemo + "\n</title>\n</head>\n<body>");
         ps.println("Command: " + mnemo.toUpperCase() + "<br>");
         ps.println("arguments: <br>");
         ps.println("effects: <br>");
         ps.println("flags to be set: <br>");
         ps.println("approx. clockcycles: <br>");
         ps.println("misc: <br>");
         ps.println("</body>\n</html>");
         ps.flush();
         ps.close();
       } catch (IOException e) {
         System.out.println("failed to create " + file.getAbsolutePath());
       }
     }
   }
 }
Example #3
0
  /**
   * scans for possible help directories (languages)
   *
   * @return a list of possible language directories
   */
  public List<String> getLanguages() {
    List<String> paths = new ArrayList<>();
    URL home = getClass().getResource("..");
    File local;
    if (home != null) {
      System.out.println("looks like you are not starting from a jar-package");
      try {
        local = new File(new File(home.getPath()).getParentFile().getParentFile(), helproot);
        System.out.println("local: " + local.getAbsolutePath());
        for (File s : local.listFiles()) {
          if (s.isDirectory() && (s.listFiles().length > 0)) {
            addToList(paths, s.getName());
          }
        }
      } catch (Exception e) {
        System.out.println("but not loading from the developer workbench?!");
      }

    } else {
      System.out.println("looks like you are starting from a jar-package");
      local = CommandLoader.getLocation();
      File helpDir = new File(local, helproot);
      if (helpDir.exists() && helpDir.isDirectory() && (helpDir.listFiles().length > 0)) {
        for (File s : helpDir.listFiles()) {
          if (s.isDirectory()) {
            addToList(paths, s.getName());
          }
        }
      }

      File jar = new File(CommandLoader.classPath());
      for (File file : local.listFiles()) {
        try {
          if (!jar.getCanonicalPath().equals(file.getCanonicalPath())) {
            searchJarPath(file, paths);
          }
        } catch (IOException ignored) {
        }
        searchJarPath(jar, paths);
      }
    }
    return paths;
  }
Example #4
0
 /**
  * load from all jars inside the [local] folder (w/o subfolders)
  *
  * @param local the folder to look for the jars
  */
 private void initJar(File local) {
   File jar = new File(CommandLoader.classPath());
   loadFromJar(jar);
 }