summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2006-04-01 14:39:45 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2006-04-01 14:39:45 +0000
commit1013d207f30207ea81c8d044fcb1ddc6f79e5a64 (patch)
tree9f3e8af8d5c17133980aaf0ff683d4260270447d /src
parent9c67466cde9ed52d96e0de9be1098d55c6912789 (diff)
Attempt to add the ability to listing file entries in a .torrent
file. This feature is not yet complete. * src/prefs.h (PREF_TORRENT_SHOW_FILES): New definition * src/TorrentMan.cc (getMultiFileEntries): New function. (getName): New function. * src/TorrentMan.h (getMultiFileEntries): New function. (getName): New function. * src/main.cc (main): Use above 2 funtion.
Diffstat (limited to 'src')
-rw-r--r--src/PeerInteractionCommand.cc2
-rw-r--r--src/TorrentMan.cc8
-rw-r--r--src/TorrentMan.h3
-rw-r--r--src/main.cc20
-rw-r--r--src/prefs.h2
5 files changed, 33 insertions, 2 deletions
diff --git a/src/PeerInteractionCommand.cc b/src/PeerInteractionCommand.cc
index 64f83fc6..80dac752 100644
--- a/src/PeerInteractionCommand.cc
+++ b/src/PeerInteractionCommand.cc
@@ -336,7 +336,7 @@ Piece PeerInteractionCommand::getNewPieceAndSendInterest() {
PendingMessage pendingMessage(PeerMessage::NOT_INTERESTED, peerConnection);
sendMessageQueue->addPendingMessage(pendingMessage);
} else {
- e->logger->debug("CUID#%d - starting download for piece #%d", cuid, piece.getIndex());
+ e->logger->debug("CUID#%d - starting download for piece index=%d", cuid, piece.getIndex());
e->logger->debug("CUID#%d - try to send interested", cuid);
PendingMessage pendingMessage(PeerMessage::INTERESTED, peerConnection);
sendMessageQueue->addPendingMessage(pendingMessage);
diff --git a/src/TorrentMan.cc b/src/TorrentMan.cc
index d8d2f030..275547aa 100644
--- a/src/TorrentMan.cc
+++ b/src/TorrentMan.cc
@@ -381,6 +381,14 @@ void TorrentMan::setup(string metaInfoFile) {
setupComplete = true;
}
+const MultiFileEntries& TorrentMan::getMultiFileEntries() const {
+ return multiFileEntries;
+}
+
+string TorrentMan::getName() const {
+ return name;
+}
+
bool TorrentMan::hasPiece(int index) const {
return bitfield->isBitSet(index);
}
diff --git a/src/TorrentMan.h b/src/TorrentMan.h
index a4f6cedd..25b24a86 100644
--- a/src/TorrentMan.h
+++ b/src/TorrentMan.h
@@ -223,6 +223,9 @@ public:
int countUsedPiece() const { return usedPieces.size(); }
int countAdvertisedPiece() const { return haves.size(); }
+ const MultiFileEntries& getMultiFileEntries() const;
+ string getName() const;
+
enum FILE_MODE {
SINGLE,
MULTI
diff --git a/src/main.cc b/src/main.cc
index 645c1768..ca730444 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -577,7 +577,25 @@ int main(int argc, char* argv[]) {
te->torrentMan->logger = logger;
te->torrentMan->setup(torrentFile.empty() ?
downloadedTorrentFile : torrentFile);
-
+ if(op->get(PREF_TORRENT_SHOW_FILES) == V_TRUE) {
+ cout << "File listing:" << endl;
+ switch(te->torrentMan->getFileMode()) {
+ case TorrentMan::SINGLE:
+ printf("%s %s\nBytes", te->torrentMan->getName().c_str(),
+ Util::llitos(te->torrentMan->getTotalLength(), true).c_str());
+ break;
+ case TorrentMan::MULTI: {
+ const MultiFileEntries& entries = te->torrentMan->getMultiFileEntries();
+ for(MultiFileEntries::const_iterator itr = entries.begin();
+ itr != entries.end(); itr++) {
+ printf("%s %s\nBytes", itr->path.c_str(),
+ Util::llitos(itr->length, true).c_str());
+ break;
+ }
+ }
+ }
+ exit(0);
+ }
PeerListenCommand* listenCommand =
new PeerListenCommand(te->torrentMan->getNewCuid(), te);
int port = listenCommand->bindPort(6881, 6999);
diff --git a/src/prefs.h b/src/prefs.h
index bc6525c6..ae8c57af 100644
--- a/src/prefs.h
+++ b/src/prefs.h
@@ -88,5 +88,7 @@
*/
// values: 1*digit
#define PREF_PEER_CONNECTION_TIMEOUT "peer_connection_timeout"
+// values: true | false
+#define PREF_TORRENT_SHOW_FILES "torrent_show_files"
#endif // _D_PREFS_H_