- Add FileStreamFactory and I2PFile to deal with the problems from
the code CWD is / but the only writable directory is /data/data/net.i2p.router/files/ - still a ton of places to be fixed, will be fixed up as things get working - Load some config files from resources at startup - Fix up logging - Add reseed capability, by copying some code over from routerconsole - Deal with conflicting bouncycastle libs
This commit is contained in:
@ -37,6 +37,7 @@ import java.util.TreeMap;
|
||||
import java.util.zip.Deflater;
|
||||
|
||||
import net.i2p.util.ByteCache;
|
||||
import net.i2p.util.FileStreamFactory;
|
||||
import net.i2p.util.OrderedProperties;
|
||||
import net.i2p.util.ReusableGZIPInputStream;
|
||||
import net.i2p.util.ReusableGZIPOutputStream;
|
||||
@ -217,7 +218,7 @@ public class DataHelper {
|
||||
loadProps(props, file, false);
|
||||
}
|
||||
public static void loadProps(Properties props, File file, boolean forceLowerCase) throws IOException {
|
||||
loadProps(props, new FileInputStream(file), forceLowerCase);
|
||||
loadProps(props, FileStreamFactory.getFileInputStream(file), forceLowerCase);
|
||||
}
|
||||
public static void loadProps(Properties props, InputStream inStr) throws IOException {
|
||||
loadProps(props, inStr, false);
|
||||
|
36
core/java/src/net/i2p/util/FileStreamFactory.java
Normal file
36
core/java/src/net/i2p/util/FileStreamFactory.java
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* public domain
|
||||
*/
|
||||
|
||||
package net.i2p.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
|
||||
|
||||
/**
|
||||
* This is pulled out and replaced in the android build.
|
||||
*
|
||||
* @author zzz
|
||||
*/
|
||||
public class FileStreamFactory {
|
||||
|
||||
public static FileInputStream getFileInputStream(String f) throws FileNotFoundException {
|
||||
return new FileInputStream(f);
|
||||
}
|
||||
|
||||
public static FileInputStream getFileInputStream(File f) throws FileNotFoundException {
|
||||
return new FileInputStream(f);
|
||||
}
|
||||
|
||||
public static FileOutputStream getFileOutputStream(String f) throws FileNotFoundException {
|
||||
return new FileOutputStream(f);
|
||||
}
|
||||
|
||||
public static FileOutputStream getFileOutputStream(File f) throws FileNotFoundException {
|
||||
return new FileOutputStream(f);
|
||||
}
|
||||
|
||||
}
|
24
core/java/src/net/i2p/util/I2PFile.java
Normal file
24
core/java/src/net/i2p/util/I2PFile.java
Normal file
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* public domain
|
||||
*/
|
||||
|
||||
package net.i2p.util;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* This is pulled out and replaced in the android build.
|
||||
*
|
||||
* @author zzz
|
||||
*/
|
||||
public class I2PFile extends File {
|
||||
|
||||
public I2PFile (String f) {
|
||||
super(f);
|
||||
}
|
||||
|
||||
public I2PFile (File p, String f) {
|
||||
super(p, f);
|
||||
}
|
||||
|
||||
}
|
@ -240,7 +240,7 @@ public class LogManager {
|
||||
//
|
||||
|
||||
private void loadConfig() {
|
||||
File cfgFile = new File(_location);
|
||||
File cfgFile = new I2PFile(_location);
|
||||
if (!cfgFile.exists()) {
|
||||
if (!_alreadyNoticedMissingConfig) {
|
||||
if (_log.shouldLog(Log.WARN))
|
||||
@ -268,11 +268,11 @@ public class LogManager {
|
||||
Properties p = new Properties();
|
||||
FileInputStream fis = null;
|
||||
try {
|
||||
fis = new FileInputStream(cfgFile);
|
||||
fis = FileStreamFactory.getFileInputStream(cfgFile);
|
||||
p.load(fis);
|
||||
_configLastRead = _context.clock().now();
|
||||
} catch (IOException ioe) {
|
||||
System.err.println("Error loading logger config from " + new File(_location).getAbsolutePath());
|
||||
System.err.println("Error loading logger config from " + new I2PFile(_location).getAbsolutePath());
|
||||
} finally {
|
||||
if (fis != null) try {
|
||||
fis.close();
|
||||
@ -540,7 +540,7 @@ public class LogManager {
|
||||
String config = createConfig();
|
||||
FileOutputStream fos = null;
|
||||
try {
|
||||
fos = new FileOutputStream(_location);
|
||||
fos = FileStreamFactory.getFileOutputStream(_location);
|
||||
fos.write(config.getBytes());
|
||||
return true;
|
||||
} catch (IOException ioe) {
|
||||
|
Reference in New Issue
Block a user