summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib/fileutl.cc
diff options
context:
space:
mode:
authorChristian PERRIER <bubulle@debian.org>2013-08-17 07:58:13 +0200
committerChristian PERRIER <bubulle@debian.org>2013-08-17 07:58:13 +0200
commit010364b7b52af9f6f4d8cbb6391a721260b6ffb5 (patch)
tree3ea2ba749956270d53f4705a1358af01b3b060fe /apt-pkg/contrib/fileutl.cc
parent34b769c51ac7cf747fb9dc5b8a5697c1c292360b (diff)
parent488011fa99aee25bedb39ae2cc3115ad1ab000c0 (diff)
Merge branch 'debian/sid' of git://git.debian.org/git/apt/apt into debian/sid
Diffstat (limited to 'apt-pkg/contrib/fileutl.cc')
-rw-r--r--apt-pkg/contrib/fileutl.cc31
1 files changed, 31 insertions, 0 deletions
diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc
index f24df65fc..dca468c63 100644
--- a/apt-pkg/contrib/fileutl.cc
+++ b/apt-pkg/contrib/fileutl.cc
@@ -41,6 +41,8 @@
#include <dirent.h>
#include <signal.h>
#include <errno.h>
+#include <glob.h>
+
#include <set>
#include <algorithm>
@@ -1766,3 +1768,32 @@ bool FileFd::FileFdError(const char *Description,...) {
/*}}}*/
gzFile FileFd::gzFd() { return (gzFile) d->gz; }
+
+
+// Glob - wrapper around "glob()" /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+std::vector<std::string> Glob(std::string const &pattern, int flags)
+{
+ std::vector<std::string> result;
+ glob_t globbuf;
+ int glob_res, i;
+
+ glob_res = glob(pattern.c_str(), flags, NULL, &globbuf);
+
+ if (glob_res != 0)
+ {
+ if(glob_res != GLOB_NOMATCH) {
+ _error->Errno("glob", "Problem with glob");
+ return result;
+ }
+ }
+
+ // append results
+ for(i=0;i<globbuf.gl_pathc;i++)
+ result.push_back(string(globbuf.gl_pathv[i]));
+
+ globfree(&globbuf);
+ return result;
+}
+ /*}}}*/