This topic is mostly for RetroX, but other people are always welcome to contribute.
Currently Enigma's plugin to LateralGM, affectionally named The Plugin (written in Java by yours truly) has a WORKDIR variable which resolves to LGM's WORKDIR, which resolves to LGM's jar directory. The question is, why do we need the jar directory?
LGM uses WORKDIR for the following:
- Finding Plugins
- Finding DND Libraries (lib/lgl files)
- For some reason, to populate gmlkeywords.properties from a file outside the jar, if one exists (probably for external override)
ENIGMA uses LGM's workdir for the following:
- To populate Enigma's WORKDIR (EnigmaRunner.WORKDIR = LGM.WORKDIR, more or less).
- To ensure that EnigmaUpdater knows that the program needs a restart when LGM is updated. (this could be replaced with a direct jar lookup)
- For some reason, it calls `make` to build enigma, and then locates enigma dll, in this directory. Not sure why. Will try to replace with ENIGMA's workdir now.
ENIGMA uses its workdir for the following:
- Not yet, but it should be used to call `make` to build enigma, and then locate the enigma dll, in this directory (see a couple lines up).
- Finding the "Compilers" directory
- Finding available API systems in "ENIGMAsystem/SHELL/"
- Provide a directory for ENIGMA's dll to run system commands in (via callback), e.g. Exec()
- Provide a directory for Subversion's Working Copy
- Finding "settings.ey" - a temporary thing that Josh and I set up for the EnigmaSettings pane.
- A directory to quicksave/quickload "definitions.h" (Can pretty much be scrapped, especially once the new file format is available)
Point is, the plugin does need to know ENIGMA's directory somehow, and in a cross-platform fashion. The simplest thing I could think up and implement at the time was "hmm, everything can just go in one program directory, so I'll just look at LGM.jar's directory". For some other directories that I can work with, consult Java.
Here is a listing of directories and other things that I can get using Java's "System.getProperty()" method, if it helps any, but please only use these directories in a cross-platform manner. For instance, do not assume that settings can be stored in `$user.home$/.lgm/` because that's a unix-only manner, and does not reflect for Windows (and probably doesn't for Mac either). Also, avoid trying to get the current Operating System as much as inhumanly possible - there will be a system that you did not account for.
|java.class.path || Java class path|
|java.library.path || List of paths to search when loading libraries|
|java.io.tmpdir || Default temp file path|
|java.compiler || Name of JIT compiler to use|
|java.ext.dirs || Path of extension directory or directories|
|file.separator || File separator ("/" on UNIX) (not necessary, because new File(directory, child) handles this for us)|
|path.separator || Path separator (":" on UNIX)|
|user.name || User's account name|
|user.home || User's home directory|
|user.dir || User's current working directory|