rlm@1: // Common/Wildcard.h rlm@1: rlm@1: #ifndef __COMMON_WILDCARD_H rlm@1: #define __COMMON_WILDCARD_H rlm@1: rlm@1: #include "MyString.h" rlm@1: rlm@1: int CompareFileNames(const UString &s1, const UString &s2); rlm@1: rlm@1: void SplitPathToParts(const UString &path, UStringVector &pathParts); rlm@1: void SplitPathToParts(const UString &path, UString &dirPrefix, UString &name); rlm@1: UString ExtractDirPrefixFromPath(const UString &path); rlm@1: UString ExtractFileNameFromPath(const UString &path); rlm@1: bool DoesNameContainWildCard(const UString &path); rlm@1: bool CompareWildCardWithName(const UString &mask, const UString &name); rlm@1: rlm@1: namespace NWildcard { rlm@1: rlm@1: struct CItem rlm@1: { rlm@1: UStringVector PathParts; rlm@1: bool Recursive; rlm@1: bool ForFile; rlm@1: bool ForDir; rlm@1: bool CheckPath(const UStringVector &pathParts, bool isFile) const; rlm@1: }; rlm@1: rlm@1: class CCensorNode rlm@1: { rlm@1: CCensorNode *Parent; rlm@1: bool CheckPathCurrent(bool include, const UStringVector &pathParts, bool isFile) const; rlm@1: void AddItemSimple(bool include, CItem &item); rlm@1: bool CheckPath(UStringVector &pathParts, bool isFile, bool &include) const; rlm@1: public: rlm@1: CCensorNode(): Parent(0) { }; rlm@1: CCensorNode(const UString &name, CCensorNode *parent): Name(name), Parent(parent) { }; rlm@1: UString Name; rlm@1: CObjectVector SubNodes; rlm@1: CObjectVector IncludeItems; rlm@1: CObjectVector ExcludeItems; rlm@1: rlm@1: int FindSubNode(const UString &path) const; rlm@1: rlm@1: void AddItem(bool include, CItem &item); rlm@1: void AddItem(bool include, const UString &path, bool recursive, bool forFile, bool forDir); rlm@1: void AddItem2(bool include, const UString &path, bool recursive); rlm@1: rlm@1: bool NeedCheckSubDirs() const; rlm@1: bool AreThereIncludeItems() const; rlm@1: rlm@1: bool CheckPath(const UString &path, bool isFile, bool &include) const; rlm@1: bool CheckPath(const UString &path, bool isFile) const; rlm@1: rlm@1: bool CheckPathToRoot(bool include, UStringVector &pathParts, bool isFile) const; rlm@1: // bool CheckPathToRoot(const UString &path, bool isFile, bool include) const; rlm@1: void ExtendExclude(const CCensorNode &fromNodes); rlm@1: }; rlm@1: rlm@1: struct CPair rlm@1: { rlm@1: UString Prefix; rlm@1: CCensorNode Head; rlm@1: CPair(const UString &prefix): Prefix(prefix) { }; rlm@1: }; rlm@1: rlm@1: class CCensor rlm@1: { rlm@1: int FindPrefix(const UString &prefix) const; rlm@1: public: rlm@1: CObjectVector Pairs; rlm@1: bool AllAreRelative() const rlm@1: { return (Pairs.Size() == 1 && Pairs.Front().Prefix.IsEmpty()); } rlm@1: void AddItem(bool include, const UString &path, bool recursive); rlm@1: bool CheckPath(const UString &path, bool isFile) const; rlm@1: void ExtendExclude(); rlm@1: }; rlm@1: rlm@1: } rlm@1: rlm@1: #endif