FileDB.h
资源名称:GGBT.rar [点击查看]
上传用户:lds876
上传日期:2013-05-25
资源大小:567k
文件大小:3k
源码类别:
P2P编程
开发平台:
Visual C++
- // FileDB.h: interface for the CFileDB class.
- //
- //////////////////////////////////////////////////////////////////////
- #if !defined(AFX_FILEDB_H__C9FE37C1_E0D5_4498_AECB_E0C59588D6A7__INCLUDED_)
- #define AFX_FILEDB_H__C9FE37C1_E0D5_4498_AECB_E0C59588D6A7__INCLUDED_
- #if _MSC_VER > 1000
- #pragma once
- #endif // _MSC_VER > 1000
- #include "Download.h"
- class CVal;
- class CDownload;
- class CFileDBItem
- {
- public :
- CFileDBItem(string strTorrentFileName,
- string strFileName,
- BLONG lFileSize,
- float lComplete,
- time_t tTime,
- string strHash,
- long lDirectoryID,
- time_t tModifiedTime,
- long lPieceCount,
- string strComment
- )
- {
- m_strFileName = strFileName;
- m_fComplete = lComplete;
- m_tTime = tTime;
- m_tModifiedTime = tModifiedTime;
- m_lFileSize = lFileSize;
- m_strTorrentFileName = strTorrentFileName;
- m_strHash = strHash;
- m_lDirectoryID = lDirectoryID;
- m_lPieceCount = lPieceCount;
- m_bBad = false;
- m_pDownload = 0;
- m_bUnclosed = false;
- m_fCompletePart = 0;
- m_strComment = strComment;
- //
- // special run parameter
- //
- m_bSpecialRunParameter = false;
- m_lUploadSpeedMode = 0;
- m_lUploadPeerMax = 0;
- m_lUploadSpeedMax = 0;
- m_lCompleteKeepSeedHour = -1;
- m_lPeersMin = -1;
- m_lPeersMax = -1;
- m_lConnectErrorMax = -1;
- m_lConnectIntval = -1;
- }
- void GetHave(vector<long>& vHave) const;
- void SetHave(const vector<long>& vHave, float fComplete);
- void GetHave(memstream& memBuf)const;
- void SetHave(const memstream& memBuf);
- string m_strComment;
- string m_strHash;
- string m_strTorrentFileName;
- string m_strFileName;
- BLONG m_lFileSize;
- float m_fComplete;
- time_t m_tTime;
- time_t m_tModifiedTime;
- long m_lDirectoryID;
- long m_lPieceCount;
- vector<long> m_vHave;
- vector<CSystemMsg> m_vMsg;
- vector<CSize> m_vUnneededFileInx;
- float m_fCompletePart;
- bool m_bBad;
- CDownload* m_pDownload;
- bool m_bUnclosed;
- //
- // special run parameter
- //
- bool m_bSpecialRunParameter;
- long m_lUploadSpeedMode;
- long m_lUploadPeerMax;
- long m_lUploadSpeedMax;
- long m_lCompleteKeepSeedHour;
- long m_lPeersMin;
- long m_lPeersMax;
- long m_lConnectErrorMax;
- long m_lConnectIntval;
- };
- class CFileDB
- {
- public:
- static bool WriteFile(string strFileName, const vector<CFileDBItem>& vFiles);
- static bool OpenFile(string strFileName, vector<CFileDBItem>& vFiles);
- static CVal* OpenFileEx(string strFileName) throw (string);
- static void CFileDB::WriteFileEx(string strFileName, CVal* pVal) throw (string);
- CFileDB();
- virtual ~CFileDB();
- private:
- static void CheckDB(CVal* pVal);
- };
- #endif // !defined(AFX_FILEDB_H__C9FE37C1_E0D5_4498_AECB_E0C59588D6A7__INCLUDED_)