/** * Gets the base file system directory containing the given class file. * * @param c The class from which the base directory should be derived. * @see #getBaseDirectory(File, String) */ public static File getBaseDirectory(final Class<?> c) { return getBaseDirectory(c, null); }
final File basePath = AppUtils.getBaseDirectory(c, baseSubdirectory); if (basePath != null) return basePath; final Class<?> mc = AppUtils.getMainClass(); final File appPath = mc == null ? null : AppUtils.getBaseDirectory(mc); if (appPath != null) return appPath;
/** * Gets the base file system directory containing the given class file. * * @param c The class from which the base directory should be derived. * @see #getBaseDirectory(File, String) */ public static File getBaseDirectory(final Class<?> c) { return getBaseDirectory(c, null); }
final File basePath = AppUtils.getBaseDirectory(c, baseSubdirectory); if (basePath != null) return basePath; final Class<?> mc = AppUtils.getMainClass(); final File appPath = mc == null ? null : AppUtils.getBaseDirectory(mc); if (appPath != null) return appPath;
@Deprecated public CommandLine() { this(AppUtils.getBaseDirectory("ij.dir", CommandLine.class, "updater"), 80); }
/** * Gets the ImageJ root directory. If the {@code ij.dir} property is set, it * is used. Otherwise, we scan up the tree from this class for a suitable * directory. * * @deprecated Use {@link App#getBaseDirectory()} instead. * @see org.scijava.util.AppUtils#getBaseDirectory(String, Class, String) */ @Deprecated public static File getBaseDirectory() { return org.scijava.util.AppUtils.getBaseDirectory("ij.dir", AppUtils.class, "core/core"); }
/** * Gets the application's root directory. If the application's system property * is set, it is used. Otherwise, we scan up the tree from this class for a * suitable directory. */ default File getBaseDirectory() { return AppUtils.getBaseDirectory(getSystemProperty(), getClass(), null); }
/** * Gets the application's root directory. If the application's system property * is set, it is used. Otherwise, we scan up the tree from this class for a * suitable directory. */ default File getBaseDirectory() { return AppUtils.getBaseDirectory(getSystemProperty(), getClass(), null); }
/** * Check the update status of the current ImageJ installation. * * @return the status * @throws IOException * @throws ParserConfigurationException * @throws SAXException */ public static Result check() throws IOException, ParserConfigurationException, SAXException { return check(AppUtils.getBaseDirectory("ij.dir", UpToDate.class, "updater")); }
public static void main(final String... args) { if (System.getProperty("imagej.dir") == null) { final String ijDir = System.getProperty("ij.dir"); if (ijDir != null) System.setProperty("imagej.dir", ijDir); else { final String fijiDir = System.getProperty("fiji.dir"); if (fijiDir != null) System.setProperty("imagej.dir", fijiDir); } } try { main(AppUtils.getBaseDirectory("imagej.dir", CommandLine.class, "updater"), 79, null, true, args); } catch (final RuntimeException e) { log.error(e); System.exit(1); } catch (final Exception e) { log.error("Could not parse db.xml.gz", e); System.exit(1); } }
/** * Gets the base file system directory containing the given class file. * * @param c The class from which the base directory should be derived. * @param baseSubdirectory A hint for what to expect for a directory structure * beneath the application base directory. * @see #getBaseDirectory(File, String) */ public static File getBaseDirectory(final Class<?> c, final String baseSubdirectory) { // see: http://stackoverflow.com/a/12733172/1207769 // step 1: convert Class to URL final URL location = Types.location(c); // step 2: convert URL to File File baseFile; try { baseFile = FileUtils.urlToFile(location); } catch (final IllegalArgumentException exc) { // URL can't be converted to a file baseFile = null; } // step 3: get the file's base directory return getBaseDirectory(baseFile, baseSubdirectory); }
/** * Gets the base file system directory containing the given class file. * * @param c The class from which the base directory should be derived. * @param baseSubdirectory A hint for what to expect for a directory structure * beneath the application base directory. * @see #getBaseDirectory(File, String) */ public static File getBaseDirectory(final Class<?> c, final String baseSubdirectory) { // see: http://stackoverflow.com/a/12733172/1207769 // step 1: convert Class to URL final URL location = Types.location(c); // step 2: convert URL to File File baseFile; try { baseFile = FileUtils.urlToFile(location); } catch (final IllegalArgumentException exc) { // URL can't be converted to a file baseFile = null; } // step 3: get the file's base directory return getBaseDirectory(baseFile, baseSubdirectory); }
final File baseDir = AppUtils.getBaseDirectory(file, null); final File pomFile = new File(baseDir, "pom.xml"); return new POM(pomFile);
final File baseDir = AppUtils.getBaseDirectory(file, null); final File pomFile = new File(baseDir, "pom.xml"); return new POM(pomFile);
final File baseDir = AppUtils.getBaseDirectory(file, null); final File pomFile = new File(baseDir, "pom.xml"); return new POM(pomFile);
@Test public void testBaseDirectory() { assertNull(AppUtils.getBaseDirectory(new File( "/home/blub/.m2/repository/org/dscho/secret/1.0/secret-1.0.jar"), null)); final String tmp = PlatformUtils.isWindows() ? "c:/tmp" : "/tmp"; assertEquals(new File(tmp), AppUtils.getBaseDirectory(new File( tmp + "/app/target/classes"), "app")); assertEquals(new File(tmp), AppUtils.getBaseDirectory(new File( tmp + "/app/target/test-classes"), "app")); assertEquals(new File(tmp), AppUtils.getBaseDirectory(new File( tmp + "/app/target/ij-app-1.57.jar"), "app")); }
final File baseDir = AppUtils.getBaseDirectory(file, null); final File pomFile = new File(baseDir, "pom.xml"); return new POM(pomFile);
"imagej.legacy.LegacyExtensions.setAppName(\"(Fiji Is Just) ImageJ\");" + "imagej.legacy.LegacyExtensions.setIcon(new java.io.File(\"" + AppUtils.getBaseDirectory(Main.class) + "/images/icon.png\"));" + "imagej.legacy.LegacyExtensions.setLegacyEditor(new fiji.$TransientFijiEditor());"
private ScriptService createScriptService() { final Context context = new Context(ScriptService.class); final ScriptService scriptService = context.service(ScriptService.class); final File defaultScriptsDir = new File(AppUtils.getBaseDirectory(ScriptFinder.class), "scripts"); scriptService.removeScriptDirectory(defaultScriptsDir); return scriptService; }
AppUtils.getBaseDirectory("imagej.dir", getClass(), null);