Router: Move continents.txt file into jar

Move core resources directory to be consistent with the other subsystems
This commit is contained in:
zzz
2020-12-26 08:11:00 -05:00
parent 12f9a7187e
commit 665239fd37
6 changed files with 17 additions and 17 deletions

View File

@@ -1827,7 +1827,6 @@
<copy file="build/addressbook.war" todir="pkg-temp/webapps/" /> <copy file="build/addressbook.war" todir="pkg-temp/webapps/" />
<!-- decapitalized the file in 0.7.8 --> <!-- decapitalized the file in 0.7.8 -->
<copy file="installer/resources/countries.txt" todir="pkg-temp/geoip/" /> <copy file="installer/resources/countries.txt" todir="pkg-temp/geoip/" />
<copy file="installer/resources/continents.txt" todir="pkg-temp/geoip/" />
<!-- <!--
<copy file="installer/resources/public-suffix-list.txt" todir="pkg-temp/geoip/" /> <copy file="installer/resources/public-suffix-list.txt" todir="pkg-temp/geoip/" />
--> -->
@@ -1846,7 +1845,6 @@
<!-- GeoIP files --> <!-- GeoIP files -->
<target name="prepgeoupdate" depends="prepgeoupdate-unlesspkg" > <target name="prepgeoupdate" depends="prepgeoupdate-unlesspkg" >
<copy file="installer/resources/countries.txt" todir="pkg-temp/geoip/" /> <copy file="installer/resources/countries.txt" todir="pkg-temp/geoip/" />
<copy file="installer/resources/continents.txt" todir="pkg-temp/geoip/" />
<!-- <!--
<copy file="installer/resources/public-suffix-list.txt" todir="pkg-temp/geoip/" /> <copy file="installer/resources/public-suffix-list.txt" todir="pkg-temp/geoip/" />
--> -->

View File

@@ -109,9 +109,12 @@
<target name="jar" depends="compile, bundle, jarUpToDate, listChangedFiles" unless="jar.uptodate" > <target name="jar" depends="compile, bundle, jarUpToDate, listChangedFiles" unless="jar.uptodate" >
<!-- set if unset --> <!-- set if unset -->
<property name="workspace.changes.tr" value="" /> <property name="workspace.changes.tr" value="" />
<mkdir dir="build/obj/net/i2p/util/resources" />
<copy todir="build/obj/net/i2p/util/resources" >
<fileset dir="../resources" />
</copy>
<jar destfile="./build/i2p.jar" > <jar destfile="./build/i2p.jar" >
<fileset dir="./build/obj" includes="**/*.class" /> <fileset dir="./build/obj" />
<fileset dir="./src" includes="net/i2p/util/resources/*" />
<!-- the getopt translation files --> <!-- the getopt translation files -->
<fileset dir="src" includes="${translation.includes}" /> <fileset dir="src" includes="${translation.includes}" />
<manifest> <manifest>

View File

@@ -70,7 +70,11 @@
<target name="jar" depends="compile, bundle, jarUpToDate, listChangedFiles" unless="jar.uptodate" > <target name="jar" depends="compile, bundle, jarUpToDate, listChangedFiles" unless="jar.uptodate" >
<!-- set if unset --> <!-- set if unset -->
<property name="workspace.changes.tr" value="" /> <property name="workspace.changes.tr" value="" />
<jar destfile="./build/router.jar" basedir="./build/obj" includes="**/*.class" > <mkdir dir="build/obj/net/i2p/router/util/resources" />
<copy todir="build/obj/net/i2p/router/util/resources" >
<fileset dir="../resources" />
</copy>
<jar destfile="./build/router.jar" basedir="./build/obj" >
<manifest> <manifest>
<!-- so people with very old wrapper.config files will still work with Jetty 6 --> <!-- so people with very old wrapper.config files will still work with Jetty 6 -->
<attribute name="${manifest.classpath.name}" value="i2p.jar addressbook.jar jetty-i2p.jar jetty-rewrite-handler.jar jetty-start.jar jetty-util.jar" /> <attribute name="${manifest.classpath.name}" value="i2p.jar addressbook.jar jetty-i2p.jar jetty-rewrite-handler.jar jetty-start.jar jetty-util.jar" />

View File

@@ -3,7 +3,7 @@ package net.i2p.router.time;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.util.HashMap; import java.util.HashMap;
import java.util.Locale; import java.util.Locale;
@@ -87,20 +87,14 @@ class Zones {
* ref: http://dev.maxmind.com/geoip/legacy/codes/country_continent/ * ref: http://dev.maxmind.com/geoip/legacy/codes/country_continent/
*/ */
private void readContinentFile() { private void readContinentFile() {
String geoDir = _context.getProperty(GeoIP.PROP_GEOIP_DIR, GeoIP.GEOIP_DIR_DEFAULT); InputStream is = Zones.class.getResourceAsStream("/net/i2p/router/util/resources/" + CONTINENT_FILE_DEFAULT);
File geoFile = new File(geoDir); if (is == null) {
if (!geoFile.isAbsolute()) System.out.println("Continent file not found");
geoFile = new File(_context.getBaseDir(), geoDir);
geoFile = new File(geoFile, CONTINENT_FILE_DEFAULT);
if (!geoFile.exists()) {
//if (_log.shouldWarn())
// _log.warn("Continent file not found: " + geoFile.getAbsolutePath());
return; return;
} }
BufferedReader br = null; BufferedReader br = null;
try { try {
br = new BufferedReader(new InputStreamReader( br = new BufferedReader(new InputStreamReader(is, "UTF-8"));
new FileInputStream(geoFile), "UTF-8"));
String line = null; String line = null;
while ((line = br.readLine()) != null) { while ((line = br.readLine()) != null) {
try { try {
@@ -118,8 +112,9 @@ class Zones {
} catch (IndexOutOfBoundsException ioobe) {} } catch (IndexOutOfBoundsException ioobe) {}
} }
} catch (IOException ioe) { } catch (IOException ioe) {
System.out.println("Error reading the continent file " + geoFile.getAbsolutePath()); System.out.println("Error reading the continent file");
} finally { } finally {
try { is.close(); } catch (IOException ioe) {}
if (br != null) try { br.close(); } catch (IOException ioe) {} if (br != null) try { br.close(); } catch (IOException ioe) {}
} }
} }