1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/other-licenses/7zstub/src/Common/Wildcard.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,78 @@ 1.4 +// Common/Wildcard.h 1.5 + 1.6 +#ifndef __COMMON_WILDCARD_H 1.7 +#define __COMMON_WILDCARD_H 1.8 + 1.9 +#include "Common/String.h" 1.10 + 1.11 +void SplitPathToParts(const UString &path, UStringVector &pathParts); 1.12 +void SplitPathToParts(const UString &path, UString &dirPrefix, UString &name); 1.13 +UString ExtractDirPrefixFromPath(const UString &path); 1.14 +UString ExtractFileNameFromPath(const UString &path); 1.15 +bool DoesNameContainWildCard(const UString &path); 1.16 +bool CompareWildCardWithName(const UString &mask, const UString &name); 1.17 + 1.18 +namespace NWildcard { 1.19 + 1.20 +struct CItem 1.21 +{ 1.22 + UStringVector PathParts; 1.23 + bool Recursive; 1.24 + bool ForFile; 1.25 + bool ForDir; 1.26 + bool CheckPath(const UStringVector &pathParts, bool isFile) const; 1.27 +}; 1.28 + 1.29 +class CCensorNode 1.30 +{ 1.31 + CCensorNode *Parent; 1.32 + bool CheckPathCurrent(bool include, const UStringVector &pathParts, bool isFile) const; 1.33 + void AddItemSimple(bool include, CItem &item); 1.34 + bool CheckPath(UStringVector &pathParts, bool isFile, bool &include) const; 1.35 +public: 1.36 + CCensorNode(): Parent(0) { }; 1.37 + CCensorNode(const UString &name, CCensorNode *parent): Name(name), Parent(parent) { }; 1.38 + UString Name; 1.39 + CObjectVector<CCensorNode> SubNodes; 1.40 + CObjectVector<CItem> IncludeItems; 1.41 + CObjectVector<CItem> ExcludeItems; 1.42 + 1.43 + int FindSubNode(const UString &path) const; 1.44 + 1.45 + void AddItem(bool include, CItem &item); 1.46 + void AddItem(bool include, const UString &path, bool recursive, bool forFile, bool forDir); 1.47 + void AddItem2(bool include, const UString &path, bool recursive); 1.48 + 1.49 + bool NeedCheckSubDirs() const; 1.50 + bool AreThereIncludeItems() const; 1.51 + 1.52 + bool CheckPath(const UString &path, bool isFile, bool &include) const; 1.53 + bool CheckPath(const UString &path, bool isFile) const; 1.54 + 1.55 + bool CheckPathToRoot(bool include, UStringVector &pathParts, bool isFile) const; 1.56 + // bool CheckPathToRoot(const UString &path, bool isFile, bool include) const; 1.57 + void ExtendExclude(const CCensorNode &fromNodes); 1.58 +}; 1.59 + 1.60 +struct CPair 1.61 +{ 1.62 + UString Prefix; 1.63 + CCensorNode Head; 1.64 + CPair(const UString &prefix): Prefix(prefix) { }; 1.65 +}; 1.66 + 1.67 +class CCensor 1.68 +{ 1.69 + int FindPrefix(const UString &prefix) const; 1.70 +public: 1.71 + CObjectVector<CPair> Pairs; 1.72 + bool AllAreRelative() const 1.73 + { return (Pairs.Size() == 1 && Pairs.Front().Prefix.IsEmpty()); } 1.74 + void AddItem(bool include, const UString &path, bool recursive); 1.75 + bool CheckPath(const UString &path, bool isFile) const; 1.76 + void ExtendExclude(); 1.77 +}; 1.78 + 1.79 +} 1.80 + 1.81 +#endif