diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2006-04-16 14:38:19 +0000 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2006-04-16 14:38:19 +0000 |
| commit | 2a84b9de43c759fb93aa7a0bb2d22d4b5f37af4e (patch) | |
| tree | 8d12afe1fe42fb6903b900f1a4e3080f6bc2fcd1 /src/AbstractDiskWriter.cc | |
| parent | 58633887e90b26c89dcf871dfa4873b73f4c5f6a (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/AbstractDiskWriter.cc')
| -rw-r--r-- | src/AbstractDiskWriter.cc | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/AbstractDiskWriter.cc b/src/AbstractDiskWriter.cc index 4e7cd642..74b35b63 100644 --- a/src/AbstractDiskWriter.cc +++ b/src/AbstractDiskWriter.cc @@ -36,7 +36,7 @@ AbstractDiskWriter::AbstractDiskWriter():fd(0) { } AbstractDiskWriter::~AbstractDiskWriter() { - if(fd != 0) { + if(fd > 0) { close(fd); } #ifdef ENABLE_SHA1DIGEST @@ -45,13 +45,16 @@ AbstractDiskWriter::~AbstractDiskWriter() { } void AbstractDiskWriter::openFile(const string& filename) { - if((fd = open(filename.c_str(), O_CREAT|O_RDWR, S_IRUSR|S_IWUSR)) < 0) { - throw new DlAbortEx(strerror(errno)); - } + File f(filename); + if(f.exists()) { + openExistingFile(filename); + } else { + initAndOpenFile(filename); + } } void AbstractDiskWriter::closeFile() { - if(fd != 0) { + if(fd > 0) { close(fd); fd = 0; } |
