#include<iostream>
#include<vector>
#include<string.h>
#include<string>
#include<map>
#include<algorithm>
using namespace std;
struct command{
vector<string> file;//当前目录下的文件
map<string,int>
num;//对应当前子目录的编号
vector<command *> next;//指向子目录
command *pre;//指向当前目录的上一级
};
command *root;
int Judge(string k,vector<string> p){//执行查找
vector<string>::iterator it;
it=find(p.begin(),p.end(),k);
return it!=p.end();
}
int DElete(string p,string q,command *t){//执行删除和判断
vector<string>::iterator it;
int x,i;
if(q=="file"){
it=find(t->file.begin(),t->file.end(),p);
t->file.erase(it);
}
else{
x=t->num[p];
for(i=0;i<t->next.size() && x>0;i++)x--;
if(t->next[i]->dir.size() || t->next[i]->file.size())
return 0;
it=find(t->dir.begin(),t->dir.end(),p);
t->dir.erase(it);
}
return 1;
}
void make(){
root=new command();
command *h=root,*t;
int x;
while(cin>>p>>q){
if(p=="CD"){//进入一个子目录
if(q==".." || q=="\\"){
cout<<"success"<<endl;
if(q=="..")
h=t->pre;
else
h=root;
}
else if(Judge(q,t->dir)){
cout<<"success"<<endl;
x=t->num[q];
h=t;
}
else{
cout<<"no such directory"<<endl;
}
}
else if(p=="MD"){//创建一个子目录
t=h;
if(q==".." || Judge(q,t->dir)){
cout<<"directory already exist"<<endl;
}
else{
t->dir.push_back(q);
t->num[q]=t->next.size();
command *newafile=new command();
t->next.push_back(newafile);
t=newafile;
t->pre=h;
}
}
else if(p=="RD"){//删除一个子目录
t=h;
if(Judge(q,t->dir)){
if(DElete(q,"dir",t)){
cout<<"success"<<endl;
}
else
cout<<"can not delete the directory"<<endl;
}
else{
cout<<"can not delete the directory"<<endl;
}
}
else if(p=="CREATE"){//创建一个文件
t=h;
if(Judge(q,t->file)){
}
else
{
t->file.push_back(q);
cout<<"success"<<endl;
}
}
else if(p=="DELETE"){//删除一个文件
t=h;
if(Judge(q,t->file)){
DElete(q,"file",t);
cout<<"success"<<endl;
}
else
}
}
}
int main(){
return 0;
}