主要是模仿了linux的风格,还比较好写
本来应该先画图再写,但是画图似乎比编程本身还要繁琐
于是不经意间就写完了
大概是符合要求了
//cyc #includeusing namespace std; typedef pair pii; const int maxn = 1e5+5; map usr_privilege; map usr_password; string password,username,current_location; int privilege=-2; int step_num=2; map file_location_phi; vector file_tree[maxn]; map isdir; map privilege_required; map file_contain; bool login_module() { cout<<"enter your username:"; cin>>username; if(!usr_password.count(username)) { cout<<"the user doesn't exist"< >password; if(password!=usr_password[username]) { cout<<"wrong password"< >cmd; if(cmd == "exit") { goto JUMP1; } if(cmd=="ls") { int phi_location=file_location_phi[current_location]; for(string it:file_tree[phi_location]) { cout< >to_location; if(to_location[0]!='/') { to_location=current_location+"/"+to_location; } if(!file_location_phi.count(to_location)) { cout<<"No such file or directory"< >new_filename; string abs_filename=current_location+"/"+new_filename; if(file_location_phi.count(abs_filename)){ cout<<"file already exists"< >new_pathname; string abs_pathname=current_location+"/"+new_pathname; if(file_location_phi.count(abs_pathname)){ cout<<"path already exists"< >filename; int phi_location; phi_location=file_location_phi[filename]; if(filename[0]!='/') { filename=current_location+"/"+filename; } if(!file_location_phi.count(filename)) { cout<<"No such file or directory"< >filename; int phi_location; phi_location=file_location_phi[filename]; if(filename[0]!='/') { filename=current_location+"/"+filename; } if(!file_location_phi.count(filename)) { cout<<"No such file or directory"< >overwrite; file_contain[phi_location]=overwrite; } } //only for the admin who can reset the privilege else if(cmd=="protect") { string filepath; cin>>filepath; if(filepath[0]!='/')filepath=current_location+"/"+filepath; if(!file_location_phi.count(filepath)) { cout<<"path doesn't exist"< >name>>psw>>privi; usr_privilege[name]=privi; usr_password[name]=psw; cout<



