TOTorrent torrent = null;
String pieceSizeStr = (String) parameters.get("force_piece_size_pow2");
if(pieceSizeStr != null) {
try {
long pieceSize = 1l << Integer.parseInt(pieceSizeStr);
TOTorrentCreator creator = TOTorrentFactory.createFromFileOrDirWithFixedPieceLength(fSrc,url,pieceSize);
creator.addListener( this );
torrent = creator.create();
}catch(Exception e) {
e.printStackTrace();
return;
}
} else {
try {
TOTorrentCreator creator = TOTorrentFactory.createFromFileOrDirWithComputedPieceLength(fSrc,url);
creator.addListener( this );
torrent = creator.create();
} catch(Exception e) {
e.printStackTrace();
return;
}
}