Refactoring.

This commit is contained in:
nvt 2012-01-28 03:34:16 +01:00
parent 1e85183754
commit 4c75a250e6
10 changed files with 64 additions and 153 deletions

View file

@ -26,10 +26,6 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* This file is part of the Contiki operating system.
*
* $Id: CoffeeFS.java,v 1.5 2009/08/11 17:03:59 fros4943 Exp $
*
* @author Nicolas Tsiftes
*
*/
@ -64,7 +60,7 @@ public class CoffeeFS {
}
private int pageCount(long size) {
int headerSize = conf.NAME_LENGTH + conf.pageTypeSize * 2 + 6;
int headerSize = conf.nameLength + conf.pageTypeSize * 2 + 6;
return (int)(size + headerSize + conf.pageSize - 1) / conf.pageSize;
}
@ -100,8 +96,7 @@ public class CoffeeFS {
}
public CoffeeHeader readHeader(int page) throws IOException {
byte[] bytes = new byte[conf.NAME_LENGTH + conf.pageTypeSize * 2 + 6];
int index = 0;
byte[] bytes = new byte[conf.nameLength + conf.pageTypeSize * 2 + 6];
image.read(bytes, bytes.length, page * conf.pageSize);
CoffeeHeader header = new CoffeeHeader(this, page, bytes);
@ -184,16 +179,21 @@ public class CoffeeFS {
return true;
}
static class CoffeeException extends RuntimeException {
public CoffeeException(String message) {
super("Coffee error: " + message);
}
public static class CoffeeException extends RuntimeException {
private static final long serialVersionUID = 1146474084441011154L;
public CoffeeException(String message) {
super("Coffee error: " + message);
}
}
static class CoffeeFileException extends RuntimeException {
public CoffeeFileException(String message) {
super("Coffee file error: " + message);
}
public static class CoffeeFileException extends RuntimeException {
private static final long serialVersionUID = -2954553141887245203L;
public CoffeeFileException(String message) {
super("Coffee file error: " + message);
}
}