Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/elfmz/far2l.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorelfmz <fenix1905@tut.by>2021-12-31 14:08:45 +0300
committerelfmz <fenix1905@tut.by>2021-12-31 14:08:45 +0300
commitbe3e39d471034827e156370b465183248558b668 (patch)
tree5d2e040450ee2b6c1511b32c251643f00e646932 /far2l/src/filemask
parent6b7b5f7fe480107373a6ef3cbd6ee41378c93642 (diff)
continue sorting files..
Diffstat (limited to 'far2l/src/filemask')
-rw-r--r--far2l/src/filemask/BaseFileMask.hpp51
-rw-r--r--far2l/src/filemask/CFileMask.cpp112
-rw-r--r--far2l/src/filemask/CFileMask.hpp62
-rw-r--r--far2l/src/filemask/FileMasksProcessor.cpp119
-rw-r--r--far2l/src/filemask/FileMasksProcessor.hpp64
-rw-r--r--far2l/src/filemask/FileMasksWithExclude.cpp142
-rw-r--r--far2l/src/filemask/FileMasksWithExclude.hpp59
7 files changed, 609 insertions, 0 deletions
diff --git a/far2l/src/filemask/BaseFileMask.hpp b/far2l/src/filemask/BaseFileMask.hpp
new file mode 100644
index 00000000..be845799
--- /dev/null
+++ b/far2l/src/filemask/BaseFileMask.hpp
@@ -0,0 +1,51 @@
+#pragma once
+
+/*
+BaseFileMask.hpp
+
+Абстрактный класс, заведен для удобства работы с масками.
+*/
+/*
+Copyright (c) 1996 Eugene Roshal
+Copyright (c) 2000 Far Group
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+3. The name of the authors may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include "noncopyable.hpp"
+
+#include <WinCompat.h>
+
+class BaseFileMask : private NonCopyable
+{
+ public:
+ BaseFileMask() {}
+ virtual ~BaseFileMask() {}
+
+ public:
+ virtual bool Set(const wchar_t *Masks, DWORD Flags)=0;
+ virtual bool Compare(const wchar_t *Name) const =0;
+ virtual bool IsEmpty() const { return true; }
+
+};
diff --git a/far2l/src/filemask/CFileMask.cpp b/far2l/src/filemask/CFileMask.cpp
new file mode 100644
index 00000000..9ccb9a69
--- /dev/null
+++ b/far2l/src/filemask/CFileMask.cpp
@@ -0,0 +1,112 @@
+/*
+CFileMask.cpp
+
+Основной класс для работы с масками файлов. Использовать нужно именно его.
+*/
+/*
+Copyright (c) 1996 Eugene Roshal
+Copyright (c) 2000 Far Group
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+3. The name of the authors may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include "headers.hpp"
+
+#include "CFileMask.hpp"
+#include "FileMasksProcessor.hpp"
+#include "FileMasksWithExclude.hpp"
+#include "lang.hpp"
+#include "language.hpp"
+#include "message.hpp"
+#include "pathmix.hpp"
+
+CFileMask::CFileMask():
+ FileMask(nullptr)
+{
+}
+
+void CFileMask::Free()
+{
+ if (FileMask)
+ delete FileMask;
+
+ FileMask=nullptr;
+}
+
+/*
+ Инициализирует список масок. Принимает список, разделенных запятой или точкой
+ с запятой. Разрешается указывать маски исключения, отделив их от основных
+ символом '|' Возвращает FALSE при неудаче (например, одна из длина одной из
+ масок равна 0).
+*/
+
+bool CFileMask::Set(const wchar_t *Masks, DWORD Flags)
+{
+ Free();
+ bool Result=false;
+ int Silent=Flags & FMF_SILENT;
+ DWORD flags=0;
+
+ if (Flags & FMF_ADDASTERISK)
+ flags|=FMPF_ADDASTERISK;
+
+ if (Masks && *Masks)
+ {
+ if (FileMasksWithExclude::IsExcludeMask(Masks))
+ {
+ if (!(Flags&FMF_FORBIDEXCLUDE))
+ FileMask=new FileMasksWithExclude;
+ }
+ else
+ {
+ FileMask=new FileMasksProcessor;
+ }
+
+ if (FileMask)
+ Result=FileMask->Set(Masks, flags);
+
+ if (!Result)
+ Free();
+ }
+
+ if (!Silent && !Result)
+ Message(MSG_WARNING,1,MSG(MWarning),MSG(MIncorrectMask), MSG(MOk));
+
+ return Result;
+}
+
+// Возвращает TRUE, если список масок пустой
+bool CFileMask::IsEmpty()const
+{
+ return FileMask?FileMask->IsEmpty():true;
+}
+
+/* сравнить имя файла со списком масок
+ Возвращает TRUE в случае успеха.
+ Путь в имени файла игнорируется.
+*/
+bool CFileMask::Compare(const wchar_t *FileName) const
+{
+ return FileMask?FileMask->Compare(PointToName(FileName)):false;
+}
diff --git a/far2l/src/filemask/CFileMask.hpp b/far2l/src/filemask/CFileMask.hpp
new file mode 100644
index 00000000..bd4ab7dc
--- /dev/null
+++ b/far2l/src/filemask/CFileMask.hpp
@@ -0,0 +1,62 @@
+#pragma once
+
+/*
+CFileMask.hpp
+
+Основной класс для работы с масками файлов. Использовать нужно именно его.
+*/
+/*
+Copyright (c) 1996 Eugene Roshal
+Copyright (c) 2000 Far Group
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+3. The name of the authors may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include "BaseFileMask.hpp"
+#include "noncopyable.hpp"
+
+enum FM_FLAGS
+{
+ FMF_SILENT = 0x00000001,
+ FMF_FORBIDEXCLUDE = 0x00000002,
+ FMF_ADDASTERISK = 0x00000004
+};
+
+
+class CFileMask : private NonCopyable
+{
+ private:
+ BaseFileMask *FileMask;
+
+ public:
+ CFileMask();
+ ~CFileMask() { Free(); }
+
+ public:
+ bool Set(const wchar_t *Masks, DWORD Flags);
+ bool Compare(const wchar_t *Name)const;
+ bool IsEmpty()const;
+ void Free();
+
+};
diff --git a/far2l/src/filemask/FileMasksProcessor.cpp b/far2l/src/filemask/FileMasksProcessor.cpp
new file mode 100644
index 00000000..bc78d1cb
--- /dev/null
+++ b/far2l/src/filemask/FileMasksProcessor.cpp
@@ -0,0 +1,119 @@
+/*
+FileMasksProcessor.cpp
+
+Класс для работы с простыми масками файлов (не учитывается наличие масок
+исключения).
+*/
+/*
+Copyright (c) 1996 Eugene Roshal
+Copyright (c) 2000 Far Group
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+3. The name of the authors may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include "headers.hpp"
+
+
+#include "FileMasksProcessor.hpp"
+#include "processname.hpp"
+#include "StackHeapArray.hpp"
+
+FileMasksProcessor::FileMasksProcessor():
+ BaseFileMask(),
+ re(nullptr),
+ n(0)
+{
+}
+
+void FileMasksProcessor::Free()
+{
+ Masks.Free();
+
+ re.reset();
+ n = 0;
+}
+
+/*
+ Инициализирует список масок. Принимает список, разделенных запятой.
+ Возвращает FALSE при неудаче (например, одна из
+ длина одной из масок равна 0)
+*/
+
+bool FileMasksProcessor::Set(const wchar_t *masks, DWORD Flags)
+{
+ Free();
+ // разделителем масок является не только запятая, но и точка с запятой!
+ DWORD flags=ULF_PACKASTERISKS|ULF_PROCESSBRACKETS|ULF_SORT|ULF_UNIQUE;
+
+ if (Flags&FMPF_ADDASTERISK)
+ flags|=ULF_ADDASTERISK;
+
+ if (masks && *masks == L'/')
+ {
+ re.reset(new(std::nothrow) RegExp);
+ if (re && re->Compile(masks, OP_PERLSTYLE|OP_OPTIMIZE))
+ {
+ n = re->GetBracketsCount();
+ return true;
+ }
+ re.reset();
+ return false;
+ }
+
+ Masks.SetParameters(L',',L';',flags);
+ return Masks.Set(masks);
+}
+
+bool FileMasksProcessor::IsEmpty() const
+{
+ if (re)
+ {
+ return !n;
+ }
+
+ return Masks.IsEmpty();
+}
+
+/* сравнить имя файла со списком масок
+ Возвращает TRUE в случае успеха.
+ Путь к файлу в FileName НЕ игнорируется */
+bool FileMasksProcessor::Compare(const wchar_t *FileName) const
+{
+ if (re)
+ {
+ StackHeapArray<RegExpMatch> m(n);
+ int i = n;
+ return re->Search(ReStringView(FileName), m.Get(), i);
+ }
+
+ const wchar_t *MaskPtr; // указатель на текущую маску в списке
+ for (size_t MI = 0; nullptr!=(MaskPtr=Masks.Get(MI)); ++MI)
+ {
+ // SkipPath=FALSE, т.к. в CFileMask вызывается PointToName
+ if (CmpName(MaskPtr,FileName, false))
+ return true;
+ }
+
+ return false;
+}
diff --git a/far2l/src/filemask/FileMasksProcessor.hpp b/far2l/src/filemask/FileMasksProcessor.hpp
new file mode 100644
index 00000000..c63189be
--- /dev/null
+++ b/far2l/src/filemask/FileMasksProcessor.hpp
@@ -0,0 +1,64 @@
+#pragma once
+
+/*
+FileMasksProcessor.hpp
+
+Класс для работы с простыми масками файлов (не учитывается наличие масок
+исключения).
+*/
+/*
+Copyright (c) 1996 Eugene Roshal
+Copyright (c) 2000 Far Group
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+3. The name of the authors may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include "BaseFileMask.hpp"
+#include "udlist.hpp"
+#include "RegExp.hpp"
+
+enum FMP_FLAGS
+{
+ FMPF_ADDASTERISK = 0x00000001 // Добавлять '*', если маска не содержит
+ // ни одного из следующих
+ // символов: '*', '?', '.'
+};
+
+class FileMasksProcessor : public BaseFileMask
+{
+ public:
+ FileMasksProcessor();
+ virtual ~FileMasksProcessor() { Free(); }
+
+ public:
+ virtual bool Set(const wchar_t *Masks, DWORD Flags);
+ virtual bool Compare(const wchar_t *Name) const;
+ virtual bool IsEmpty() const;
+ void Free();
+
+ private:
+ UserDefinedList Masks; // список масок файлов
+ std::unique_ptr<RegExp> re;
+ int n = 0;
+};
diff --git a/far2l/src/filemask/FileMasksWithExclude.cpp b/far2l/src/filemask/FileMasksWithExclude.cpp
new file mode 100644
index 00000000..1fed7207
--- /dev/null
+++ b/far2l/src/filemask/FileMasksWithExclude.cpp
@@ -0,0 +1,142 @@
+/*
+FileMasksWithExclude.cpp
+
+Класс для работы со сложными масками файлов (учитывается наличие масок
+исключения).
+*/
+/*
+Copyright (c) 1996 Eugene Roshal
+Copyright (c) 2000 Far Group
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+3. The name of the authors may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include "headers.hpp"
+
+
+#include "FileMasksWithExclude.hpp"
+
+const wchar_t EXCLUDEMASKSEPARATOR=L'|';
+
+FileMasksWithExclude::FileMasksWithExclude():BaseFileMask()
+{
+}
+
+void FileMasksWithExclude::Free()
+{
+ Include.Free();
+ Exclude.Free();
+}
+
+bool FileMasksWithExclude::IsExcludeMask(const wchar_t *masks)
+{
+ return FindExcludeChar(masks)!=nullptr;
+}
+
+const wchar_t *FileMasksWithExclude::FindExcludeChar(const wchar_t *masks)
+{
+ const wchar_t *pExclude = masks;
+
+ if (*pExclude == '\\')
+ {
+ pExclude++;
+
+ while (*pExclude && (*pExclude != '\\' || *(pExclude-1) == GOOD_SLASH))
+ pExclude++;
+
+ while (*pExclude && *pExclude != EXCLUDEMASKSEPARATOR)
+ pExclude++;
+
+ if (*pExclude != EXCLUDEMASKSEPARATOR)
+ pExclude = nullptr;
+ }
+ else
+ {
+ pExclude = wcschr(masks,EXCLUDEMASKSEPARATOR);
+ }
+
+ return pExclude;
+}
+
+/*
+ Инициализирует список масок. Принимает список, разделенных запятой.
+ Возвращает FALSE при неудаче (например, одна из
+ длина одной из масок равна 0)
+*/
+
+bool FileMasksWithExclude::Set(const wchar_t *masks, DWORD Flags)
+{
+ Free();
+
+ if (nullptr==masks || !*masks) return FALSE;
+
+ size_t len=StrLength(masks)+1;
+ bool rc=false;
+ wchar_t *MasksStr=(wchar_t *) malloc(len*sizeof(wchar_t));
+
+ if (MasksStr)
+ {
+ rc=true;
+ wcscpy(MasksStr, masks);
+ wchar_t *pExclude = (wchar_t *) FindExcludeChar(MasksStr);
+
+ if (pExclude)
+ {
+ *pExclude=0;
+ ++pExclude;
+
+ if (*pExclude!=L'/' && wcschr(pExclude, EXCLUDEMASKSEPARATOR))
+ rc=FALSE;
+ }
+
+ if (rc)
+ {
+ rc = Include.Set(*MasksStr?MasksStr:L"*",(Flags&FMPF_ADDASTERISK)?FMPF_ADDASTERISK:0);
+
+ if (rc)
+ rc=Exclude.Set(pExclude, 0);
+ }
+ }
+
+ if (!rc)
+ Free();
+
+ if (MasksStr)
+ free(MasksStr);
+
+ return rc;
+}
+
+/* сравнить имя файла со списком масок
+ Возвращает TRUE в случае успеха.
+ Путь к файлу в FileName НЕ игнорируется */
+bool FileMasksWithExclude::Compare(const wchar_t *FileName) const
+{
+ return (Include.Compare(FileName) && !Exclude.Compare(FileName));
+}
+
+bool FileMasksWithExclude::IsEmpty() const
+{
+ return (Include.IsEmpty() && Exclude.IsEmpty());
+}
diff --git a/far2l/src/filemask/FileMasksWithExclude.hpp b/far2l/src/filemask/FileMasksWithExclude.hpp
new file mode 100644
index 00000000..a9a52ab9
--- /dev/null
+++ b/far2l/src/filemask/FileMasksWithExclude.hpp
@@ -0,0 +1,59 @@
+#pragma once
+
+/*
+FileMasksWithExclude.hpp
+
+Класс для работы со сложными масками файлов (учитывается наличие масок
+исключения).
+*/
+/*
+Copyright (c) 1996 Eugene Roshal
+Copyright (c) 2000 Far Group
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+3. The name of the authors may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include "FileMasksProcessor.hpp"
+
+extern const wchar_t EXCLUDEMASKSEPARATOR;
+
+class FileMasksWithExclude:public BaseFileMask
+{
+ private:
+ void Free();
+ static const wchar_t *FindExcludeChar(const wchar_t *masks);
+
+ public:
+ FileMasksWithExclude();
+ virtual ~FileMasksWithExclude() {}
+
+ public:
+ virtual bool Set(const wchar_t *Masks, DWORD Flags);
+ virtual bool Compare(const wchar_t *Name) const;
+ virtual bool IsEmpty() const;
+ static bool IsExcludeMask(const wchar_t *masks);
+
+ private:
+ FileMasksProcessor Include, Exclude;
+};