summaryrefslogtreecommitdiff
path: root/src/PeerInteractionCommand.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2006-04-16 14:38:19 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2006-04-16 14:38:19 +0000
commit2a84b9de43c759fb93aa7a0bb2d22d4b5f37af4e (patch)
tree8d12afe1fe42fb6903b900f1a4e3080f6bc2fcd1 /src/PeerInteractionCommand.cc
parent58633887e90b26c89dcf871dfa4873b73f4c5f6a (diff)
2006-04-16 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* src/TorrentConsoleDownloadEngine.cc (onPartialDownloadingCompletes): Renamed as onSelectiveDownloadingCompletes. (onSelectiveDownloadingCompletes): Updated message. To add DiskAdaptor which abstract DiskWriter family: * src/PeerConnection.cc: Use diskAdaptor instead of diskWriter. * src/PeerInteractionCommand.cc: Use diskAdaptor instead of diskWriter. * src/BitfieldMan.cc (isAllBitSet): bug fix. * src/TorrentMan.cc : Included CopyDiskAdaptor.h, DirectDiskAdaptor.h, MultiDiskAdaptor.h. (readFileEntry): Changed its arguments. (setup): setupDiskWriter is merged into this function. (setupDiskWriter): Removed. (setFileFilter): New function. (readFileEntryFromMetaInfoFile): Updated according to the changes made in readFileEntry. (getFilePath): Removed. (getTempFilePath): Removed. (getSegmentFilePath): Updated due to the removal of getFilePath. (fixFilename): Removed. (copySingleFile): Removed. (splitMultiFile): Removed. (deleteTempFile): Removed. (setFileEntriesToDownload): Removed. (isPartialDownloadingMode): Renamed as isSelectiveDownloadingMode. (isSelectiveDownloadingMode): New function. (setAllMultiFileRequestedState): Removed. (finishPartialDownloadingMode): Renamed as finishSelectiveDownloadingMode. (finishSelectiveDownloadingMode): New function. (getPartialTotalLength): Renamed as getSelectedTotalLength. (getSelectedTotalLength): New function. (onDownloadComplete): Use diskAdaptor. * src/MultiDiskWriter.cc (Constructor): Added the argument pieceLength (Range): Removed. (setMultiFileEntries): Renamed as setFileEntries. (setFileEntries): New function. * src/MultiDiskWriter.h [DiskWriterEntry](enabled): Removed. (pieceLength): New variable. * src/main.cc (printDownloadCompeleteMessage): New function. (torrentHandler): Use diskAdaptor instead of diskWriter. (main): Renamed torrent-show-files to show-files. Rewritten file contents listing. * src/TorrentMan.h (FileEntry): Removed. (multiFileTopDir): Removed. (multiFileEntries): Removed. (diskWriter): Removed. (diskAdaptor): New variable. * src/DefaultDiskWriter.h (totalLength): New variable. * src/DefaultDiskWriter.cc (initAndOpenFile): Added ftruncate. * src/TorrentDownloadEngine.cc (onEndOfRun): Use diskAdaptor instead of diskWriter. * src/TorrentConsoleDownloadEngine.h (partialDownloadLengthDiff): Renamed as selectedDownloadLengthDiff. (partialTotalLength): Renamed as selectedTotalLength. * src/AbstractDiskWriter.cc (openFile): If file exists, call openExistingFile, otherwise call initAndOpenFile. (closeFile): fd > 0, not fd != 0. * src/prefs.h (PREF_TORRENT_SHOW_FILES): Renamed as PREF_SHOW_FILES (PREF_SHOW_FILES): New definition.
Diffstat (limited to 'src/PeerInteractionCommand.cc')
-rw-r--r--src/PeerInteractionCommand.cc12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/PeerInteractionCommand.cc b/src/PeerInteractionCommand.cc
index 691f9043..2015f21b 100644
--- a/src/PeerInteractionCommand.cc
+++ b/src/PeerInteractionCommand.cc
@@ -274,9 +274,9 @@ void PeerInteractionCommand::receiveMessage() {
((long long int)message->getIndex())*e->torrentMan->pieceLength+message->getBegin();
e->logger->debug("CUID#%d - write block length = %d, offset=%lld",
cuid, message->getBlockLength(), offset);
- e->torrentMan->diskWriter->writeData(message->getBlock(),
- message->getBlockLength(),
- offset);
+ e->torrentMan->diskAdaptor->writeData(message->getBlock(),
+ message->getBlockLength(),
+ offset);
piece.completeBlock(slot.getBlockIndex());
sendMessageQueue->deleteRequestSlot(slot);
e->torrentMan->updatePiece(piece);
@@ -444,7 +444,7 @@ void PeerInteractionCommand::beforeSocketCheck() {
bool PeerInteractionCommand::checkPieceHash(const Piece& piece) {
long long int offset = ((long long int)piece.getIndex())*e->torrentMan->pieceLength;
- return e->torrentMan->diskWriter->sha1Sum(offset, piece.getLength()) ==
+ return e->torrentMan->diskAdaptor->sha1Sum(offset, piece.getLength()) ==
e->torrentMan->getPieceHash(piece.getIndex());
}
@@ -454,11 +454,11 @@ void PeerInteractionCommand::erasePieceOnDisk(const Piece& piece) {
memset(buf, 0, BUFSIZE);
long long int offset = ((long long int)piece.getIndex())*e->torrentMan->pieceLength;
for(int i = 0; i < piece.getLength()/BUFSIZE; i++) {
- e->torrentMan->diskWriter->writeData(buf, BUFSIZE, offset);
+ e->torrentMan->diskAdaptor->writeData(buf, BUFSIZE, offset);
offset += BUFSIZE;
}
int r = piece.getLength()%BUFSIZE;
if(r > 0) {
- e->torrentMan->diskWriter->writeData(buf, r, offset);
+ e->torrentMan->diskAdaptor->writeData(buf, r, offset);
}
}