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