Pages: 1
  Print  
Author Topic: Replacing Plugin Workdir (and possibly LGM's)  (Read 15907 times)
Offline (Female) IsmAvatar
Posted on: June 16, 2011, 08:09:02 pm

LateralGM Developer
LGM Developer
Location: Pennsylvania/USA
Joined: Apr 2008
Posts: 877

View Profile Email
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
« Last Edit: June 16, 2011, 08:12:12 pm by IsmAvatar » Logged
Offline (Male) RetroX
Reply #1 Posted on: June 16, 2011, 08:28:56 pm

Master of all things Linux
Contributor
Location: US
Joined: Apr 2008
Posts: 1055
MSN Messenger - classixretrox@gmail.com
View Profile Email
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.
Logged
My Box: Phenom II 3.4GHz X4 | ASUS ATI RadeonHD 5770, 1GB GDDR5 RAM | 1x4GB DDR3 SRAM | Arch Linux, x86_64 (Cube) / Windows 7 x64 (Blob)
Quote from: Fede-lasse
Why do all the pro-Microsoft people have troll avatars? :(
Offline (Female) IsmAvatar
Reply #2 Posted on: June 16, 2011, 08:31:12 pm

LateralGM Developer
LGM Developer
Location: Pennsylvania/USA
Joined: Apr 2008
Posts: 877

View Profile Email
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.
« Last Edit: June 16, 2011, 08:34:10 pm by IsmAvatar » Logged
Offline (Male) RetroX
Reply #3 Posted on: June 16, 2011, 08:44:04 pm

Master of all things Linux
Contributor
Location: US
Joined: Apr 2008
Posts: 1055
MSN Messenger - classixretrox@gmail.com
View Profile Email
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.
Logged
My Box: Phenom II 3.4GHz X4 | ASUS ATI RadeonHD 5770, 1GB GDDR5 RAM | 1x4GB DDR3 SRAM | Arch Linux, x86_64 (Cube) / Windows 7 x64 (Blob)
Quote from: Fede-lasse
Why do all the pro-Microsoft people have troll avatars? :(
Offline (Male) Goombert
Reply #4 Posted on: December 04, 2013, 05:25:35 pm

Developer
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 2993

View Profile
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.
Logged
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.

Pages: 1
  Print