Исправление на null-terminated строку () для передачи в C-функцию
This commit is contained in:
parent
7799808287
commit
bc10ae70f4
1 changed files with 5 additions and 3 deletions
|
@ -1,6 +1,6 @@
|
|||
module wildmatch;
|
||||
|
||||
import std.string : fromStringz;
|
||||
import std.string : fromStringz, toStringz;
|
||||
import std.conv : to;
|
||||
|
||||
extern(C):
|
||||
|
@ -29,6 +29,8 @@ alias WM_FILE_NAME = WM_PATHNAME;
|
|||
*/
|
||||
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;
|
||||
bool dwildmatch(const string pattern, const string str, int flags = WM_PATHNAME) {
|
||||
auto patternZ = pattern.toStringz();
|
||||
auto strZ = str.toStringz();
|
||||
return wildmatch(patternZ, strZ, flags) == WM_MATCH;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue