load configuration from the JAR
This commit is contained in:
parent
7d25016895
commit
c154985d7e
@ -28,7 +28,7 @@
|
|||||||
*
|
*
|
||||||
* This file is part of the Contiki operating system.
|
* This file is part of the Contiki operating system.
|
||||||
*
|
*
|
||||||
* $Id: CoffeeConfiguration.java,v 1.2 2009/08/10 12:51:52 nvt-se Exp $
|
* $Id: CoffeeConfiguration.java,v 1.3 2009/08/11 14:42:58 nvt-se Exp $
|
||||||
*
|
*
|
||||||
* @author Nicolas Tsiftes
|
* @author Nicolas Tsiftes
|
||||||
*
|
*
|
||||||
@ -59,10 +59,12 @@ public class CoffeeConfiguration {
|
|||||||
"default_log_size", "page_type_size"};
|
"default_log_size", "page_type_size"};
|
||||||
String property;
|
String property;
|
||||||
Properties prop = new Properties();
|
Properties prop = new Properties();
|
||||||
FileInputStream fstream =
|
InputStream stream = CoffeeConfiguration.class.getResourceAsStream("/" + filename);
|
||||||
new FileInputStream(filename);
|
if (stream == null) {
|
||||||
|
throw new CoffeeException("failed to load the configuration file " + filename);
|
||||||
|
}
|
||||||
|
|
||||||
prop.load(fstream);
|
prop.load(stream);
|
||||||
for (int i = 0; i < validParameters.length; i++) {
|
for (int i = 0; i < validParameters.length; i++) {
|
||||||
if (prop.getProperty(validParameters[i]) == null) {
|
if (prop.getProperty(validParameters[i]) == null) {
|
||||||
throw new CoffeeException("missing the parameter \"" + validParameters[i] + "\" in the configuration file " + filename);
|
throw new CoffeeException("missing the parameter \"" + validParameters[i] + "\" in the configuration file " + filename);
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
*
|
*
|
||||||
* This file is part of the Contiki operating system.
|
* This file is part of the Contiki operating system.
|
||||||
*
|
*
|
||||||
* $Id: CoffeeFile.java,v 1.4 2009/08/10 12:56:13 nvt-se Exp $
|
* $Id: CoffeeFile.java,v 1.5 2009/08/11 14:42:58 nvt-se Exp $
|
||||||
*
|
*
|
||||||
* @author Nicolas Tsiftes
|
* @author Nicolas Tsiftes
|
||||||
*
|
*
|
||||||
@ -103,10 +103,10 @@ public class CoffeeFile {
|
|||||||
|
|
||||||
FileOutputStream fOut = new FileOutputStream(filename);
|
FileOutputStream fOut = new FileOutputStream(filename);
|
||||||
|
|
||||||
if(microLog != null) {
|
if (microLog != null) {
|
||||||
for(i = 0; i < microLog.getLogRecords(); i++) {
|
for (i = 0; i < microLog.getLogRecords(); i++) {
|
||||||
bytes = microLog.getRegion(i);
|
bytes = microLog.getRegion(i);
|
||||||
if(bytes == null) {
|
if (bytes == null) {
|
||||||
bytes = new byte[microLog.getLogRecordSize()];
|
bytes = new byte[microLog.getLogRecordSize()];
|
||||||
coffeeFS.getImage().read(bytes, bytes.length, i * microLog.getLogRecordSize());
|
coffeeFS.getImage().read(bytes, bytes.length, i * microLog.getLogRecordSize());
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
*
|
*
|
||||||
* This file is part of the Contiki operating system.
|
* This file is part of the Contiki operating system.
|
||||||
*
|
*
|
||||||
* $Id: CoffeeMicroLog.java,v 1.1 2009/08/10 12:51:52 nvt-se Exp $
|
* $Id: CoffeeMicroLog.java,v 1.2 2009/08/11 14:42:58 nvt-se Exp $
|
||||||
*
|
*
|
||||||
* @author Nicolas Tsiftes
|
* @author Nicolas Tsiftes
|
||||||
*
|
*
|
||||||
@ -81,8 +81,8 @@ public class CoffeeMicroLog extends CoffeeFile {
|
|||||||
int headerSize = header.rawLength();
|
int headerSize = header.rawLength();
|
||||||
int indexSize = logRecords * 2;
|
int indexSize = logRecords * 2;
|
||||||
|
|
||||||
for(int i = logRecords - 1; i >= 0; i--) {
|
for (int i = logRecords - 1; i >= 0; i--) {
|
||||||
if(index[i] - 1 == region) {
|
if (index[i] - 1 == region) {
|
||||||
byte[] bytes = new byte[logRecordSize];
|
byte[] bytes = new byte[logRecordSize];
|
||||||
coffeeFS.getImage().read(bytes, bytes.length,
|
coffeeFS.getImage().read(bytes, bytes.length,
|
||||||
recordStart + i * logRecordSize);
|
recordStart + i * logRecordSize);
|
||||||
|
Loading…
Reference in New Issue
Block a user