Moved keywords from local variables to keywords map.
This commit is contained in:
1 parent
907f449ecc
commit
9622b5cf8c
23 files changed
+221
-220
No files matched your search
+14
-14
@@ -9,44 +9,44 @@
|
||||
namespace jet {
|
||||
|
||||
__whiledir::__whiledir(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local) : Tag(in, parentOut, global, parent, this) {
|
||||
if(!variableDefined("path"))
|
||||
if(!keywordDefined("path"))
|
||||
throw coreutils::Exception("whiledir tag must specify a path.");
|
||||
resolveKeyword("path");
|
||||
resolveKeyword("sort");
|
||||
if(variableDefined("sort") && (variables["sort"] == "true")) {
|
||||
if(keywordDefined("sort") && (keywords["sort"] == "true")) {
|
||||
std::vector<std::filesystem::directory_entry> entries;
|
||||
for(auto const &entry : std::filesystem::directory_iterator(variables["path"].str()))
|
||||
entries.push_back(entry);
|
||||
std::sort(entries.begin(), entries.end(), [](const auto &a, const auto &b) { return a.path() < b.path(); });
|
||||
for(const auto &entry : entries) {
|
||||
if(variableDefined("fullpath")) {
|
||||
if(keywordDefined("fullpath")) {
|
||||
resolveKeyword("fullpath");
|
||||
global.variables[variables["fullpath"]] = entry.path();
|
||||
global.variables[keywords["fullpath"]] = entry.path();
|
||||
}
|
||||
if(variableDefined("filename")) {
|
||||
if(keywordDefined("filename")) {
|
||||
resolveKeyword("filename");
|
||||
global.variables[variables["filename"]] = entry.path().filename();
|
||||
global.variables[keywords["filename"]] = entry.path().filename();
|
||||
}
|
||||
if(variableDefined("filenamenoextension")) {
|
||||
if(keywordDefined("filenamenoextension")) {
|
||||
resolveKeyword("filenamenoextension");
|
||||
global.variables[variables["filenamenoextension"]] = entry.path().stem();
|
||||
global.variables[keywords["filenamenoextension"]] = entry.path().stem();
|
||||
}
|
||||
processContainer(container);
|
||||
container.reset();
|
||||
}
|
||||
} else {
|
||||
for(auto const &entry : std::filesystem::directory_iterator(variables["path"].str())) {
|
||||
if(variableDefined("fullpath")) {
|
||||
if(keywordDefined("fullpath")) {
|
||||
resolveKeyword("fullpath");
|
||||
global.variables[variables["fullpath"]] = entry.path();
|
||||
global.variables[keywords["fullpath"]] = entry.path();
|
||||
}
|
||||
if(variableDefined("filename")) {
|
||||
if(keywordDefined("filename")) {
|
||||
resolveKeyword("filename");
|
||||
global.variables[variables["filename"]] = entry.path().filename();
|
||||
global.variables[keywords["filename"]] = entry.path().filename();
|
||||
}
|
||||
if(variableDefined("filenamenoextension")) {
|
||||
if(keywordDefined("filenamenoextension")) {
|
||||
resolveKeyword("filenamenoextension");
|
||||
global.variables[variables["filenamenoextension"]] = entry.path().stem();
|
||||
global.variables[keywords["filenamenoextension"]] = entry.path().stem();
|
||||
}
|
||||
processContainer(container);
|
||||
container.reset();
|
||||
|
||||
Reference in new issue
Block a user