Search in sources :

Example 1 with CoreEngine

use of main.system.launch.CoreEngine in project Eidolons by IDemiurge.

the class PathFinder method _init.

private static void _init() {
    ClassLoader classLoader = PathFinder.class.getClassLoader();
    if (classLoader.getResource("") != null) {
        File temp = new File(classLoader.getResource("").getFile());
        ENGINE_PATH = new File(temp.getParentFile().toURI()) + File.separator;
        XML_PATH = new File(temp.getParentFile() + File.separator + "XML") + File.separator;
        System.out.println("Engine path: " + ENGINE_PATH);
    } else {
        // FOR JARS
        CoreEngine.setJar(true);
        URI uri = null;
        try {
            uri = new CoreEngine().getClass().getProtectionDomain().getCodeSource().getLocation().toURI();
        } catch (URISyntaxException e) {
            main.system.ExceptionMaster.printStackTrace(e);
        }
        if (jarName == null)
            jarName = StringMaster.getLastPathSegment((uri.toString()));
        if (jarName.contains(".exe")) {
            CoreEngine.setExe(true);
        }
        System.out.println("jarName: " + jarName);
        String path = new File(uri.toString().replace(jarName + StringMaster.getPathSeparator(), "")).getAbsolutePath();
        path = path.split("file:")[0];
        System.out.println("Engine path for Jar: " + path);
        ENGINE_PATH = path + File.separator;
        XML_PATH = path + File.separator + "XML" + File.separator;
    }
    RES_PATH = RES_FOLDER_NAME + File.separator;
    IMG_PATH = ENGINE_PATH + RES_PATH + "img" + StringMaster.getPathSeparator();
    main.system.auxiliary.log.LogMaster.log(1, "IMG_PATH PATH= " + IMG_PATH);
    SND_PATH = ENGINE_PATH + RES_PATH + "sound" + StringMaster.getPathSeparator();
    FONT_PATH = ENGINE_PATH + RES_PATH + "Fonts" + StringMaster.getPathSeparator();
    MACRO_TYPES_PATH = XML_PATH + MACRO_MODULE_NAME + StringMaster.getPathSeparator() + "types" + StringMaster.getPathSeparator();
    TYPES_PATH = XML_PATH + MICRO_MODULE_NAME + StringMaster.getPathSeparator() + "types" + StringMaster.getPathSeparator() + ((PRESENTATION_MODE) ? PRESENTATION : "");
}
Also used : URISyntaxException(java.net.URISyntaxException) File(java.io.File) URI(java.net.URI) CoreEngine(main.system.launch.CoreEngine)

Aggregations

File (java.io.File)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 CoreEngine (main.system.launch.CoreEngine)1