mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
some getenv/setenv muckety muck
This commit is contained in:
@@ -1215,6 +1215,11 @@ public class Base {
|
||||
// }
|
||||
|
||||
|
||||
static public Platform getPlatform() {
|
||||
return platform;
|
||||
}
|
||||
|
||||
|
||||
static public String getPlatformName() {
|
||||
String osname = System.getProperty("os.name");
|
||||
|
||||
@@ -1761,33 +1766,6 @@ public class Base {
|
||||
// ...................................................................
|
||||
|
||||
|
||||
public interface CLibrary extends Library {
|
||||
CLibrary INSTANCE = (CLibrary)Native.loadLibrary("c", CLibrary.class);
|
||||
int setenv(String name, String value, int overwrite);
|
||||
String getenv(String name);
|
||||
int unsetenv(String name);
|
||||
int putenv(String string);
|
||||
}
|
||||
|
||||
|
||||
static public void setenv(String variable, String value) {
|
||||
CLibrary clib = CLibrary.INSTANCE;
|
||||
clib.setenv(variable, value, 1);
|
||||
}
|
||||
|
||||
|
||||
static public String getenv(String variable) {
|
||||
CLibrary clib = CLibrary.INSTANCE;
|
||||
return clib.getenv(variable);
|
||||
}
|
||||
|
||||
|
||||
static public int unsetenv(String variable) {
|
||||
CLibrary clib = CLibrary.INSTANCE;
|
||||
return clib.unsetenv(variable);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the number of lines in a file by counting the number of newline
|
||||
* characters inside a String (and adding 1).
|
||||
|
||||
@@ -26,6 +26,9 @@ import java.io.File;
|
||||
|
||||
import javax.swing.UIManager;
|
||||
|
||||
import com.sun.jna.Library;
|
||||
import com.sun.jna.Native;
|
||||
|
||||
|
||||
/**
|
||||
* Used by Base for platform-specific tweaking, for instance finding the
|
||||
@@ -128,6 +131,36 @@ public class Platform {
|
||||
|
||||
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
||||
|
||||
|
||||
public interface CLibrary extends Library {
|
||||
CLibrary INSTANCE = (CLibrary)Native.loadLibrary("c", CLibrary.class);
|
||||
int setenv(String name, String value, int overwrite);
|
||||
String getenv(String name);
|
||||
int unsetenv(String name);
|
||||
int putenv(String string);
|
||||
}
|
||||
|
||||
|
||||
public void setenv(String variable, String value) {
|
||||
CLibrary clib = CLibrary.INSTANCE;
|
||||
clib.setenv(variable, value, 1);
|
||||
}
|
||||
|
||||
|
||||
public String getenv(String variable) {
|
||||
CLibrary clib = CLibrary.INSTANCE;
|
||||
return clib.getenv(variable);
|
||||
}
|
||||
|
||||
|
||||
public int unsetenv(String variable) {
|
||||
CLibrary clib = CLibrary.INSTANCE;
|
||||
return clib.unsetenv(variable);
|
||||
}
|
||||
|
||||
|
||||
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
||||
|
||||
|
||||
protected void showLauncherWarning() {
|
||||
Base.showWarning("No launcher available",
|
||||
|
||||
@@ -69,16 +69,17 @@ public class Android implements Tool {
|
||||
|
||||
|
||||
static protected void checkPath() {
|
||||
Platform platform = Base.getPlatform();
|
||||
// System.out.println("PATH is " + Base.getenv("PATH"));
|
||||
// System.out.println("PATH from System is " + System.getenv("PATH"));
|
||||
if (Base.getenv("ANDROID_SDK") == null) {
|
||||
Base.setenv("ANDROID_SDK", "/opt/android");
|
||||
if (platform.getenv("ANDROID_SDK") == null) {
|
||||
platform.setenv("ANDROID_SDK", "/opt/android");
|
||||
}
|
||||
sdkPath = Base.getenv("ANDROID_SDK");
|
||||
sdkPath = platform.getenv("ANDROID_SDK");
|
||||
// System.out.println("sdk path is " + sdkPath);
|
||||
// sdkPath = "/opt/android";
|
||||
String toolsPath = sdkPath + File.separator + "tools";
|
||||
Base.setenv("PATH", Base.getenv("PATH") + File.pathSeparator + toolsPath);
|
||||
platform.setenv("PATH", platform.getenv("PATH") + File.pathSeparator + toolsPath);
|
||||
// System.out.println("path after set is " + Base.getenv("PATH"));
|
||||
}
|
||||
|
||||
|
||||
@@ -25,8 +25,12 @@ package processing.app.windows;
|
||||
import java.io.File;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
import com.sun.jna.Library;
|
||||
import com.sun.jna.Native;
|
||||
|
||||
import processing.app.Base;
|
||||
import processing.app.Preferences;
|
||||
import processing.app.Platform.CLibrary;
|
||||
import processing.app.windows.Registry.REGISTRY_ROOT_KEY;
|
||||
import processing.core.PApplet;
|
||||
|
||||
@@ -265,4 +269,36 @@ public class Platform extends processing.app.Platform {
|
||||
// not tested
|
||||
//Runtime.getRuntime().exec("start explorer \"" + folder + "\"");
|
||||
}
|
||||
|
||||
|
||||
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
||||
|
||||
|
||||
public interface WinLibC extends Library {
|
||||
WinLibC INSTANCE = (WinLibC) Native.loadLibrary("msvcrt", WinLibC.class);
|
||||
|
||||
public int _putenv(String name);
|
||||
// int setenv(String name, String value, int overwrite);
|
||||
// String getenv(String name);
|
||||
// int unsetenv(String name);
|
||||
// int putenv(String string);
|
||||
}
|
||||
|
||||
|
||||
public void setenv(String variable, String value) {
|
||||
WinLibC clib = WinLibC.INSTANCE;
|
||||
clib._putenv(variable + "=" + value);
|
||||
}
|
||||
|
||||
|
||||
public String getenv(String variable) {
|
||||
return System.getenv(variable);
|
||||
}
|
||||
|
||||
|
||||
public int unsetenv(String variable) {
|
||||
WinLibC clib = WinLibC.INSTANCE;
|
||||
clib._putenv(variable + "=");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user