/* */ #ifndef D_DEFAULT_BT_PROGRESS_INFO_FILE_H #define D_DEFAULT_BT_PROGRESS_INFO_FILE_H #include "BtProgressInfoFile.h" #include namespace aria2 { class DownloadContext; class PieceStorage; class PeerStorage; class BtRuntime; class Option; class IOFile; class DefaultBtProgressInfoFile : public BtProgressInfoFile { private: std::shared_ptr dctx_; std::shared_ptr pieceStorage_; #ifdef ENABLE_BITTORRENT std::shared_ptr peerStorage_; std::shared_ptr btRuntime_; #endif // ENABLE_BITTORRENT const Option* option_; std::string filename_; // Last SHA1 digest value of the content written. Initially, this // is empty string. This is used to avoid to write same content // repeatedly, which could wake up disk that may be sleeping. std::string lastDigest_; bool isTorrentDownload(); void save(IOFile& fp); public: DefaultBtProgressInfoFile(const std::shared_ptr& btContext, const std::shared_ptr& pieceStorage, const Option* option); virtual ~DefaultBtProgressInfoFile(); virtual std::string getFilename() CXX11_OVERRIDE { return filename_; } virtual bool exists() CXX11_OVERRIDE; virtual void save() CXX11_OVERRIDE; virtual void load() CXX11_OVERRIDE; virtual void removeFile() CXX11_OVERRIDE; // re-set filename using current dctx_. virtual void updateFilename() CXX11_OVERRIDE; #ifdef ENABLE_BITTORRENT // for torrents void setPeerStorage(const std::shared_ptr& peerStorage); void setBtRuntime(const std::shared_ptr& btRuntime); #endif // ENABLE_BITTORRENT static const std::string& getSuffix() { static std::string suffix = ".aria2"; return suffix; } }; } // namespace aria2 #endif // D_DEFAULT_BT_PROGRESS_INFO_FILE_H