FileDB.h
上传用户:lds876
上传日期:2013-05-25
资源大小:567k
文件大小:3k
源码类别:

P2P编程

开发平台:

Visual C++

  1. // FileDB.h: interface for the CFileDB class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #if !defined(AFX_FILEDB_H__C9FE37C1_E0D5_4498_AECB_E0C59588D6A7__INCLUDED_)
  5. #define AFX_FILEDB_H__C9FE37C1_E0D5_4498_AECB_E0C59588D6A7__INCLUDED_
  6. #if _MSC_VER > 1000
  7. #pragma once
  8. #endif // _MSC_VER > 1000
  9. #include "Download.h"
  10. class CVal;
  11. class CDownload;
  12. class CFileDBItem
  13. {
  14. public :
  15. CFileDBItem(string strTorrentFileName,
  16. string strFileName,
  17. BLONG lFileSize,
  18. float lComplete,
  19. time_t tTime,
  20. string  strHash,
  21. long lDirectoryID, 
  22. time_t tModifiedTime, 
  23. long lPieceCount, 
  24. string strComment
  25. )
  26. {
  27. m_strFileName = strFileName;
  28. m_fComplete = lComplete;
  29. m_tTime = tTime;
  30. m_tModifiedTime = tModifiedTime;
  31. m_lFileSize = lFileSize;
  32. m_strTorrentFileName = strTorrentFileName;
  33. m_strHash = strHash;
  34. m_lDirectoryID = lDirectoryID;
  35. m_lPieceCount = lPieceCount;
  36. m_bBad = false;
  37. m_pDownload = 0;
  38. m_bUnclosed = false;
  39. m_fCompletePart = 0;
  40. m_strComment = strComment;
  41. //
  42. // special run parameter
  43. //
  44. m_bSpecialRunParameter = false;
  45. m_lUploadSpeedMode = 0;
  46. m_lUploadPeerMax = 0;
  47. m_lUploadSpeedMax = 0;
  48. m_lCompleteKeepSeedHour = -1;
  49. m_lPeersMin = -1;
  50. m_lPeersMax = -1;
  51. m_lConnectErrorMax = -1;
  52. m_lConnectIntval = -1;
  53. }
  54. void GetHave(vector<long>& vHave) const;
  55. void SetHave(const vector<long>& vHave, float fComplete);
  56. void GetHave(memstream& memBuf)const;
  57. void SetHave(const memstream& memBuf);
  58. string m_strComment;
  59. string  m_strHash;
  60. string m_strTorrentFileName;
  61. string m_strFileName;
  62. BLONG m_lFileSize;
  63. float m_fComplete;
  64. time_t m_tTime;
  65. time_t m_tModifiedTime;
  66. long m_lDirectoryID;
  67. long m_lPieceCount;
  68. vector<long> m_vHave;
  69. vector<CSystemMsg> m_vMsg;
  70. vector<CSize> m_vUnneededFileInx;
  71. float m_fCompletePart;
  72. bool m_bBad;
  73. CDownload* m_pDownload;
  74. bool m_bUnclosed;
  75. //
  76. // special run parameter
  77. //
  78. bool m_bSpecialRunParameter;
  79. long m_lUploadSpeedMode;
  80. long m_lUploadPeerMax;
  81. long m_lUploadSpeedMax;
  82. long m_lCompleteKeepSeedHour;
  83. long m_lPeersMin;
  84. long m_lPeersMax;
  85. long m_lConnectErrorMax;
  86. long m_lConnectIntval;
  87. };
  88. class CFileDB  
  89. {
  90. public:
  91. static bool WriteFile(string strFileName, const vector<CFileDBItem>& vFiles);
  92. static bool OpenFile(string strFileName, vector<CFileDBItem>& vFiles);
  93. static CVal* OpenFileEx(string strFileName) throw (string);
  94. static void CFileDB::WriteFileEx(string strFileName, CVal* pVal) throw (string);
  95. CFileDB();
  96. virtual ~CFileDB();
  97. private:
  98. static void CheckDB(CVal* pVal);
  99. };
  100. #endif // !defined(AFX_FILEDB_H__C9FE37C1_E0D5_4498_AECB_E0C59588D6A7__INCLUDED_)