Update AppID documentation

This commit is contained in:
Will Hedgecock 2021-10-22 12:25:59 -05:00
parent 956364b449
commit e4b34d51d9
2 changed files with 5 additions and 7 deletions

View File

@ -8,8 +8,8 @@ _A platform-independent serial port access library for Java._
For usage examples, please refer to the [Usage wiki](https://github.com/Fazecast/jSerialComm/wiki/Usage-Examples).
If you intend to use the library in multiple applications simultaneously, please make sure
to set ```fazecast.jSerialComm.appid``` property before accessing the SerialPort class so that
applications don't accidentally delete each others temporary files during boot-up:
to set the ```fazecast.jSerialComm.appid``` property before accessing the SerialPort class
so that applications don't accidentally delete each others' temporary files during boot-up:
```
System.setProperty("fazecast.jSerialComm.appid", "YOUR_APPLICATION_IDENTIFIER")
```

View File

@ -51,9 +51,7 @@ public final class SerialPort
{
// Static initializer loads correct native library for this machine
private static final String versionString = "2.7.0";
// Used to distinguish multiple processes running this lib
private static final String TMPDIR_APPID_PROPERTY = "fazecast.jSerialComm.appid";
private static final String tmpdirAppIdProperty = "fazecast.jSerialComm.appid";
private static volatile boolean isAndroid = false;
private static volatile boolean isUnixBased = false;
private static volatile boolean isWindows = false;
@ -66,8 +64,8 @@ public final class SerialPort
if ((tempFileDirectory.charAt(tempFileDirectory.length()-1) != '\\') && (tempFileDirectory.charAt(tempFileDirectory.length()-1) != '/'))
tempFileDirectory += "/";
// Make sure to use appId to separate tmpdir directories if library is used by multiple modules, so they don't erase each others folders accidentally.
String appId = System.getProperty(TMPDIR_APPID_PROPERTY, "");
// Make sure to use appId to separate tmpdir directories if library is used by multiple modules so they don't erase each others' folders
String appId = System.getProperty(tmpdirAppIdProperty, "");
tempFileDirectory += "jSerialComm/";
if (!appId.isEmpty()) {
tempFileDirectory += appId + (!appId.endsWith("/") ? "/" : "");