main.cpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. 
  2. // A file finding application showing how to use the filesystem wrapper in the file API using C++ 2014.
  3. // If you can use only the essential headers, compilation will be faster and work even if parts of the library can't be compiled.
  4. //#include "../../DFPSR/includeFramework.h"
  5. #include "../../DFPSR/includeEssentials.h"
  6. using namespace dsr;
  7. void exploreFolder(const ReadableString& folderPath, const ReadableString& indentation) {
  8. if (!file_getFolderContent(folderPath, [indentation](const ReadableString& entryPath, const ReadableString& entryName, EntryType entryType) {
  9. printText(indentation, "* Entry: ", entryName, " as ", entryType, "\n");
  10. if (entryType == EntryType::Folder) {
  11. exploreFolder(entryPath, indentation + " ");
  12. }
  13. })) {
  14. printText("Failed to explore ", folderPath, "\n");
  15. }
  16. }
  17. DSR_MAIN_CALLER(dsrMain)
  18. void dsrMain(List<String> args) {
  19. printText("Input arguments:\n");
  20. for (int a = 0; a < args.length(); a++) {
  21. printText(" args[", a, "] = ", args[a], "\n");
  22. }
  23. String absolutePath = file_getAbsolutePath(args[0]);
  24. printText("Absolute path = ", absolutePath, "\n");
  25. if (args.length() > 1) {
  26. // Explore each listed folder from input arguments.
  27. for (int a = 1; a < args.length(); a++) {
  28. printText("Exploring ", args[a], "\n");
  29. exploreFolder(args[a], U" ");
  30. }
  31. } else {
  32. // Test program on the current path when nothing was entered.
  33. String currentPath = file_getCurrentPath();
  34. printText("Exploring ", currentPath, " because no folders were given.\n");
  35. exploreFolder(currentPath, U" ");
  36. }
  37. }