12345678910111213141516171819202122232425262728293031323334 |
- #include "JsonUtils.h"
- #include <Datei.h>
- void loadAllJsonsFromDirectory(Framework::Text path,
- std::function<void(Framework::JSON::JSONValue* zValue, Framework::Text path)> action)
- {
- if (path.hatAt(path.getLength() - 1, "/")
- || path.hatAt(path.getLength() - 1, "\\"))
- {
- path.remove(path.getLength() - 1, path.getLength());
- }
- Framework::Datei dir(path);
- if (dir.istOrdner())
- {
- Framework::RCArray<Framework::Text> *list = dir.getDateiListe();
- for (Framework::Text* name : *list)
- {
- Framework::Text nextPath = path + "/" + *name;
- loadAllJsonsFromDirectory(nextPath, action);
- }
- list->release();
- }
- else if (path.hatAt(path.getLength() - 5, ".json") && dir.existiert())
- {
- Framework::JSON::JSONValue* value
- = Framework::JSON::loadJSONFromFile(path);
- if (value)
- {
- action(value, path);
- value->release();
- }
- }
- }
|