1baa3858d3f5d128a5c8466b700098109edcad5f2repo sync// Common/Wildcard.h 2baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 3baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#ifndef __COMMON_WILDCARD_H 4baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#define __COMMON_WILDCARD_H 5baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 6baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#include "MyString.h" 7baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 8baa3858d3f5d128a5c8466b700098109edcad5f2repo syncint CompareFileNames(const UString &s1, const UString &s2); 9baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 10baa3858d3f5d128a5c8466b700098109edcad5f2repo syncvoid SplitPathToParts(const UString &path, UStringVector &pathParts); 11baa3858d3f5d128a5c8466b700098109edcad5f2repo syncvoid SplitPathToParts(const UString &path, UString &dirPrefix, UString &name); 12baa3858d3f5d128a5c8466b700098109edcad5f2repo syncUString ExtractDirPrefixFromPath(const UString &path); 13baa3858d3f5d128a5c8466b700098109edcad5f2repo syncUString ExtractFileNameFromPath(const UString &path); 14baa3858d3f5d128a5c8466b700098109edcad5f2repo syncbool DoesNameContainWildCard(const UString &path); 15baa3858d3f5d128a5c8466b700098109edcad5f2repo syncbool CompareWildCardWithName(const UString &mask, const UString &name); 16baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 17baa3858d3f5d128a5c8466b700098109edcad5f2repo syncnamespace NWildcard { 18baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 19baa3858d3f5d128a5c8466b700098109edcad5f2repo syncstruct CItem 20baa3858d3f5d128a5c8466b700098109edcad5f2repo sync{ 21baa3858d3f5d128a5c8466b700098109edcad5f2repo sync UStringVector PathParts; 22baa3858d3f5d128a5c8466b700098109edcad5f2repo sync bool Recursive; 23baa3858d3f5d128a5c8466b700098109edcad5f2repo sync bool ForFile; 24baa3858d3f5d128a5c8466b700098109edcad5f2repo sync bool ForDir; 25baa3858d3f5d128a5c8466b700098109edcad5f2repo sync bool CheckPath(const UStringVector &pathParts, bool isFile) const; 26baa3858d3f5d128a5c8466b700098109edcad5f2repo sync}; 27baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 28baa3858d3f5d128a5c8466b700098109edcad5f2repo syncclass CCensorNode 29baa3858d3f5d128a5c8466b700098109edcad5f2repo sync{ 30baa3858d3f5d128a5c8466b700098109edcad5f2repo sync CCensorNode *Parent; 31baa3858d3f5d128a5c8466b700098109edcad5f2repo sync bool CheckPathCurrent(bool include, const UStringVector &pathParts, bool isFile) const; 32baa3858d3f5d128a5c8466b700098109edcad5f2repo sync void AddItemSimple(bool include, CItem &item); 33baa3858d3f5d128a5c8466b700098109edcad5f2repo sync bool CheckPath(UStringVector &pathParts, bool isFile, bool &include) const; 34baa3858d3f5d128a5c8466b700098109edcad5f2repo syncpublic: 35baa3858d3f5d128a5c8466b700098109edcad5f2repo sync CCensorNode(): Parent(0) { }; 36baa3858d3f5d128a5c8466b700098109edcad5f2repo sync CCensorNode(const UString &name, CCensorNode *parent): Name(name), Parent(parent) { }; 37baa3858d3f5d128a5c8466b700098109edcad5f2repo sync UString Name; 38baa3858d3f5d128a5c8466b700098109edcad5f2repo sync CObjectVector<CCensorNode> SubNodes; 39baa3858d3f5d128a5c8466b700098109edcad5f2repo sync CObjectVector<CItem> IncludeItems; 40baa3858d3f5d128a5c8466b700098109edcad5f2repo sync CObjectVector<CItem> ExcludeItems; 41baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 42baa3858d3f5d128a5c8466b700098109edcad5f2repo sync int FindSubNode(const UString &path) const; 43baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 44baa3858d3f5d128a5c8466b700098109edcad5f2repo sync void AddItem(bool include, CItem &item); 45baa3858d3f5d128a5c8466b700098109edcad5f2repo sync void AddItem(bool include, const UString &path, bool recursive, bool forFile, bool forDir); 46baa3858d3f5d128a5c8466b700098109edcad5f2repo sync void AddItem2(bool include, const UString &path, bool recursive); 47baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 48baa3858d3f5d128a5c8466b700098109edcad5f2repo sync bool NeedCheckSubDirs() const; 49baa3858d3f5d128a5c8466b700098109edcad5f2repo sync bool AreThereIncludeItems() const; 50baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 51baa3858d3f5d128a5c8466b700098109edcad5f2repo sync bool CheckPath(const UString &path, bool isFile, bool &include) const; 52baa3858d3f5d128a5c8466b700098109edcad5f2repo sync bool CheckPath(const UString &path, bool isFile) const; 53baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 54baa3858d3f5d128a5c8466b700098109edcad5f2repo sync bool CheckPathToRoot(bool include, UStringVector &pathParts, bool isFile) const; 55baa3858d3f5d128a5c8466b700098109edcad5f2repo sync // bool CheckPathToRoot(const UString &path, bool isFile, bool include) const; 56baa3858d3f5d128a5c8466b700098109edcad5f2repo sync void ExtendExclude(const CCensorNode &fromNodes); 57baa3858d3f5d128a5c8466b700098109edcad5f2repo sync}; 58baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 59baa3858d3f5d128a5c8466b700098109edcad5f2repo syncstruct CPair 60baa3858d3f5d128a5c8466b700098109edcad5f2repo sync{ 61baa3858d3f5d128a5c8466b700098109edcad5f2repo sync UString Prefix; 62baa3858d3f5d128a5c8466b700098109edcad5f2repo sync CCensorNode Head; 63baa3858d3f5d128a5c8466b700098109edcad5f2repo sync CPair(const UString &prefix): Prefix(prefix) { }; 64baa3858d3f5d128a5c8466b700098109edcad5f2repo sync}; 65baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 66baa3858d3f5d128a5c8466b700098109edcad5f2repo syncclass CCensor 67baa3858d3f5d128a5c8466b700098109edcad5f2repo sync{ 68baa3858d3f5d128a5c8466b700098109edcad5f2repo sync int FindPrefix(const UString &prefix) const; 69baa3858d3f5d128a5c8466b700098109edcad5f2repo syncpublic: 70baa3858d3f5d128a5c8466b700098109edcad5f2repo sync CObjectVector<CPair> Pairs; 71baa3858d3f5d128a5c8466b700098109edcad5f2repo sync bool AllAreRelative() const 72baa3858d3f5d128a5c8466b700098109edcad5f2repo sync { return (Pairs.Size() == 1 && Pairs.Front().Prefix.IsEmpty()); } 73baa3858d3f5d128a5c8466b700098109edcad5f2repo sync void AddItem(bool include, const UString &path, bool recursive); 74baa3858d3f5d128a5c8466b700098109edcad5f2repo sync bool CheckPath(const UString &path, bool isFile) const; 75baa3858d3f5d128a5c8466b700098109edcad5f2repo sync void ExtendExclude(); 76baa3858d3f5d128a5c8466b700098109edcad5f2repo sync}; 77baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 78baa3858d3f5d128a5c8466b700098109edcad5f2repo sync} 79baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 80baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#endif 81