other-licenses/7zstub/src/Common/Wildcard.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial