From 488011fa99aee25bedb39ae2cc3115ad1ab000c0 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 17 Oct 2012 10:27:50 +0200 Subject: * lp:~mvo/apt/add-glob-function: - add Glob() to fileutl.{cc,h} Conflicts: apt-pkg/contrib/fileutl.h debian/changelog --- apt-pkg/contrib/fileutl.cc | 31 +++++++++++++++++++++++++++++++ apt-pkg/contrib/fileutl.h | 3 +++ 2 files changed, 34 insertions(+) (limited to 'apt-pkg') 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 #include #include +#include + #include #include @@ -1766,3 +1768,32 @@ bool FileFd::FileFdError(const char *Description,...) { /*}}}*/ gzFile FileFd::gzFd() { return (gzFile) d->gz; } + + +// Glob - wrapper around "glob()" /*{{{*/ +// --------------------------------------------------------------------- +/* */ +std::vector Glob(std::string const &pattern, int flags) +{ + std::vector 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 Glob(std::string const &pattern, int flags=0); + #endif -- cgit v1.2.3