Skip to content

Commit

Permalink
Simple CreateTorrent test.
Browse files Browse the repository at this point in the history
  • Loading branch information
aldenml committed Feb 27, 2015
1 parent 2f73962 commit a60fa51
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/com/frostwire/jlibtorrent/demo/CreateTorrentTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.frostwire.jlibtorrent.demo;

import com.frostwire.jlibtorrent.swig.*;

/**
* @author gubatron
* @author aldenml
*/
public final class CreateTorrentTest {

public static void main(String[] args) throws Throwable {
file_storage fs = new file_storage();

// recursively adds files in directories
libtorrent.add_files(fs, "/Users/aldenml/Downloads/Kellee");

create_torrent t = new create_torrent(fs);
t.add_tracker("http://my.tracker.com/announce");
t.set_creator("libtorrent example");

error_code ec = new error_code();
// reads the files and calculates the hashes
libtorrent.set_piece_hashes(t, "/Users/aldenml/Downloads", ec);

if (ec.value() != 0) {
System.out.println(ec.message());
}

entry e = t.generate();

System.out.println(e.to_string());
}
}

0 comments on commit a60fa51

Please sign in to comment.