Minor improvements of coffee-manager.
This commit is contained in:
parent
c23bb4cc5c
commit
2f72cb043d
3 changed files with 32 additions and 35 deletions
|
@ -32,38 +32,40 @@
|
|||
|
||||
package se.sics.coffee;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.RandomAccessFile;
|
||||
|
||||
public class CoffeeImageFile implements CoffeeImage {
|
||||
private RandomAccessFile imageFile;
|
||||
private CoffeeConfiguration conf;
|
||||
private final RandomAccessFile imageFile;
|
||||
private final CoffeeConfiguration conf;
|
||||
|
||||
public CoffeeImageFile(String filename, CoffeeConfiguration conf) throws IOException {
|
||||
this.conf = conf;
|
||||
File file = new File(filename);
|
||||
imageFile = new RandomAccessFile(file, "rw");
|
||||
imageFile = new RandomAccessFile(filename, "rw");
|
||||
if (imageFile.length() == 0) {
|
||||
// Allocate a full file system image.
|
||||
imageFile.setLength(conf.fsSize);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CoffeeConfiguration getConfiguration() {
|
||||
return conf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(byte[] bytes, int size, int offset) throws IOException {
|
||||
imageFile.seek(conf.startOffset + offset);
|
||||
imageFile.read(bytes, 0, size);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(byte[] bytes, int size, int offset) throws IOException {
|
||||
imageFile.seek(conf.startOffset + offset);
|
||||
imageFile.write(bytes, 0, size);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void erase(int size, int offset) throws IOException {
|
||||
byte[] bytes = new byte[256];
|
||||
int chunkSize;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue