#define OLC_PGE_APPLICATION #include "pixelGameEngine.h" #include "olcutils.h" using namespace olc; std::ifstream file("input"); std::map filedata; std::string pwd; std::string tempstr; class File{ public: std::map files; int size; }; int DisplayContents(File&f,std::string path,int filter,int*filtersum){ std::cout<<" Contents of "<::iterator it=f.files.begin();it!=f.files.end();it++){ int amt=DisplayContents(it->second,(path=="/")?path+it->first:path+"/"+it->first,filter,filtersum); sum+=amt; } if (sum<=filter){ *filtersum+=sum; } std::cout<<" Size of "<::iterator it=f.files.begin();it!=f.files.end();it++){ int amt=GetSmallestAboveThreshold(it->second,(path=="/")?path+it->first:path+"/"+it->first,remaining,smallest); if (amt>=remaining){ std::cout<<"Remaining: "<0){ std::string line; if (tempstr.length()!=0){ line=tempstr; tempstr=""; } else { std::getline(file,line); } //std::cout<files.find(dir)==filer->files.end()){ //Does not exist. Create. filer->files[dir]=File(); std::cout<<"Created "<files.size()<files[dir]; }else{ filer=&filer->files[dir]; } navigator=navigator.substr(navigator.find_first_of('/')+1,std::string::npos); std::cout<<" Navigator is now at "<files.find(navigator)==filer->files.end()){ //Does not exist. Create. filer->files[navigator]=File(); std::cout<<"Created "<files.size()<files[navigator]; }else{ filer=&filer->files[navigator]; } } else if (data1.length()>0&&data1!="dir"){ int size=std::atoi(line.substr(0,line.find_first_of(' ')).c_str()); std::string filename=line.substr(line.find_first_of(' ')+1,std::string::npos); File*filer=&rootFile; std::string navigator; if (pwd=="/") { navigator=pwd+filename; } else { navigator=pwd+"/"+filename; } std::cout<<" Navigator starts at "<files.find(dir)==filer->files.end()){ //Does not exist. Create. filer->files[dir]=File(); std::cout<<"Created "<files.size()<files[dir]; }else{ filer=&filer->files[dir]; } navigator=navigator.substr(navigator.find_first_of('/')+1,std::string::npos); std::cout<<" Navigator is now at "<files[navigator]=File(); std::cout<<"Created "<files.size()<files[navigator].size=size; } } std::cout<<"end ls"<