1// 2// This file is part of the aMule Project. 3// 4// Copyright (c) 2007-2011 aMule Team ( admin@amule.org / http://www.amule.org ) 5// Copyright (c) 2007-2011 Johannes Krampf ( wuischke@amule.org ) 6// 7// Any parts of this program derived from the xMule, lMule or eMule project, 8// or contributed by third-party developers are copyrighted by their 9// respective authors. 10// 11// This program is free software; you can redistribute it and/or modify 12// it under the terms of the GNU General Public License as published by 13// the Free Software Foundation; either version 2 of the License, or 14// (at your option) any later version. 15// 16// This program is distributed in the hope that it will be useful, 17// but WITHOUT ANY WARRANTY; without even the implied warranty of 18// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19// GNU General Public License for more details. 20// 21// You should have received a copy of the GNU General Public License 22// along with this program; if not, write to the Free Software 23// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 24// 25 26 27#ifndef __MULECOLLECTION_H__ 28#define __MULECOLLECTION_H__ 29 30#include <string> 31#include <vector> 32 33#ifndef __MINGW32__ 34#include "Types.h" 35#endif 36 37struct CollectionFile 38{ 39 std::string m_fileName; 40 uint64_t m_fileSize; 41 std::string m_fileHash; 42 43 CollectionFile( 44 const std::string &fileName = "", 45 uint64_t fileSize = 0, 46 const std::string &fileHash = ""); 47}; 48 49 50class CMuleCollection 51{ 52private: 53 std::vector<CollectionFile> vCollection; 54 55public: 56 CMuleCollection(); 57 ~CMuleCollection(); 58 59 bool Open(const std::string &File); 60 size_t GetFileCount() const { return vCollection.size(); } 61 62 std::string GetEd2kLink(size_t index) const; 63 std::string GetFileName(size_t index) const; 64 uint64_t GetFileSize(size_t index) const; 65 std::string GetFileHash(size_t index) const; 66 67private: 68 bool OpenBinary(const std::string &File); 69 bool OpenText(const std::string &File); 70 71 bool AddLink(const std::string &Link); 72 bool AddFile( 73 const std::string &fileName, 74 uint64_t fileSize, 75 const std::string &fileHash); 76 77 static bool IsValidHash(const std::string &fileHash); 78 79 template <typename intType> 80 intType ReadInt(std::ifstream& infile); 81 82 std::string ReadString(std::ifstream& infile, int TagType); 83}; 84 85#endif // __MULECOLLECTION_H__ 86 87