-
-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simple CreateTorrent test with progress.
- Loading branch information
Showing
2 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
src/com/frostwire/jlibtorrent/demo/CreateTorrentTest2.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package com.frostwire.jlibtorrent.demo; | ||
|
||
import com.frostwire.jlibtorrent.AlertListener; | ||
import com.frostwire.jlibtorrent.Session; | ||
import com.frostwire.jlibtorrent.alerts.Alert; | ||
import com.frostwire.jlibtorrent.alerts.SetPieceHashesAlert; | ||
import com.frostwire.jlibtorrent.swig.*; | ||
|
||
/** | ||
* @author gubatron | ||
* @author aldenml | ||
*/ | ||
public final class CreateTorrentTest2 { | ||
|
||
public static void main(String[] args) throws Throwable { | ||
final Session s = new Session(); | ||
|
||
s.addListener(new AlertListener() { | ||
@Override | ||
public int[] types() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void alert(Alert<?> alert) { | ||
|
||
if (alert instanceof SetPieceHashesAlert) { | ||
System.out.println(alert); | ||
} | ||
} | ||
}); | ||
|
||
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 | ||
s.setPieceHashes("test", t, "/Users/aldenml/Downloads", ec); | ||
|
||
if (ec.value() != 0) { | ||
System.out.println(ec.message()); | ||
} | ||
|
||
entry e = t.generate(); | ||
|
||
System.out.println(e.to_string()); | ||
|
||
System.out.println("Press ENTER to exit"); | ||
System.in.read(); | ||
} | ||
} |