#include using namespace std; struct File; class Directory{ public: Directory* parent; string name; vector subdirectories; vector files; long container_size; Directory (Directory* parent, string name) : parent(parent), name(name){ subdirectories.clear(); files.clear(); container_size = 0; } }; struct File{ string name; long size; Directory* parent; }; using ChangeDirectory = string; using List = vector; using Command = variant; int main(){ ifstream input_file("test.txt"); string line; vector commands; List current_list; bool reading_list = false; // Parsing the input so it is nicer to handle later on while(getline(input_file, line)){ if(line[0] == '$'){ if(reading_list){ commands.push_back(current_list); current_list.clear(); reading_list = false; } stringstream ss(line); string _, comm; ss >> _ >> comm; if(comm == "cd"){ ChangeDirectory dir; ss >> dir; commands.push_back(dir); } else{ reading_list = true; } } else{ current_list.push_back(line); } } if(reading_list){ commands.push_back(current_list); reading_list = false; } // Setting up initial, empty directory Directory // Mapping out the file directory from all the commands for(auto c : commands){ if(c.index() == 0){ } else{ } } // Printing parsed commands // for(auto c : commands){ // if(c.index() == 0){ // cout << "$ cd " << get<0>(c) << '\n'; // } else{ // cout << "$ ls\n"; // for(auto s : get<1>(c)){ // cout << s << '\n'; // } // } // } return 0; }