00001 // 00002 // HashDatabase.h 00003 // 00004 // Copyright (c) Shareaza Development Team, 2002-2005. 00005 // This file is part of SHAREAZA (www.shareaza.com) 00006 // 00007 // Shareaza is free software; you can redistribute it 00008 // and/or modify it under the terms of the GNU General Public License 00009 // as published by the Free Software Foundation; either version 2 of 00010 // the License, or (at your option) any later version. 00011 // 00012 // Shareaza is distributed in the hope that it will be useful, 00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 // GNU General Public License for more details. 00016 // 00017 // You should have received a copy of the GNU General Public License 00018 // along with Shareaza; if not, write to the Free Software 00019 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00020 // 00021 00022 #if !defined(AFX_HASHDATABASE_H__01733EE8_54F0_440D_BAD9_59EE0272DD1C__INCLUDED_) 00023 #define AFX_HASHDATABASE_H__01733EE8_54F0_440D_BAD9_59EE0272DD1C__INCLUDED_ 00024 00025 #pragma once 00026 00027 typedef struct 00028 { 00029 DWORD nIndex; 00030 DWORD nOffset; 00031 DWORD nLength; 00032 } HASHDB_INDEX_1000; 00033 00034 typedef struct 00035 { 00036 DWORD nIndex; 00037 DWORD nType; 00038 DWORD nOffset; 00039 DWORD nLength; 00040 } HASHDB_INDEX_1001, HASHDB_INDEX; 00041 00042 class CTigerTree; 00043 class CED2K; 00044 00045 00046 class CHashDatabase 00047 { 00048 // Construction 00049 public: 00050 CHashDatabase(); 00051 virtual ~CHashDatabase(); 00052 00053 // Attributes 00054 protected: 00055 CCriticalSection m_pSection; 00056 protected: 00057 CString m_sPath; 00058 CFile m_pFile; 00059 BOOL m_bOpen; 00060 protected: 00061 DWORD m_nOffset; 00062 HASHDB_INDEX* m_pIndex; 00063 DWORD m_nIndex; 00064 DWORD m_nBuffer; 00065 00066 // Operations 00067 public: 00068 BOOL Create(); 00069 void Close(); 00070 BOOL DeleteAll(DWORD nIndex); 00071 protected: 00072 HASHDB_INDEX* Lookup(DWORD nIndex, DWORD nType); 00073 HASHDB_INDEX* PrepareToStore(DWORD nIndex, DWORD nType, DWORD nLength); 00074 BOOL Erase(DWORD nIndex, DWORD nType); 00075 void Commit(); 00076 public: 00077 BOOL GetTiger(DWORD nIndex, CTigerTree* pTree); 00078 BOOL StoreTiger(DWORD nIndex, CTigerTree* pTree); 00079 BOOL DeleteTiger(DWORD nIndex); 00080 public: 00081 BOOL GetED2K(DWORD nIndex, CED2K* pSet); 00082 BOOL StoreED2K(DWORD nIndex, CED2K* pSet); 00083 BOOL DeleteED2K(DWORD nIndex); 00084 00085 }; 00086 00087 extern CHashDatabase LibraryHashDB; 00088 00089 #endif // !defined(AFX_HASHDATABASE_H__01733EE8_54F0_440D_BAD9_59EE0272DD1C__INCLUDED_)