/* */ #include "FtpDownloadCommand.h" #include "Request.h" #include "Socket.h" #include "Segment.h" #include "DownloadEngine.h" #include "RequestGroup.h" #include "prefs.h" #include "Option.h" #include "FtpFinishDownloadCommand.h" #include "FtpConnection.h" #include "Logger.h" #include "FileEntry.h" #include "SocketRecvBuffer.h" namespace aria2 { FtpDownloadCommand::FtpDownloadCommand (cuid_t cuid, const SharedHandle& req, const SharedHandle& fileEntry, RequestGroup* requestGroup, const SharedHandle& ftpConnection, DownloadEngine* e, const SocketHandle& dataSocket, const SocketHandle& ctrlSocket) :DownloadCommand(cuid, req, fileEntry, requestGroup, e, dataSocket, SharedHandle (new SocketRecvBuffer(dataSocket))), ftpConnection_(ftpConnection), ctrlSocket_(ctrlSocket) {} FtpDownloadCommand::~FtpDownloadCommand() {} bool FtpDownloadCommand::prepareForNextSegment() { if(getOption()->getAsBool(PREF_FTP_REUSE_CONNECTION) && static_cast (getFileEntry()->gtoloff(getSegments().front()->getPositionToWrite())) == getFileEntry()->getLength()) { Command* command = new FtpFinishDownloadCommand (getCuid(), getRequest(), getFileEntry(), getRequestGroup(), ftpConnection_, getDownloadEngine(), ctrlSocket_); getDownloadEngine()->addCommand(command); if(getRequestGroup()->downloadFinished()) { // To run checksum checking, we had to call following function here. DownloadCommand::prepareForNextSegment(); } return true; } else { return DownloadCommand::prepareForNextSegment(); } } off_t FtpDownloadCommand::getRequestEndOffset() const { return getFileEntry()->getLength(); } } // namespace aria2