| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
-
- // A file finding application showing how to use the filesystem wrapper in the file API using C++ 2017.
- /*
- TODO:
- * Function for getting EntryType from a path.
- * Implement file_getParent, getting the parent folder or root path, so that it's easy to iterate the other way.
- * 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.
- * Wrap file_getPermissions
- * Wrap file_moveAndRename (over std::filesystem::rename)
- * Wrap copy (over std::filesystem::copy)
- */
- #include "../../DFPSR/includeFramework.h"
- using namespace dsr;
- void exploreFolder(const ReadableString& folderPath, const ReadableString& indentation) {
- if (!file_getFolderContent(folderPath, [indentation](const ReadableString& entryPath, const ReadableString& entryName, EntryType entryType) {
- printText(indentation, "* Entry: ", entryName, " as ", entryType, "\n");
- if (entryType == EntryType::Folder) {
- exploreFolder(entryPath, indentation + " ");
- }
- })) {
- printText("Failed to explore ", folderPath, "\n");
- }
- }
- DSR_MAIN_CALLER(dsrMain)
- void dsrMain(List<String> args) {
- printText("Input arguments:\n");
- for (int a = 0; a < args.length(); a++) {
- printText(" args[", a, "] = ", args[a], "\n");
- }
- String absolutePath = file_getAbsolutePath(args[0]);
- printText("Absolute path = ", absolutePath, "\n");
- if (args.length() > 1) {
- // Explore each listed folder from input arguments.
- for (int a = 1; a < args.length(); a++) {
- printText("Exploring ", args[a], "\n");
- exploreFolder(args[a], U" ");
- }
- } else {
- // Test program on the current path when nothing was entered.
- String currentPath = file_getCurrentPath();
- printText("Exploring ", currentPath, " because no folders were given.\n");
- exploreFolder(currentPath, U" ");
- }
- }
|