diff --git a/build.xml b/build.xml index 7b32aca..e60036d 100755 --- a/build.xml +++ b/build.xml @@ -172,7 +172,7 @@ Linux(because the top command will be run and the script will exit).\n\nBoth det - + @@ -183,6 +183,17 @@ Linux(because the top command will be run and the script will exit).\n\nBoth det + + + + + + + + + + + diff --git a/scripts/build.number b/scripts/build.number index c25161c..4f64682 100644 --- a/scripts/build.number +++ b/scripts/build.number @@ -1,3 +1,3 @@ #Build Number for ANT. Do not edit! -#Sat Aug 27 18:59:34 EDT 2022 -build.number=89 +#Tue Aug 30 12:27:51 EDT 2022 +build.number=90 diff --git a/src/build.xml b/src/build.xml index cea59a8..0012d18 100644 --- a/src/build.xml +++ b/src/build.xml @@ -43,6 +43,7 @@ + diff --git a/src/java/net/i2p/i2pfirefox/I2PChromiumProfileBuilder.java b/src/java/net/i2p/i2pfirefox/I2PChromiumProfileBuilder.java index 8357b93..9a549ee 100644 --- a/src/java/net/i2p/i2pfirefox/I2PChromiumProfileBuilder.java +++ b/src/java/net/i2p/i2pfirefox/I2PChromiumProfileBuilder.java @@ -41,7 +41,7 @@ public class I2PChromiumProfileBuilder extends I2PCommonBrowser { * @return the profile directory, or null if it could not be created */ public static String profileDirectory() { - String pd = System.getenv("I2P_FIREFOX_PROFILE"); + String pd = System.getenv("I2P_CHROMIUM_PROFILE"); if (pd != null && !pd.isEmpty()) { File pdf = new File(pd); if (pdf.exists() && pdf.isDirectory()) { @@ -73,7 +73,7 @@ public class I2PChromiumProfileBuilder extends I2PCommonBrowser { * @return the base profile directory, or null if it could not be created */ public static String baseProfileDirectory() { - String pd = System.getenv("I2P_FIREFOX_BASE_PROFILE"); + String pd = System.getenv("I2P_CHROMIUM_BASE_PROFILE"); if (pd != null && !pd.isEmpty()) { File pdf = new File(pd); if (pdf.exists() && pdf.isDirectory()) { @@ -108,18 +108,18 @@ public class I2PChromiumProfileBuilder extends I2PCommonBrowser { * @since 0.0.1 */ public static String runtimeDirectory() { - // get the I2P_FIREFOX_DIR environment variable - String rtd = System.getenv("I2P_FIREFOX_DIR"); + // get the I2P_CHROMIUM_DIR environment variable + String rtd = System.getenv("I2P_CHROMIUM_DIR"); // if it is not null and not empty if (rtd != null && !rtd.isEmpty()) { // check if the file exists File rtdFile = new File(rtd); if (rtdFile.exists()) { // if it does, return it - return runtimeDirectory(rtd) + return runtimeDirectory(rtd); } } - return runtimeDirectory("") + return runtimeDirectory(""); } /** @@ -147,6 +147,7 @@ public class I2PChromiumProfileBuilder extends I2PCommonBrowser { System.out.println("Copied base profile to profile directory"); return copyStrictOptions(); } + private static void copyDirectory(File sourceDirectory, File destinationDirectory) throws IOException { destinationDirectory = new File(destinationDirectory.toString().replace("i2p.chromium.base.profile", "")); if (!destinationDirectory.exists()) { diff --git a/src/java/net/i2p/i2pfirefox/I2PChromiumProfileUnpacker.java b/src/java/net/i2p/i2pfirefox/I2PChromiumProfileUnpacker.java index 394eb0c..8d7d737 100644 --- a/src/java/net/i2p/i2pfirefox/I2PChromiumProfileUnpacker.java +++ b/src/java/net/i2p/i2pfirefox/I2PChromiumProfileUnpacker.java @@ -24,7 +24,7 @@ import java.util.zip.ZipInputStream; * @author idk * @since 0.0.1 */ -public class I2PChromiumProfileUnpacker { +public class I2PChromiumProfileUnpacker extends I2PCommonBrowser { public static void main(String[] args) { String profileDirectory = I2PChromiumProfileBuilder.profileDirectory(); @@ -43,45 +43,7 @@ public class I2PChromiumProfileUnpacker { */ public boolean unpackProfile(String profileDirectory) { System.out.println("Unpacking base profile to " + profileDirectory); - try { - final InputStream resources = this.getClass().getClassLoader().getResourceAsStream("i2p.chromium.base.profile.zip"); - if (resources == null) { - System.out.println("Could not find resources"); - return false; - } - System.out.println(resources.toString()); - // InputStream corresponds to a zip file. Unzip it. - //Files.copy(r, new File(profileDirectory).toPath(), StandardCopyOption.REPLACE_EXISTING); - ZipInputStream zis = new ZipInputStream(resources); - ZipEntry entry; - // while there are entries I process them - while ((entry = zis.getNextEntry()) != null) - { - System.out.println("entry: " + entry.getName() + ", " + entry.getSize()); - // consume all the data from this entry - if (entry.isDirectory()) { - System.out.println("Creating directory: " + entry.getName()); - File dir = new File(profileDirectory + "/" + entry.getName()); - dir.mkdirs(); - } else { - System.out.println("Creating file: " + entry.getName()); - File file = new File(profileDirectory + "/" + entry.getName()); - file.createNewFile(); - Files.copy(zis, file.toPath(), StandardCopyOption.REPLACE_EXISTING); - } - while (zis.available() > 0) - zis.read(); - // I could close the entry, but getNextEntry does it automatically - // zis.closeEntry() - } - // loop through the Enumeration - - } catch (Exception e) { - System.out.println("Error copying profile files: " + e.getMessage()); - return false; - } - return true; + return unpackProfile(profileDirectory, "chromium", "base"); } - } diff --git a/src/java/net/i2p/i2pfirefox/I2PCommonBrowser.java b/src/java/net/i2p/i2pfirefox/I2PCommonBrowser.java index a7e4277..99e276c 100644 --- a/src/java/net/i2p/i2pfirefox/I2PCommonBrowser.java +++ b/src/java/net/i2p/i2pfirefox/I2PCommonBrowser.java @@ -1,6 +1,11 @@ package net.i2p.i2pfirefox; import java.io.File; +import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.StandardCopyOption; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; public class I2PCommonBrowser { @@ -68,4 +73,46 @@ public class I2PCommonBrowser { } return ""; } + + public boolean unpackProfile(String profileDirectory, String browser, String base) { + System.out.println("Unpacking base profile to " + profileDirectory); + try { + final InputStream resources = this.getClass().getClassLoader().getResourceAsStream("i2p."+browser+"."+base+".profile.zip"); + if (resources == null) { + System.out.println("Could not find resources"); + return false; + } + System.out.println(resources.toString()); + // InputStream corresponds to a zip file. Unzip it. + //Files.copy(r, new File(profileDirectory).toPath(), StandardCopyOption.REPLACE_EXISTING); + ZipInputStream zis = new ZipInputStream(resources); + ZipEntry entry; + // while there are entries I process them + while ((entry = zis.getNextEntry()) != null) + { + System.out.println("entry: " + entry.getName() + ", " + entry.getSize()); + // consume all the data from this entry + if (entry.isDirectory()) { + System.out.println("Creating directory: " + entry.getName()); + File dir = new File(profileDirectory + "/" + entry.getName()); + dir.mkdirs(); + } else { + System.out.println("Creating file: " + entry.getName()); + File file = new File(profileDirectory + "/" + entry.getName()); + file.createNewFile(); + Files.copy(zis, file.toPath(), StandardCopyOption.REPLACE_EXISTING); + } + while (zis.available() > 0) + zis.read(); + // I could close the entry, but getNextEntry does it automatically + // zis.closeEntry() + } + // loop through the Enumeration + + } catch (Exception e) { + System.out.println("Error copying profile files: " + e.getMessage()); + return false; + } + return true; + } } diff --git a/src/java/net/i2p/i2pfirefox/I2PFirefoxProfileUnpacker.java b/src/java/net/i2p/i2pfirefox/I2PFirefoxProfileUnpacker.java index f144c46..d952394 100644 --- a/src/java/net/i2p/i2pfirefox/I2PFirefoxProfileUnpacker.java +++ b/src/java/net/i2p/i2pfirefox/I2PFirefoxProfileUnpacker.java @@ -1,12 +1,5 @@ package net.i2p.i2pfirefox; -import java.io.File; -import java.io.InputStream; -import java.nio.file.Files; -import java.nio.file.StandardCopyOption; -import java.util.zip.ZipEntry; -import java.util.zip.ZipInputStream; - /** * I2PFirefoxProfileUnpacker.java * Copyright (C) 2022 idk @@ -25,7 +18,7 @@ import java.util.zip.ZipInputStream; * @author idk * @since 0.0.1 */ -public class I2PFirefoxProfileUnpacker { +public class I2PFirefoxProfileUnpacker extends I2PCommonBrowser { public static void main(String[] args) { String profileDirectory = I2PFirefoxProfileBuilder.profileDirectory(); @@ -42,46 +35,8 @@ public class I2PFirefoxProfileUnpacker { * @return true if the profile directory was successfully unpacked * @since 0.0.1 */ - public boolean unpackProfile(String profileDirectory) { - System.out.println("Unpacking base profile to " + profileDirectory); - try { - final InputStream resources = this.getClass().getClassLoader().getResourceAsStream("i2p.firefox.base.profile.zip"); - if (resources == null) { - System.out.println("Could not find resources"); - return false; - } - System.out.println(resources.toString()); - // InputStream corresponds to a zip file. Unzip it. - //Files.copy(r, new File(profileDirectory).toPath(), StandardCopyOption.REPLACE_EXISTING); - ZipInputStream zis = new ZipInputStream(resources); - ZipEntry entry; - // while there are entries I process them - while ((entry = zis.getNextEntry()) != null) - { - System.out.println("entry: " + entry.getName() + ", " + entry.getSize()); - // consume all the data from this entry - if (entry.isDirectory()) { - System.out.println("Creating directory: " + entry.getName()); - File dir = new File(profileDirectory + "/" + entry.getName()); - dir.mkdirs(); - } else { - System.out.println("Creating file: " + entry.getName()); - File file = new File(profileDirectory + "/" + entry.getName()); - file.createNewFile(); - Files.copy(zis, file.toPath(), StandardCopyOption.REPLACE_EXISTING); - } - while (zis.available() > 0) - zis.read(); - // I could close the entry, but getNextEntry does it automatically - // zis.closeEntry() - } - // loop through the Enumeration - - } catch (Exception e) { - System.out.println("Error copying profile files: " + e.getMessage()); - return false; - } - return true; + public boolean unpackProfile(String profileDirectory){ + return unpackProfile(profileDirectory, "firefox", "base"); }