init
This commit is contained in:
commit
7799808287
7 changed files with 84 additions and 0 deletions
5
.vscode/settings.json
vendored
Normal file
5
.vscode/settings.json
vendored
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"editor.insertSpaces": false,
|
||||||
|
"editor.tabSize": 4,
|
||||||
|
"editor.detectIndentation": false
|
||||||
|
}
|
23
LICENSE
Normal file
23
LICENSE
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
Boost Software License - Version 1.0 - August 17th, 2003
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person or organization
|
||||||
|
obtaining a copy of the software and accompanying documentation covered by
|
||||||
|
this license (the "Software") to use, reproduce, display, distribute,
|
||||||
|
execute, and transmit the Software, and to prepare derivative works of the
|
||||||
|
Software, and to permit third-parties to whom the Software is furnished to
|
||||||
|
do so, all subject to the following:
|
||||||
|
|
||||||
|
The copyright notices in the Software and this entire statement, including
|
||||||
|
the above license grant, this restriction and the following disclaimer,
|
||||||
|
must be included in all copies of the Software, in whole or in part, and
|
||||||
|
all derivative works of the Software, unless such copies or derivative
|
||||||
|
works are solely in the form of machine-executable object code generated by
|
||||||
|
a source language processor.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||||
|
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||||
|
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||||
|
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
DEALINGS IN THE SOFTWARE.
|
3
README.md
Normal file
3
README.md
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
# wildmatch
|
||||||
|
|
||||||
|
wildmatch — это библиотека для сопоставления шаблонов в стиле git/rsync.
|
10
dub.json
Normal file
10
dub.json
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"authors": [
|
||||||
|
"Alexander Zhirov"
|
||||||
|
],
|
||||||
|
"copyright": "Copyright © 2025, Alexander Zhirov",
|
||||||
|
"description": "wildmatch is a library for git/rsync-style pattern matching.",
|
||||||
|
"license": "BSL-1.0",
|
||||||
|
"name": "wildmatch",
|
||||||
|
"targetType": "library"
|
||||||
|
}
|
5
dub.selections.json
Normal file
5
dub.selections.json
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"fileVersion": 1,
|
||||||
|
"versions": {
|
||||||
|
}
|
||||||
|
}
|
4
dub.settings.json
Normal file
4
dub.settings.json
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"defaultArchitecture": "x86_64",
|
||||||
|
"defaultCompiler": "ldc2"
|
||||||
|
}
|
34
source/wildmatch.d
Normal file
34
source/wildmatch.d
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
module wildmatch;
|
||||||
|
|
||||||
|
import std.string : fromStringz;
|
||||||
|
import std.conv : to;
|
||||||
|
|
||||||
|
extern(C):
|
||||||
|
/** Коды результата */
|
||||||
|
enum WM_MATCH = 0; // Совпадение
|
||||||
|
enum WM_NOMATCH = 1; // Не совпало
|
||||||
|
|
||||||
|
/** Флаги */
|
||||||
|
enum WM_NOESCAPE = 0x01; // Отключить экранирование обратным слешем
|
||||||
|
enum WM_PATHNAME = 0x02; // '/' должен совпадать только с '/'
|
||||||
|
enum WM_PERIOD = 0x04; // '.' должен совпадать только с '.'
|
||||||
|
enum WM_LEADING_DIR = 0x08; // Игнорировать /<хвост> после совпадения
|
||||||
|
enum WM_CASEFOLD = 0x10; // Регистронезависимо
|
||||||
|
enum WM_PREFIX_DIRS = 0x20; // Не используется
|
||||||
|
enum WM_WILDSTAR = 0x40; // '**' совпадает и через '/'
|
||||||
|
|
||||||
|
alias WM_IGNORECASE = WM_CASEFOLD;
|
||||||
|
alias WM_FILE_NAME = WM_PATHNAME;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Сопоставляет строку с шаблоном (fnmatch-подобно).
|
||||||
|
* @param pattern NUL-терминированный шаблон
|
||||||
|
* @param str NUL-терминированная строка
|
||||||
|
* @param flags комбинация WM_* флагов
|
||||||
|
* @return WM_MATCH или WM_NOMATCH
|
||||||
|
*/
|
||||||
|
private int wildmatch(const(char)* pattern, const(char)* str, int flags);
|
||||||
|
|
||||||
|
bool dwildmatch(string pattern, string str, int flags = WM_PATHNAME) {
|
||||||
|
return wildmatch(pattern.ptr, str.ptr, flags) == WM_MATCH;
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue