@Override
public final boolean write(Torrent torrent, Range dataRange, ByteBuffer data)
throws IOException {
final List<TorrentFile> files = torrent.getFiles(dataRange);
for (final TorrentFile file : files) {
final Range rangeOnFile = file.getTorrentRange().intersection(
dataRange);
final Range range = file.getFileRange().intersection(
Range.getRangeByLength(
rangeOnFile.getStart() - file.getOffset(),
rangeOnFile.getLength()));
data.limit((int) (data.position() + range.getLength()));
if (!this.write(file, range, data))
return false;
}
return true;
}