aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/glob.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/glob.h')
-rw-r--r--src/glob.h31
1 files changed, 12 insertions, 19 deletions
diff --git a/src/glob.h b/src/glob.h
index 6222520..1577242 100644
--- a/src/glob.h
+++ b/src/glob.h
@@ -18,6 +18,8 @@
#ifndef __GLOB_H
#define __GLOB_H
+#include <string.h>
+
#include <glib.h>
#include <glib/gstdio.h>
@@ -26,29 +28,11 @@
namespace SciTECO {
-/*
- * Auxiliary functions
- */
-static inline bool
-is_glob_pattern(const gchar *str)
-{
- if (!str)
- return false;
-
- while (*str) {
- if (*str == '*' || *str == '?')
- return true;
- str++;
- }
-
- return false;
-}
-
class Globber {
GFileTest test;
gchar *dirname;
GDir *dir;
- GPatternSpec *pattern;
+ GRegex *pattern;
public:
Globber(const gchar *pattern,
@@ -56,6 +40,15 @@ public:
~Globber();
gchar *next(void);
+
+ static inline bool
+ is_pattern(const gchar *str)
+ {
+ return str && strpbrk(str, "*?[") != NULL;
+ }
+
+ static gchar *escape_pattern(const gchar *pattern);
+ static GRegex *compile_pattern(const gchar *pattern);
};
/*