Pages: 1
Author Topic: Replacing Plugin Workdir (and possibly LGM's)  (49,390 Views)
Offline (Unknown gender) IsmAvatar

LateralGM Developer
LGM Developer
Joined: Apr 2008
Posts: 877
View profile
Posted on: June 17, 2011, 01:09:02 AM
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
Offline (Unknown gender) RetroX

Master of all things Linux
Contributor
Joined: Apr 2008
Posts: 1,055
View profile
Reply #1 Posted on: June 17, 2011, 01:28:56 AM
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.
Offline (Unknown gender) IsmAvatar

LateralGM Developer
LGM Developer
Joined: Apr 2008
Posts: 877
View profile
Reply #2 Posted on: June 17, 2011, 01:31:12 AM
RetroX suggested a very good idea to essentially solve LGM's WORKDIR rewrite:
Search for Plugins and Libraries in two locations:
  • The current LGM.jar directory (primarily for Windows users)
  • ~/.lateralgm/ (primarily for Linux users)
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:
  • How does this bode for Mac?
  • This still relies on LGM.jar directory, which causes exceptions when run from a Windows network. 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.
Offline (Unknown gender) RetroX

Master of all things Linux
Contributor
Joined: Apr 2008
Posts: 1,055
View profile
Reply #3 Posted on: June 17, 2011, 01:44:04 AM
Quote from: IsmAvatar on June 17, 2011, 01:31:12 AM
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.
Offline (Unknown gender) Goombert

Developer
Joined: Jan 2013
Posts: 2,991
View profile
Reply #4 Posted on: December 04, 2013, 10: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.
Pages: 1