diff options
author | vvvv <vvvv@ydb.tech> | 2023-07-31 18:21:04 +0300 |
---|---|---|
committer | vvvv <vvvv@ydb.tech> | 2023-07-31 18:21:04 +0300 |
commit | dec41c40e51aa407edef81a3c566a5a15780fc49 (patch) | |
tree | 4f197b596b32f35eca368121f0dff913419da9af /library/cpp/regex/glob/glob_iterator.h | |
parent | 3ca8b54c96e09eb2b65be7f09675623438d559c7 (diff) | |
download | ydb-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.h | 36 |
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; +}; |