예제 #1
0
 /**
  * This method deletes a plugin file. If deletion fails - typically happens on Windows due to file
  * locking - the file is scheduled for deletion on the next startup.
  *
  * @param f The file to delete.
  * @return true if deletion was successful, false if scheduled for later.
  */
 public static boolean deletePluginFile(File f) {
   boolean success = f.delete();
   if (success) return true;
   else {
     schedulePluginForDeletion(f.getPath());
     return false;
   }
 }
예제 #2
0
 /**
  * Delete the given files. Refuses to delete files outside the user plugin directory. This method
  * throws no errors is the files don't exist or deletion failed.
  *
  * @param filenames An array of names of the files to be deleted.
  */
 public static void deletePluginsOnStartup(String[] filenames) {
   for (String s : filenames) {
     File f = new File(s);
     if (f.getParentFile().equals(PluginCore.userPluginDir)) {
       // if (s.startsWith(PluginCore.userPluginDir.getPath())) {
       boolean success = f.delete();
     } else System.out.println("File outside of user plugin dir: " + s);
   }
 }
예제 #3
0
  /**
   * Look inside a jar file, find the plugin.xml file, and use it to determine the name and version
   * of the plugin.
   *
   * @param f The file to investigate.
   * @return A string array containing the plugin name in the first element and the version number
   *     in the second, or null if the filename couldn't be interpreted.
   */
  public static String[] getNameAndVersion(File f) {

    try {
      File temp = unpackPluginXML(f);
      if (temp == null) return null; // Couldn't find the plugin.xml file
      ManifestInfo mi =
          PluginCore.getManager().getRegistry().readManifestInfo(temp.toURI().toURL());
      temp.delete();
      return new String[] {mi.getId(), mi.getVersion().toString()};
    } catch (MalformedURLException e) {
      e.printStackTrace();
      return null;
    } catch (ManifestProcessingException e) {
      return null; // Couldn't make sense of the plugin.xml
    }
  }