1 /* 2 * HLLib 3 * Copyright (C) 2006-2010 Ryan Gregg 4 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Lesser General Public 7 * License as published by the Free Software Foundation; either 8 * version 2.1 of the License, or (at your option) any later 9 * version. 10 */ 11 12 #ifndef DIRECTORYFOLDER_H 13 #define DIRECTORYFOLDER_H 14 15 #include "DirectoryItem.h" 16 #include "DirectoryFile.h" 17 18 #include <vector> 19 20 namespace HLLib 21 { 22 class HLLIB_API CDirectoryFolder : public CDirectoryItem 23 { 24 private: 25 typedef std::vector<CDirectoryItem *> CDirectoryItemVector; 26 27 private: 28 CDirectoryItemVector *pDirectoryItemVector; 29 30 public: 31 CDirectoryFolder(CPackage *pPackage); 32 CDirectoryFolder(const hlChar *lpName, hlUInt uiID, hlVoid *pData, CPackage *pPackage, CDirectoryFolder *pParent); 33 virtual ~CDirectoryFolder(); 34 35 virtual HLDirectoryItemType GetType() const; 36 37 CDirectoryFolder *AddFolder(const hlChar *lpName, hlUInt uiID = HL_ID_INVALID, hlVoid *lpData = 0); 38 CDirectoryFile *AddFile(const hlChar *lpName, hlUInt uiID = HL_ID_INVALID, hlVoid *lpData = 0); 39 40 hlUInt GetCount() const; 41 CDirectoryItem *GetItem(hlUInt uiIndex); 42 const CDirectoryItem *GetItem(hlUInt uiIndex) const; 43 CDirectoryItem *GetItem(const hlChar *lpName, HLFindType eFind = HL_FIND_ALL); 44 const CDirectoryItem *GetItem(const hlChar *lpName, HLFindType eFind = HL_FIND_ALL) const; 45 CDirectoryItem *GetRelativeItem(const hlChar *lpPath, HLFindType eFind = HL_FIND_ALL); 46 const CDirectoryItem *GetRelativeItem(const hlChar *lpPath, HLFindType eFind = HL_FIND_ALL) const; 47 48 hlVoid Sort(HLSortField eField = HL_FIELD_NAME, HLSortOrder eOrder = HL_ORDER_ASCENDING, hlBool bRecurse = hlTrue); 49 50 CDirectoryItem *FindFirst(const hlChar *lpSearch, HLFindType eFind = HL_FIND_ALL); 51 const CDirectoryItem *FindFirst(const hlChar *lpSearch, HLFindType eFind = HL_FIND_ALL) const; 52 CDirectoryItem *FindNext(const CDirectoryItem *pItem, const hlChar *lpSearch, HLFindType eFind = HL_FIND_ALL); 53 const CDirectoryItem *FindNext(const CDirectoryItem *pItem, const hlChar *lpSearch, HLFindType eFind = HL_FIND_ALL) const; 54 55 hlUInt GetSize(hlBool bRecurse = hlTrue) const; 56 hlULongLong GetSizeEx(hlBool bRecurse = hlTrue) const; 57 hlUInt GetSizeOnDisk(hlBool bRecurse = hlTrue) const; 58 hlULongLong GetSizeOnDiskEx(hlBool bRecurse = hlTrue) const; 59 hlUInt GetFolderCount(hlBool bRecurse = hlTrue) const; 60 hlUInt GetFileCount(hlBool bRecurse = hlTrue) const; 61 62 virtual hlBool Extract(const hlChar *lpPath) const; 63 64 private: 65 hlInt Compare(const hlChar *lpString0, const hlChar *lpString1, HLFindType eFind) const; 66 hlBool Match(const hlChar *lpString, const hlChar *lpSearch, HLFindType eFind) const; 67 const CDirectoryItem *FindNext(const CDirectoryFolder *pFolder, const CDirectoryItem *pRelative, const hlChar *lpSearch, HLFindType eFind = HL_FIND_ALL) const; 68 }; 69 } 70 71 #endif 72