From 2f0ab58544ceffd6f556ecf4cabec07f8213a3a5 Mon Sep 17 00:00:00 2001 From: Marian Krivos Date: Tue, 7 Aug 2012 20:56:38 +0000 Subject: [PATCH] check for initialization with an empty pattern (backport from old trunk) --- Foundation/src/Glob.cpp | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/Foundation/src/Glob.cpp b/Foundation/src/Glob.cpp index ed5e553fd..1ac727435 100644 --- a/Foundation/src/Glob.cpp +++ b/Foundation/src/Glob.cpp @@ -46,11 +46,10 @@ namespace Poco { -Glob::Glob(const std::string& pattern, int options): - _pattern(pattern), - _options(options) +Glob::Glob(const std::string& pattern, int options) + : _pattern(pattern), _options(options) { - poco_assert (!_pattern.empty()); + poco_assert(!_pattern.empty()); } @@ -90,20 +89,21 @@ void Glob::glob(const Path& pathPattern, std::set& files, int optio { Path pattern(pathPattern); pattern.makeDirectory(); // to simplify pattern handling later on - Path base(pattern); - Path absBase(base); - absBase.makeAbsolute(); - // In case of UNC paths we must not pop the topmost directory - // (which must not contain wildcards), otherwise collect() will fail - // as one cannot create a DirectoryIterator with only a node name ("\\srv\"). - int minDepth = base.getNode().empty() ? 0 : 1; - while (base.depth() > minDepth && base[base.depth() - 1] != "..") - { - base.popDirectory(); - absBase.popDirectory(); + Path base(pattern); + Path absBase(base); + absBase.makeAbsolute(); + // In case of UNC paths we must not pop the topmost directory + // (which must not contain wildcards), otherwise collect() will fail + // as one cannot create a DirectoryIterator with only a node name ("\\srv\"). + int minDepth = base.getNode().empty() ? 0 : 1; + while (base.depth() > minDepth && base[base.depth() - 1] != "..") + { + base.popDirectory(); + absBase.popDirectory(); } - if (pathPattern.isDirectory()) options |= GLOB_DIRS_ONLY; - collect(pattern, absBase, base, pathPattern[base.depth()], files, options); + if (pathPattern.isDirectory()) + options |= GLOB_DIRS_ONLY; + collect(pattern, absBase, base, pathPattern[base.depth()], files, options); }