Making progress on tools still
This commit is contained in:
@ -0,0 +1,59 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "GeneratedLanguages.hpp"
|
||||
|
||||
using namespace Dawn;
|
||||
|
||||
std::vector<std::string> GeneratedLanguages::getRequiredFlags() {
|
||||
return std::vector<std::string>{ "input", "output" };
|
||||
}
|
||||
|
||||
int32_t GeneratedLanguages::start() {
|
||||
// Generate list of languages
|
||||
std::string inNormal = File::normalizeSlashes(flags["input"]);
|
||||
std::string error;
|
||||
std::vector<std::string> files;
|
||||
int32_t ret = this->scanDir(inNormal, &error, &files);
|
||||
if(ret != 0) {
|
||||
std::cout << error << std::endl;
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Now process each language file
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t GeneratedLanguages::scanDir(
|
||||
std::string dir,
|
||||
std::string *error,
|
||||
std::vector<std::string> *files
|
||||
) {
|
||||
DIR* handle = opendir(dir.c_str());
|
||||
if(ENOENT == errno || !handle) {
|
||||
*error = "Input directory \"" + dir + "\" does not exist";
|
||||
return 1;
|
||||
}
|
||||
|
||||
struct dirent *entry;
|
||||
while((entry=readdir(handle))) {
|
||||
std::string name(entry->d_name);
|
||||
if(name.size() == 0 || name[0] == '.') continue;
|
||||
auto path = dir + FILE_PATH_SEP + entry->d_name;
|
||||
if(entry->d_type == DT_DIR) {
|
||||
auto ret = this->scanDir(dir, error, files);
|
||||
if(ret != 0) return ret;
|
||||
} else if(entry->d_type == DT_REG) {
|
||||
files->push_back(path);
|
||||
}
|
||||
}
|
||||
|
||||
closedir(handle);
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user