set a default directory in some cases
This commit is contained in:
@ -4,10 +4,11 @@
|
|||||||
jpackage --verbose \
|
jpackage --verbose \
|
||||||
--type deb \
|
--type deb \
|
||||||
--linux-deb-maintainer hankhill19580@gmail.com \
|
--linux-deb-maintainer hankhill19580@gmail.com \
|
||||||
--linux-menu-group "Internet" \
|
--linux-menu-group "Network;WebBrowser;P2P" \
|
||||||
--linux-app-category "network" \
|
--linux-app-category "Network" \
|
||||||
--linux-package-deps "firefox|chromium|brave|firefox-esr|librewolf|icecat" \
|
--linux-package-deps "firefox|chromium|brave|firefox-esr|librewolf|icecat" \
|
||||||
--linux-shortcut \
|
--linux-shortcut \
|
||||||
|
--license-file LICENSE.md \
|
||||||
--name i2pbrowser \
|
--name i2pbrowser \
|
||||||
--app-version "$GITHUB_TAG" \
|
--app-version "$GITHUB_TAG" \
|
||||||
--input src/build \
|
--input src/build \
|
||||||
|
Binary file not shown.
Binary file not shown.
@ -112,6 +112,7 @@ public class I2PBrowser extends I2PCommonBrowser {
|
|||||||
* @since 0.0.17
|
* @since 0.0.17
|
||||||
*/
|
*/
|
||||||
public void launch(boolean privateWindow, String[] url) {
|
public void launch(boolean privateWindow, String[] url) {
|
||||||
|
validateUserDir();
|
||||||
if (generic)
|
if (generic)
|
||||||
this.launchGeneric(privateWindow, url);
|
this.launchGeneric(privateWindow, url);
|
||||||
if ((chromium && firefox) || (!chromium && !firefox)) {
|
if ((chromium && firefox) || (!chromium && !firefox)) {
|
||||||
@ -175,6 +176,7 @@ public class I2PBrowser extends I2PCommonBrowser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
validateUserDir();
|
||||||
boolean privateBrowsing = false;
|
boolean privateBrowsing = false;
|
||||||
println("I2PBrowser");
|
println("I2PBrowser");
|
||||||
I2PBrowser i2pBrowser = new I2PBrowser();
|
I2PBrowser i2pBrowser = new I2PBrowser();
|
||||||
|
@ -549,6 +549,7 @@ public class I2PChromium extends I2PCommonBrowser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Process launchAndDetatch(boolean privateWindow, String[] url) {
|
public Process launchAndDetatch(boolean privateWindow, String[] url) {
|
||||||
|
validateUserDir();
|
||||||
if (waitForProxy()) {
|
if (waitForProxy()) {
|
||||||
String profileDirectory = I2PChromiumProfileBuilder.profileDirectory();
|
String profileDirectory = I2PChromiumProfileBuilder.profileDirectory();
|
||||||
if (I2PChromiumProfileChecker.validateProfileDirectory(
|
if (I2PChromiumProfileChecker.validateProfileDirectory(
|
||||||
@ -641,6 +642,7 @@ public class I2PChromium extends I2PCommonBrowser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
validateUserDir();
|
||||||
boolean privateBrowsing = false;
|
boolean privateBrowsing = false;
|
||||||
println("I2PChromium");
|
println("I2PChromium");
|
||||||
I2PChromium i2pChromium = new I2PChromium();
|
I2PChromium i2pChromium = new I2PChromium();
|
||||||
|
@ -49,10 +49,65 @@ public class I2PCommonBrowser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void validateUserDir() {
|
||||||
|
println("Validating user directory");
|
||||||
|
String userDir = System.getProperty("user.dir");
|
||||||
|
String userHome = System.getProperty("user.home");
|
||||||
|
File userDirFile = new File(userDir);
|
||||||
|
File userHomeFile = new File(userHome);
|
||||||
|
println("user.dir testing !" + userHomeFile.getAbsolutePath() + ".equals(" +
|
||||||
|
userDirFile.getAbsolutePath() + ")");
|
||||||
|
if (!userDirFile.getAbsolutePath().equals(userHomeFile.getAbsolutePath())) {
|
||||||
|
println("user.dir is not inconvenient");
|
||||||
|
if (userDirFile.exists()) {
|
||||||
|
println("user.dir exists");
|
||||||
|
if (userDirFile.isDirectory()) {
|
||||||
|
println("user.dir is a directory");
|
||||||
|
if (userDirFile.canWrite()) {
|
||||||
|
println("user.dir is writable");
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
println("user.dir is not writable");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{ println("user.dir is not actually a directory"); }
|
||||||
|
} else {
|
||||||
|
println("user.dir does not exist");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
println("user.dir should not be the same as user.home");
|
||||||
|
}
|
||||||
|
if (isWindows())
|
||||||
|
userHome = new File(userHome, "AppData/Local/I2P").getAbsolutePath();
|
||||||
|
File defaultPathFile = new File(userHome, "i2p/i2pbrowser");
|
||||||
|
if (!defaultPathFile.exists())
|
||||||
|
defaultPathFile.mkdirs();
|
||||||
|
if (!defaultPathFile.isDirectory()) {
|
||||||
|
println(
|
||||||
|
"default path exists and is not a directory, get it out of the way");
|
||||||
|
println(defaultPathFile.getAbsolutePath());
|
||||||
|
}
|
||||||
|
System.setProperty("user.dir", defaultPathFile.getAbsolutePath());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isWindows() {
|
||||||
|
String osName = System.getProperty("os.name");
|
||||||
|
println("os.name" + osName);
|
||||||
|
if (osName.contains("windows"))
|
||||||
|
return true;
|
||||||
|
if (osName.contains("Windows"))
|
||||||
|
return true;
|
||||||
|
if (osName.contains("WINDOWS"))
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public static void println(String line) { logger.info(line); }
|
public static void println(String line) { logger.info(line); }
|
||||||
|
|
||||||
private static File logFile() {
|
private static File logFile() {
|
||||||
File log = new File("logs");
|
validateUserDir();
|
||||||
|
String userDir = System.getProperty("user.dir");
|
||||||
|
File log = new File(userDir, "logs");
|
||||||
if (!log.exists())
|
if (!log.exists())
|
||||||
log.mkdirs();
|
log.mkdirs();
|
||||||
return new File(log, "browserlauncher.log");
|
return new File(log, "browserlauncher.log");
|
||||||
|
@ -184,6 +184,8 @@ public class I2PFirefox extends I2PCommonBrowser {
|
|||||||
// list the files in the user.dir directory
|
// list the files in the user.dir directory
|
||||||
if (userFiles != null) {
|
if (userFiles != null) {
|
||||||
for (File userFile : userFiles) {
|
for (File userFile : userFiles) {
|
||||||
|
if (userFile.isDirectory())
|
||||||
|
continue;
|
||||||
if (userFile.getName().equals("firefox") ||
|
if (userFile.getName().equals("firefox") ||
|
||||||
userFile.getName().equals("firefox-bin") ||
|
userFile.getName().equals("firefox-bin") ||
|
||||||
userFile.getName().equals("firefox-esr") ||
|
userFile.getName().equals("firefox-esr") ||
|
||||||
@ -462,6 +464,7 @@ public class I2PFirefox extends I2PCommonBrowser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Process launchAndDetatch(boolean privateWindow, String[] url) {
|
public Process launchAndDetatch(boolean privateWindow, String[] url) {
|
||||||
|
validateUserDir();
|
||||||
if (waitForProxy()) {
|
if (waitForProxy()) {
|
||||||
String profileDirectory = I2PFirefoxProfileBuilder.profileDirectory();
|
String profileDirectory = I2PFirefoxProfileBuilder.profileDirectory();
|
||||||
if (I2PFirefoxProfileChecker.validateProfileDirectory(profileDirectory)) {
|
if (I2PFirefoxProfileChecker.validateProfileDirectory(profileDirectory)) {
|
||||||
@ -556,6 +559,7 @@ public class I2PFirefox extends I2PCommonBrowser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
validateUserDir();
|
||||||
boolean privateBrowsing = false;
|
boolean privateBrowsing = false;
|
||||||
println("checking for private browsing");
|
println("checking for private browsing");
|
||||||
ArrayList<String> visitURL = new ArrayList<String>();
|
ArrayList<String> visitURL = new ArrayList<String>();
|
||||||
|
@ -326,6 +326,7 @@ public class I2PGenericUnsafeBrowser extends I2PCommonBrowser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Process launchAndDetatch(boolean privateWindow, String[] url) {
|
public Process launchAndDetatch(boolean privateWindow, String[] url) {
|
||||||
|
validateUserDir();
|
||||||
if (waitForProxy()) {
|
if (waitForProxy()) {
|
||||||
ProcessBuilder pb;
|
ProcessBuilder pb;
|
||||||
if (privateWindow) {
|
if (privateWindow) {
|
||||||
@ -393,6 +394,7 @@ public class I2PGenericUnsafeBrowser extends I2PCommonBrowser {
|
|||||||
|
|
||||||
//
|
//
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
validateUserDir();
|
||||||
boolean privateBrowsing = false;
|
boolean privateBrowsing = false;
|
||||||
println("checking for private browsing");
|
println("checking for private browsing");
|
||||||
ArrayList<String> visitURL = new ArrayList<String>();
|
ArrayList<String> visitURL = new ArrayList<String>();
|
||||||
|
@ -9,6 +9,7 @@ jpackage \
|
|||||||
--win-menu-group "I2P Browser Configurer" \
|
--win-menu-group "I2P Browser Configurer" \
|
||||||
--win-shortcut \
|
--win-shortcut \
|
||||||
--win-shortcut-prompt \
|
--win-shortcut-prompt \
|
||||||
|
--license-file LICENSE.md \
|
||||||
--name i2pbrowser \
|
--name i2pbrowser \
|
||||||
--app-version "$GITHUB_TAG" \
|
--app-version "$GITHUB_TAG" \
|
||||||
--input src/build \
|
--input src/build \
|
||||||
|
Reference in New Issue
Block a user