use of com.bonree.brfs.disknode.DiskReader in project BRFS by zhangnianli.
the class ReadMessageHandler method handle.
@Override
public void handle(DiskMessage msg, HandleResultCallback callback) {
HandleResult result = new HandleResult();
try {
String offsetParam = msg.getParams().get(PARAM_READ_OFFSET);
String lengthParam = msg.getParams().get(PARAM_READ_LENGTH);
int offset = offsetParam == null ? 0 : Integer.parseInt(offsetParam);
int length = lengthParam == null ? Integer.MAX_VALUE : Integer.parseInt(lengthParam);
DiskReader reader = new DiskReader(msg.getFilePath());
byte[] data = reader.read(offset, length);
result.setSuccess(true);
result.setData(data);
} catch (IOException e) {
result.setSuccess(false);
result.setCause(e);
} finally {
callback.completed(result);
}
}
Aggregations