3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-06-06 06:03:23 +00:00

Added glob support to all front-ends

This commit is contained in:
Clifford Wolf 2016-08-22 15:05:57 +02:00
parent 450f6f59b4
commit f8a77abfac
3 changed files with 38 additions and 4 deletions

View file

@ -37,11 +37,13 @@
# include <unistd.h>
# include <dirent.h>
# include <sys/stat.h>
# include <glob.h>
#else
# include <unistd.h>
# include <dirent.h>
# include <sys/types.h>
# include <sys/stat.h>
# include <glob.h>
#endif
#include <limits.h>
@ -547,6 +549,29 @@ const char *create_prompt(RTLIL::Design *design, int recursion_counter)
return buffer;
}
std::vector<std::string> glob_filename(const std::string &filename_pattern)
{
std::vector<std::string> results;
#ifdef _WIN32
results.push_back(filename_pattern);
#else
glob_t globbuf;
int err = glob(filename_pattern.c_str(), 0, NULL, &globbuf);
if(err == 0) {
for (size_t i = 0; i < globbuf.gl_pathc; i++)
results.push_back(globbuf.gl_pathv[i]);
globfree(&globbuf);
} else {
results.push_back(filename_pattern);
}
#endif
return results;
}
void rewrite_filename(std::string &filename)
{
if (filename.substr(0, 1) == "\"" && filename.substr(GetSize(filename)-1) == "\"")