29 void scanDir(
const string& folder, vector<string>& totalFiles) {
32 virtual ~ListFilter() {}
34 bool accept(
const string& pathName,
const string& fileName)
override {
35 if (fileName ==
".")
return false;
36 if (fileName ==
"..")
return false;
37 if (FileSystem::getInstance()->isPath(pathName +
"/" + fileName) ==
true)
return true;
38 if (fileName ==
"LICENSE")
return true;
43 ListFilter listFilter;
46 FileSystem::getInstance()->list(folder, files, &listFilter);
48 for (
const auto& fileName: files) {
49 if (fileName ==
"LICENSE") {
50 totalFiles.push_back(folder +
"/" + fileName);
52 scanDir(folder +
"/" + fileName, totalFiles);
57 void processFile(
const string& indent,
const string& fileName) {
58 auto _fileName = StringTools::startsWith(fileName,
"./") ==
true?StringTools::substring(fileName, 2, fileName.size()):fileName;
60 FileSystem::getInstance()->getContentAsStringArray(
".", fileName, lines);
61 Console::println(indent + _fileName);
62 Console::print(indent);
63 for (
auto i = 0; i < _fileName.size() + 2; i++) Console::print(
"-");
66 for (
const auto& line: lines) {
67 if (StringTools::trim(line).size() == 0) {
70 Console::println(indent +
"\t" + line);
77 int main(
int argc,
char** argv)
79 Console::println(
string(
"generatelicenses ") + Version::getVersion());
80 Console::println(Version::getCopyright());
83 auto pathToHeaders =
".";
84 auto indent = argc > 1?string(argv[1]):string();
86 if (argc > 2 || (argc == 2 && indent.empty() ==
false && indent !=
"--indent")) {
87 Console::println(
"Usage: generatelicenses [--indent]");
91 if (indent ==
"--indent") indent =
"\t";
93 Console::println(
"Scanning files");
97 Console::println(
"Processing files");
98 Console::println(
"------------------");
100 for (
const auto& fileName: files) {
101 if (fileName ==
"./LICENSE")
continue;
106 Application::exit(Application::EXITCODE_SUCCESS);
Application base class, please make sure to allocate application on heap to have correct application ...
File system singleton class.
int main(int argc, char **argv)
void scanDir(const string &folder, vector< string > &totalFiles)
void processFile(const string &indent, const string &fileName)
std::exception Exception
Exception base class.
File system file name filter interface.
virtual bool accept(const string &path, const string &file)=0
Accept a file.