2 * glob.c: Simple glob support for the class libraries
5 * Miguel de Icaza (miguel@ximian.com).
7 * (C) 2002 Ximian, Inc.
16 mono_glob_compile (const char *glob
)
18 regex_t
*compiled
= g_new (regex_t
, 1);
19 GString
*str
= g_string_new ("^");
22 for (p
= glob
; *p
; p
++){
25 g_string_append_c (str
, '.');
28 g_string_append (str
, ".*");
31 case '[': case ']': case '\\': case '(': case ')':
32 case '^': case '$': case '.':
33 g_string_append_c (str
, '\\');
36 g_string_append_c (str
, *p
);
39 g_string_append_c (str
, '$');
40 regcomp (compiled
, str
->str
, 0);
46 mono_glob_match (gpointer handle
, const char *str
)
48 regex_t
*compiled
= (regex_t
*) handle
;
50 return regexec (compiled
, str
, 0, NULL
, 0) == 0;
54 mono_glob_dispose (gpointer handle
)
56 regfree ((regex_t
*) handle
);