2018-09-11 16:45:17 -04:00
|
|
|
/*
|
|
|
|
Copyright (c) 2018, Antonio SJ Musumeci <trapexit@spawn.link>
|
|
|
|
|
|
|
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
purpose with or without fee is hereby granted, provided that the above
|
|
|
|
copyright notice and this permission notice appear in all copies.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <glob.h>
|
|
|
|
|
2020-12-19 15:06:08 -05:00
|
|
|
#include <cstdint>
|
2018-09-11 16:45:17 -04:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
using std::string;
|
|
|
|
using std::vector;
|
|
|
|
|
2020-12-19 15:06:08 -05:00
|
|
|
|
2018-09-11 16:45:17 -04:00
|
|
|
namespace fs
|
|
|
|
{
|
|
|
|
void
|
2018-10-20 23:40:02 -04:00
|
|
|
glob(const string &pattern_,
|
2020-08-16 18:22:25 -04:00
|
|
|
vector<string> *strs_)
|
2018-09-11 16:45:17 -04:00
|
|
|
{
|
|
|
|
int flags;
|
|
|
|
glob_t gbuf = {0};
|
|
|
|
|
|
|
|
flags = GLOB_NOCHECK;
|
2018-10-20 23:40:02 -04:00
|
|
|
::glob(pattern_.c_str(),flags,NULL,&gbuf);
|
2018-09-11 16:45:17 -04:00
|
|
|
|
2018-10-20 23:40:02 -04:00
|
|
|
for(size_t i = 0; i < gbuf.gl_pathc; i++)
|
2020-08-16 18:22:25 -04:00
|
|
|
strs_->push_back(gbuf.gl_pathv[i]);
|
2018-09-11 16:45:17 -04:00
|
|
|
|
|
|
|
::globfree(&gbuf);
|
|
|
|
}
|
|
|
|
}
|