view src/win32/7zip/7z/CPP/Common/Wildcard.h @ 1:f9f4f1b99eed

importing src directory
author Robert McIntyre <rlm@mit.edu>
date Sat, 03 Mar 2012 10:31:27 -0600
parents
children
line wrap: on
line source
1 // Common/Wildcard.h
3 #ifndef __COMMON_WILDCARD_H
4 #define __COMMON_WILDCARD_H
6 #include "MyString.h"
8 int CompareFileNames(const UString &s1, const UString &s2);
10 void SplitPathToParts(const UString &path, UStringVector &pathParts);
11 void SplitPathToParts(const UString &path, UString &dirPrefix, UString &name);
12 UString ExtractDirPrefixFromPath(const UString &path);
13 UString ExtractFileNameFromPath(const UString &path);
14 bool DoesNameContainWildCard(const UString &path);
15 bool CompareWildCardWithName(const UString &mask, const UString &name);
17 namespace NWildcard {
19 struct CItem
20 {
21 UStringVector PathParts;
22 bool Recursive;
23 bool ForFile;
24 bool ForDir;
25 bool CheckPath(const UStringVector &pathParts, bool isFile) const;
26 };
28 class CCensorNode
29 {
30 CCensorNode *Parent;
31 bool CheckPathCurrent(bool include, const UStringVector &pathParts, bool isFile) const;
32 void AddItemSimple(bool include, CItem &item);
33 bool CheckPath(UStringVector &pathParts, bool isFile, bool &include) const;
34 public:
35 CCensorNode(): Parent(0) { };
36 CCensorNode(const UString &name, CCensorNode *parent): Name(name), Parent(parent) { };
37 UString Name;
38 CObjectVector<CCensorNode> SubNodes;
39 CObjectVector<CItem> IncludeItems;
40 CObjectVector<CItem> ExcludeItems;
42 int FindSubNode(const UString &path) const;
44 void AddItem(bool include, CItem &item);
45 void AddItem(bool include, const UString &path, bool recursive, bool forFile, bool forDir);
46 void AddItem2(bool include, const UString &path, bool recursive);
48 bool NeedCheckSubDirs() const;
49 bool AreThereIncludeItems() const;
51 bool CheckPath(const UString &path, bool isFile, bool &include) const;
52 bool CheckPath(const UString &path, bool isFile) const;
54 bool CheckPathToRoot(bool include, UStringVector &pathParts, bool isFile) const;
55 // bool CheckPathToRoot(const UString &path, bool isFile, bool include) const;
56 void ExtendExclude(const CCensorNode &fromNodes);
57 };
59 struct CPair
60 {
61 UString Prefix;
62 CCensorNode Head;
63 CPair(const UString &prefix): Prefix(prefix) { };
64 };
66 class CCensor
67 {
68 int FindPrefix(const UString &prefix) const;
69 public:
70 CObjectVector<CPair> Pairs;
71 bool AllAreRelative() const
72 { return (Pairs.Size() == 1 && Pairs.Front().Prefix.IsEmpty()); }
73 void AddItem(bool include, const UString &path, bool recursive);
74 bool CheckPath(const UString &path, bool isFile) const;
75 void ExtendExclude();
76 };
78 }
80 #endif