OpenVPN 3 Core Library
Loading...
Searching...
No Matches
glob.hpp
Go to the documentation of this file.
1// OpenVPN -- An application to securely tunnel IP networks
2// over a single port, with support for SSL/TLS-based
3// session authentication and key exchange,
4// packet encryption, packet authentication, and
5// packet compression.
6//
7// Copyright (C) 2012- OpenVPN Inc.
8//
9// SPDX-License-Identifier: MPL-2.0 OR AGPL-3.0-only WITH openvpn3-openssl-exception
10//
11
12#ifndef OPENVPN_COMMON_GLOB_H
13#define OPENVPN_COMMON_GLOB_H
14
15#include <glob.h>
16
17#include <cstring>
18#include <string>
19
20namespace openvpn {
21class Glob
22{
23 public:
24 Glob(const std::string &pattern, const int flags)
25 {
26 reset();
27 status_ = ::glob(pattern.c_str(), flags, nullptr, &glob_);
28 }
29
30 int status() const
31 {
32 return status_;
33 }
34
35 size_t size() const
36 {
37 return glob_.gl_pathc;
38 }
39
40 const char *operator[](const size_t i) const
41 {
42 return glob_.gl_pathv[i];
43 }
44
46 {
47 ::globfree(&glob_);
48 }
49
50 private:
51 void reset()
52 {
53 std::memset(&glob_, 0, sizeof(glob_));
54 status_ = 0;
55 }
56
57 Glob(const Glob &) = delete;
58 Glob &operator=(const Glob &) = delete;
59
60 ::glob_t glob_;
62};
63} // namespace openvpn
64
65#endif
int status() const
Definition glob.hpp:30
const char * operator[](const size_t i) const
Definition glob.hpp:40
Glob & operator=(const Glob &)=delete
void reset()
Definition glob.hpp:51
::glob_t glob_
Definition glob.hpp:60
size_t size() const
Definition glob.hpp:35
Glob(const std::string &pattern, const int flags)
Definition glob.hpp:24
int status_
Definition glob.hpp:61
Glob(const Glob &)=delete
reroute_gw flags