File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change 17
17
#include < stdlib.h>
18
18
#include < stddef.h>
19
19
#include < string.h>
20
+ #ifdef __OpenBSD__
21
+ #include < glob.h>
22
+ #else
20
23
#include < wordexp.h>
24
+ #endif
21
25
#include < stdint.h>
22
26
#include < inttypes.h>
23
27
Original file line number Diff line number Diff line change 17
17
#include < stdlib.h>
18
18
#include < stddef.h>
19
19
#include < string.h>
20
+ #ifdef __OpenBSD__
21
+ #include < glob.h>
22
+ #else
20
23
#include < wordexp.h>
24
+ #endif
21
25
#include < stdint.h>
22
26
#include < inttypes.h>
23
27
@@ -119,10 +123,17 @@ std::string get_path(const std::string& file) {
119
123
std::list<std::string> expandEnv (const std::string& var, int flags) {
120
124
std::list<std::string> vars;
121
125
126
+ #ifdef __OpenBSD__
127
+ glob_t p;
128
+ if (glob (var.c_str (), flags, NULL , &p) == false ) {
129
+ if (p.gl_pathc ) {
130
+ for (char ** exp = p.gl_pathv ; *exp; ++exp) {
131
+ #else
122
132
wordexp_t p;
123
133
if (wordexp (var.c_str (), &p, flags) == false ) {
124
134
if (p.we_wordc ) {
125
135
for (char ** exp = p.we_wordv ; *exp; ++exp) {
136
+ #endif
126
137
std::ifstream *iss = new std::ifstream (exp[0 ], std::ios::in);
127
138
if (iss->is_open ()) {
128
139
iss->close ();
@@ -131,12 +142,15 @@ std::list<std::string> expandEnv(const std::string& var, int flags) {
131
142
delete iss;
132
143
}
133
144
}
145
+ #ifdef __OpenBSD__
146
+ globfree (&p);
147
+ #else
134
148
wordfree (&p);
149
+ #endif
135
150
}
136
151
return vars;
137
152
}
138
153
139
-
140
154
bool createDir (std::string dir, int mode, std::string *error) {
141
155
int ret = mkdir (dir.data (), mode);
142
156
if (ret != 0 && errno != EEXIST) {
You can’t perform that action at this time.
0 commit comments