main.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. 
  2. // A file finding application showing how to use the filesystem wrapper in the file API using C++ 2017.
  3. /*
  4. TODO:
  5. * Function for getting EntryType from a path.
  6. * Implement file_getParent, getting the parent folder or root path, so that it's easy to iterate the other way.
  7. * Something for listing root paths, so that systems with more than one system root can have a listbox with drives to select in file explorers.
  8. * Wrap file_getPermissions
  9. * Wrap file_moveAndRename (over std::filesystem::rename)
  10. * Wrap copy (over std::filesystem::copy)
  11. */
  12. #include "../../DFPSR/includeFramework.h"
  13. using namespace dsr;
  14. void exploreFolder(const ReadableString& folderPath, const ReadableString& indentation) {
  15. /*file_getFolderContent(folderPath, [indentation](ReadableString entryPath, EntryType entryType) {
  16. ReadableString shortName = file_getPathlessName(entryPath);
  17. if (entryType == EntryType::Folder) {
  18. printText(indentation, " Folder(", shortName, ")\n");
  19. exploreFolder(entryPath, indentation + " ");
  20. } else if (entryType == EntryType::File) {
  21. printText(indentation, " File(", shortName, ") of ", file_getSize(entryPath), " bytes\n");
  22. }
  23. });*/
  24. }
  25. DSR_MAIN_CALLER(dsrMain)
  26. int dsrMain(List<String> args) {
  27. printText("Input arguments:\n");
  28. for (int a = 0; a < args.length(); a++) {
  29. printText(" args[", a, "] = ", args[a], "\n");
  30. }
  31. /*
  32. String absolutePath = file_getCanonicalPath(args[0]);
  33. printText("Absolute path = ", absolutePath, "\n");
  34. if (args.length() > 1) {
  35. // Explore each listed folder from input arguments.
  36. for (int a = 1; a < args.length(); a++) {
  37. printText("Exploring ", args[a], "\n");
  38. exploreFolder(args[a], U"");
  39. }
  40. } else {
  41. // Test program on the current path when nothing was entered.
  42. String currentPath = file_getCurrentPath();
  43. printText("Exploring ", currentPath, " because no folders were given.\n");
  44. exploreFolder(currentPath, U"");
  45. }
  46. */
  47. // When the DSR_MAIN_CALLER wrapper is used over the real main function, returning zero is no longer implicit.
  48. return 0;
  49. }