Giter Site home page Giter Site logo

Comments (2)

aldenml avatar aldenml commented on July 19, 2024 1

Hi @rpithadia25, TorrentBuilder was meant to address the simple cases with a fluent api. Here I added a verbatim copy of a test in libtorrent for a v2 only #183, something similar can be done for hybrid.

error_code ec = new error_code();
file_storage fs = new file_storage();
fs.add_file_ex(ec, "test/A", 0x8002);
fs.add_file_ex(ec, "test/B", 0x4002);
create_torrent t = new create_torrent(fs, 0x4000, create_torrent.v2_only);

t.set_hash2(0, 0, sha256_hash.max());
t.set_hash2(0, 1, sha256_hash.max());
t.set_hash2(0, 2, sha256_hash.max());
// file 1 is a pad file
t.set_hash2(2, 0, sha256_hash.max());
t.set_hash2(2, 1, sha256_hash.max());

byte[] buffer = Vectors.byte_vector2bytes(t.generate().bencode());
torrent_info info = TorrentInfo.bdecode(buffer).swig();
assertTrue(info.info_hashes().has_v2());
assertFalse(info.info_hashes().has_v1());
assertEquals("A", info.files().file_name_ex(0));
assertTrue(info.files().pad_file_at(1));
assertEquals("B", info.files().file_name_ex(2));
assertEquals("test", info.name());

create_torrent t2 = new create_torrent(info);
byte[] buffer2 = Vectors.byte_vector2bytes(t2.generate().bencode());
assertArrayEquals(buffer, buffer2);

let me know if there is another specific case I can help with.

from libtorrent4j.

rpithadia25 avatar rpithadia25 commented on July 19, 2024

Thanks a lot for the quick response. I'll try this out.

from libtorrent4j.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.