aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/regex/glob/glob_iterator.h
diff options
context:
space:
mode:
authorqrort <qrort@yandex-team.com>2022-11-30 23:47:12 +0300
committerqrort <qrort@yandex-team.com>2022-11-30 23:47:12 +0300
commit22f8ae0e3f5d68b92aecccdf96c1d841a0334311 (patch)
treebffa27765faf54126ad44bcafa89fadecb7a73d7 /library/cpp/regex/glob/glob_iterator.h
parent332b99e2173f0425444abb759eebcb2fafaa9209 (diff)
downloadydb-22f8ae0e3f5d68b92aecccdf96c1d841a0334311.tar.gz
validate canons without yatest_common
Diffstat (limited to 'library/cpp/regex/glob/glob_iterator.h')
-rw-r--r--library/cpp/regex/glob/glob_iterator.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/library/cpp/regex/glob/glob_iterator.h b/library/cpp/regex/glob/glob_iterator.h
new file mode 100644
index 0000000000..e25481e594
--- /dev/null
+++ b/library/cpp/regex/glob/glob_iterator.h
@@ -0,0 +1,36 @@
+#pragma once
+
+#include "glob_compat.h"
+
+#include <util/generic/noncopyable.h>
+#include <util/generic/string.h>
+#include <util/generic/yexception.h>
+
+class TGlobPaths : TNonCopyable {
+public:
+ TGlobPaths(const char* pattern) {
+ Impl.gl_pathc = 0;
+ int result = glob(pattern, 0, nullptr, &Impl);
+ Y_ENSURE(result == 0 || result == GLOB_NOMATCH, "glob failed");
+ }
+
+ TGlobPaths(const TString& pattern)
+ : TGlobPaths(pattern.data())
+ {
+ }
+
+ ~TGlobPaths() {
+ globfree(&Impl);
+ }
+
+ const char** begin() {
+ return const_cast<const char**>(Impl.gl_pathv);
+ }
+
+ const char** end() {
+ return const_cast<const char**>(Impl.gl_pathv + Impl.gl_pathc);
+ }
+
+private:
+ glob_t Impl;
+};