logo资料库

文件系统源码--操作系统课程设计.doc

第1页 / 共16页
第2页 / 共16页
第3页 / 共16页
第4页 / 共16页
第5页 / 共16页
第6页 / 共16页
第7页 / 共16页
第8页 / 共16页
资料共16页,剩余部分请下载后查看
#include #include #include #include #include #include #include using namespace std; #define maxusernum 100; #define maxdirnum 100; #define maxfilenum 100; struct file { char filename[10]; file *fnext; int length; char content[100]; }; struct dir { char dirname[10]; dir *fc; dir *rb; file *dnext; }; int adddir(char dirname[],char name[]); void deletedir(char dirname[],char name[]); void show(dir *p,char dirname[]); int find(dir *p,char name[]); void renamedir(char dirname[],char newname[],char name[]); void showdir(char dirname[]); void addfile(char filename[],char dirname[],int length); void deletefile(char filename[],char dirname[]); void renamefile(char filename[],char newname[],char dirname[]); void write(char filename[],char dirname[]); void showfile(char filename[],char dirname[]); void copyfile(char filename[],char desdirname[],char name[]); void copydir(char dirname[],char desdirname[],char renamedir[]); void exitdir(); dir *root=NULL;
dir *current=NULL; void main() { while(1) { cout<<"*************************************************"<"; char xx[10]; cin>>xx; if(!strcmp(xx,"1")) { char a[20],b[10],c[10]; char x[20]; char t[20]; cout<<"Please input according to the rules>"; cin>>x>>b; if(strcmp(x,"adddir")) { cout<<"Input the wrong word!..."<"; cin>>t; adddir(b,t);
cout<<"Add completely!..."<"; cin>>x>>b; if(strcmp("deletedir",x)) { cout<<"Input the wrong number!"<fc==NULL){deletedir(b,"0");continue;} else { cout<<"Please input its dir>"; cin>>t; deletedir(b,t);continue; } } } if(!strcmp(xx,"3")) { char a[20],b[10],c[10]; char x[20]; char t[20]; cout<<"Please input according to the rules>"; cin>>x>>b>>c; if(strcmp("renamedir",x)) { cout<<"Input the wrong number!"<fc==NULL){renamedir(b,c,"0");continue;} else {
cout<<"Please input its dir>"; cin>>t; renamedir(b,c,t); cout<<"rename compeletely!..."<"; cin>>x>>b; if(strcmp("showdir",x)) { cout<<"Input the wrong number!"<"; cin>>x>>b; if(strcmp("addfile",x)) {cout<<"Input the wrong number!"<"; cin>>a; cout<<"please input its length>"; cin>>length; addfile(b,a,length);continue; } } if(!strcmp(xx,"6")) {
char a[20],b[20]; char x[20]; cout<<"Please input according to the rules>"; cin>>x>>b; if(strcmp("deletefile",x)) {cout<<"Input the wrong word!"<"; cin>>a; deletefile(b,a);continue; } } if(!strcmp(xx,"7")) { char a[20],b[20],c[20]; char x[20]; cout<<"Please input according to the rules>"; cin>>x>>a>>b; if(strcmp("renamefile",x)) {cout<<"Input the wrong word!"<"; cin>>c; renamefile(a,b,c);continue; } } if(!strcmp(xx,"8")) { char a[20],b[20],c[20]; char x[20]; cout<<"Please input according to the rules>"; cin>>x>>a; if(strcmp("write",x)) {cout<<"Input the wrong word!"<"; cin>>b; write(a,b);continue; }
} if(!strcmp(xx,"9")) { char a[20],b[20]; char x[20]; cout<<"Please input according to the rules>"; cin>>x>>a; if(strcmp("showfile",x)) {cout<<"Input the wrong word!"<"; cin>>b; showfile(a,b);continue; } } if(!strcmp(xx,"10")) { char a[20],b[20],c[20]; char x[20]; cout<<"Please input according to the rules>"; cin>>x>>a>>b; if(strcmp("copyfile",x)) {cout<<"Input the wrong word!"<"; cin>>c; copyfile(a,b,c);continue; } } if(!strcmp(xx,"11")) { char a[20],b[20],c[20]; char x[20]; cout<<"Please input according to the rules>"; cin>>x>>a>>b; if(strcmp("copydir",x)) {cout<<"Input the wrong word!"<"; cin>>c; copydir(a,b,c);continue;
} } if(!strcmp(xx,"12")) { exitdir(); } if(!strcmp(xx,"help")) { system("cls"); cout<<"*********************************************************"<
if(!strcmp(xx,"renamefile?")){system("cls"); cout<<"重命名文件"<dirname,dirname); p->fc=NULL; p->rb=NULL; p->dnext=NULL; if(root==NULL) { root=current=p; return 1; } find(root,name); if(current->fc==NULL)current->fc=p; else { dir *q=current->fc; while(q->rb!=NULL) {q=q->rb;} q->rb=p; } return 1; }
分享到:
收藏