ENIGMA Forums

Sharing is caring => Ideas and Design => Topic started by: IsmAvatar on June 16, 2011, 08:09:02 pm

Title: Replacing Plugin Workdir (and possibly LGM's)
Post by: IsmAvatar on June 16, 2011, 08:09:02 pm
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:

ENIGMA uses LGM's workdir for the following:

ENIGMA uses its workdir for the following:

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
Title: Re: Replacing Plugin Workdir (and possibly LGM's)
Post by: RetroX on June 16, 2011, 08:28:56 pm
Based upon a proposal in the IRC:
- ENIGMA's workdir will remain the same for now, but LGM's will also search ~/.lateralgm.  This will allow linux users to add plug-ins and libs to LGM without having to mess with root permissions if the directory is write-protected.
Title: Re: Replacing Plugin Workdir (and possibly LGM's)
Post by: IsmAvatar on June 16, 2011, 08:31:12 pm
RetroX suggested a very good idea to essentially solve LGM's WORKDIR rewrite:
Search for Plugins and Libraries in two locations:
And temporarily resolve ENIGMA's WORKDIR to LGM.jar directory until we find something else to do with it.

I like the idea, but it does have some problems:
Title: Re: Replacing Plugin Workdir (and possibly LGM's)
Post by: RetroX on June 16, 2011, 08:44:04 pm
The #java folks vaguely hinted at the fact that for Windows I should also have some kind of generic home directory for settings (similar to ~/.lateralgm, but for Windows), but I haven't been able to figure out how to achieve this in a cross-platform manner.
It's AppData/Roaming in Windows 7.  I dunno how to do it in Java.
Title: Re: Replacing Plugin Workdir (and possibly LGM's)
Post by: Goombert on December 04, 2013, 05:25:35 pm
Just to comment on this, JNA 4.0 had an issue when we first added it, it no longer makes you add "." as a search path or it will cause issues, it now does it automatically for you.