aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/regex/glob/glob_iterator.h
diff options
context:
space:
mode:
authorvvvv <vvvv@ydb.tech>2023-07-31 18:21:04 +0300
committervvvv <vvvv@ydb.tech>2023-07-31 18:21:04 +0300
commitdec41c40e51aa407edef81a3c566a5a15780fc49 (patch)
tree4f197b596b32f35eca368121f0dff913419da9af /library/cpp/regex/glob/glob_iterator.h
parent3ca8b54c96e09eb2b65be7f09675623438d559c7 (diff)
downloadydb-dec41c40e51aa407edef81a3c566a5a15780fc49.tar.gz
YQL-16239 Move purecalc to public
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;
+};