respect Java conventions a little better, start writing some Javadoc
This commit is contained in:
@ -1,3 +1,3 @@
|
||||
#Build Number for ANT. Do not edit!
|
||||
#Sun Aug 07 12:05:18 EDT 2022
|
||||
build.number=33
|
||||
#Sun Aug 07 12:40:19 EDT 2022
|
||||
build.number=34
|
||||
|
@ -168,7 +168,7 @@ public class I2PFirefox {
|
||||
return "Unknown";
|
||||
}
|
||||
|
||||
public String[] OnlyValidFirefoxes() {
|
||||
public String[] onlyValidFirefoxes() {
|
||||
String[] firefoxes = FIREFOX_FINDER();
|
||||
ArrayList<String> validFirefoxes = new ArrayList<String>();
|
||||
for (String firefox : firefoxes) {
|
||||
@ -180,7 +180,7 @@ public class I2PFirefox {
|
||||
return validFirefoxes.toArray(new String[validFirefoxes.size()]);
|
||||
}
|
||||
|
||||
public String TopFirefox() {
|
||||
public String topFirefox() {
|
||||
// get the FIREFOX environment variable
|
||||
String firefox = System.getenv("FIREFOX");
|
||||
// if it is not null and not empty
|
||||
@ -192,21 +192,21 @@ public class I2PFirefox {
|
||||
return firefox;
|
||||
}
|
||||
}
|
||||
String[] firefoxes = OnlyValidFirefoxes();
|
||||
String[] firefoxes = onlyValidFirefoxes();
|
||||
if (firefoxes.length > 0) {
|
||||
return firefoxes[0];
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
public String TopFirefox(String overrideFirefox) {
|
||||
public String topFirefox(String overrideFirefox) {
|
||||
if (overrideFirefox != null && !overrideFirefox.isEmpty()) {
|
||||
File firefoxFile = new File(overrideFirefox);
|
||||
if (firefoxFile.exists()) {
|
||||
return overrideFirefox;
|
||||
}
|
||||
}
|
||||
return TopFirefox();
|
||||
return topFirefox();
|
||||
}
|
||||
|
||||
public ProcessBuilder defaultProcessBuilder() {
|
||||
@ -214,7 +214,7 @@ public class I2PFirefox {
|
||||
}
|
||||
|
||||
public ProcessBuilder processBuilder(String[] args) {
|
||||
String firefox = TopFirefox();
|
||||
String firefox = topFirefox();
|
||||
if (!firefox.isEmpty()) {
|
||||
String[] newArgs = new String[args.length+3];
|
||||
newArgs[0] = firefox;
|
||||
@ -223,7 +223,7 @@ public class I2PFirefox {
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
newArgs[i+3] = args[i];
|
||||
}
|
||||
return new ProcessBuilder(newArgs).directory(I2PFirefoxProfileBuilder.RuntimeDirectory(true));
|
||||
return new ProcessBuilder(newArgs).directory(I2PFirefoxProfileBuilder.runtimeDirectory(true));
|
||||
} else {
|
||||
return new ProcessBuilder(args);
|
||||
}
|
||||
@ -268,7 +268,7 @@ public class I2PFirefox {
|
||||
System.out.println("Valid profile directory: "+profileDirectory);
|
||||
} else {
|
||||
System.out.println("Invalid profile directory: "+profileDirectory+" rebuilding...");
|
||||
if (!I2PFirefoxProfileBuilder.CopyBaseProfiletoProfile()) {
|
||||
if (!I2PFirefoxProfileBuilder.copyBaseProfiletoProfile()) {
|
||||
System.out.println("Failed to rebuild profile directory: "+profileDirectory);
|
||||
return;
|
||||
} else {
|
||||
|
@ -27,7 +27,7 @@ public class I2PFirefoxProfileBuilder {
|
||||
return pd;
|
||||
}
|
||||
}
|
||||
String rtd = RuntimeDirectory();
|
||||
String rtd = runtimeDirectory();
|
||||
return profileDir(rtd);
|
||||
}
|
||||
|
||||
@ -51,12 +51,12 @@ public class I2PFirefoxProfileBuilder {
|
||||
return pd;
|
||||
}
|
||||
}
|
||||
String rtd = RuntimeDirectory();
|
||||
String rtd = runtimeDirectory();
|
||||
return baseProfileDir(rtd);
|
||||
}
|
||||
|
||||
public static File RuntimeDirectory(boolean create) {
|
||||
String rtd = RuntimeDirectory();
|
||||
public static File runtimeDirectory(boolean create) {
|
||||
String rtd = runtimeDirectory();
|
||||
File rtdFile = new File(rtd);
|
||||
if (create) {
|
||||
if (!rtdFile.exists()) {
|
||||
@ -66,7 +66,7 @@ public class I2PFirefoxProfileBuilder {
|
||||
return new File(rtd);
|
||||
}
|
||||
|
||||
public static String RuntimeDirectory() {
|
||||
public static String runtimeDirectory() {
|
||||
// get the I2P_FIREFOX_DIR environment variable
|
||||
String rtd = System.getenv("I2P_FIREFOX_DIR");
|
||||
// if it is not null and not empty
|
||||
@ -106,7 +106,13 @@ public class I2PFirefoxProfileBuilder {
|
||||
}
|
||||
return "";
|
||||
}
|
||||
public static boolean CopyBaseProfiletoProfile() {
|
||||
|
||||
/*
|
||||
* Copy the inert base profile directory to the runtime profile directory
|
||||
*
|
||||
* @since 0.0.1
|
||||
*/
|
||||
public static boolean copyBaseProfiletoProfile() {
|
||||
String baseProfile = baseProfileDirectory();
|
||||
String profile = profileDirectory();
|
||||
if (baseProfile.isEmpty() || profile.isEmpty()) {
|
||||
@ -123,12 +129,16 @@ public class I2PFirefoxProfileBuilder {
|
||||
System.out.println("Error copying base profile to profile"+e);
|
||||
return false;
|
||||
}
|
||||
if (!CopyStrictOptions()){
|
||||
return false;
|
||||
return copyStrictOptions();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public static boolean CopyStrictOptions() {
|
||||
|
||||
/*
|
||||
* Copy the strict options from the base profile to the profile
|
||||
*
|
||||
* @return true if successful, false otherwise
|
||||
* @since 0.0.1
|
||||
*/
|
||||
public static boolean copyStrictOptions() {
|
||||
if (!strict){
|
||||
return true;
|
||||
}
|
||||
@ -156,9 +166,21 @@ public class I2PFirefoxProfileBuilder {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Construct a new Profile Builder
|
||||
*
|
||||
* @since 0.0.1
|
||||
*/
|
||||
I2PFirefoxProfileBuilder() {
|
||||
I2PFirefoxProfileBuilder.strict = false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Construct a new Profile Builder
|
||||
* @param strict if true, the strict overrides will be copied to the profile
|
||||
*
|
||||
* @since 0.0.1
|
||||
*/
|
||||
I2PFirefoxProfileBuilder(boolean strict) {
|
||||
I2PFirefoxProfileBuilder.strict = strict;
|
||||
}
|
||||
|
Reference in New Issue
Block a user