| | |
| | | std::string userDataPath = "/user_data"; |
| | | std::string userCloudPath = "/user_cloud"; |
| | | |
| | | void list_folder(const std::string& folder) |
| | | void list_subfolder(const std::string& folder, const std::string& short_folder, const std::string& prefix = "") |
| | | { |
| | | std::cout << "Listing files in " << folder << "\n"; |
| | | std::cout << prefix << short_folder << "/\n"; |
| | | |
| | | DIR *d = opendir(folder.c_str()); |
| | | if (d) |
| | |
| | | while((entry = readdir(d))) |
| | | { |
| | | if (entry->d_name[0] == '.') continue; |
| | | std::cout << entry->d_name << "\n"; |
| | | if ((entry->d_type & DT_DIR)>0) { |
| | | list_subfolder(folder + '/' + entry->d_name, entry->d_name, prefix + " "); |
| | | } else { |
| | | std::cout << prefix << " " << entry->d_name << "\n"; |
| | | } |
| | | } |
| | | closedir(d); |
| | | } |
| | | } |
| | | |
| | | void list_folder(const std::string& folder) |
| | | { |
| | | std::cout << "Listing files\n"; |
| | | list_subfolder(folder, folder); |
| | | } |
| | | |
| | | void test_list_files() |
| | | { |
| | | list_folder(userDataPath); |