c语言文件系统设计—计算机毕业设计内容摘要:

name),CD..)==0) strcpy(ltrim(rtrim(dirname)),)。 else printf(\nError.\39。 %s\39。 does not exist.\n,dname)。 } void CreateF() /*Create File*/ {int fpaddrno,flag=1,i。 char fname[MAXNAME],str[50],str1[50],strtext[255],a[25]。 char fmode[25]。 char *rtrim(char *str)。 /*remove the trailing blanks.*/ char *ltrim(char *str)。 /*remove the heading blanks.*/ int FindPANo()。 /*find out physical address num*/ int WriteF1()。 /*write file*/ int ExistF(char *filename)。 /*Whether FileName Exist,Existi,Not Exist0*/ int ExistD(char *dirname)。 if (strcmp(strupr(dirname),strupr(username))!=0) {printf(\nError. You must create file in your own dir.\n)。 wgetchar=1。 } else { printf(\nPlease input FileName:)。 gets(fname)。 ltrim(rtrim(fname))。 if (ExistF(fname)=0) {printf(\nError. Name \39。 %s\39。 has already existed.\n,fname)。 wgetchar=1。 } else {printf(Please input FileMode(0Read Only, 1Write Only, 2Read and Write, 3Protect):)。 gets(fmode)。 ltrim(rtrim(fmode))。 if((strcmp(fmode,0)==0)||(strcmp(fmode,1)==0)||(strcmp(fmode,2)==0)||(strcmp(fmode,3)==0)) {fpaddrno=FindPANo()。 if (fpaddrno=0) {i=ExistD(username)。 strcpy(ufd[i]ufdfile[fcount[i]].fname,fname)。 ufd[i]ufdfile[fcount[i]].fpaddr=fpaddrno。 ufd[i]ufdfile[fcount[i]].fmode=atoi(fmode)。 ifopen[i][fcount[i]].ifopen=0。 ifopen[i][fcount[i]].openmode=4。 strcpy(str,c:\\osfile\\file\\file)。 itoa(fpaddrno,str1,10)。 strcat(str,str1)。 fp_file=fopen(str,wb)。 fclose(fp_file)。 fcount[i]++。 while(flag) {printf(Input text now(Y/N):)。 gets(a)。 ltrim(rtrim(a))。 ufd[i]ufdfile[fcount[i]1].flength=0。 if(strcmp(strupr(a),Y)==0) {fp_file=fopen(str,wb+)。 ufd[i]ufdfile[fcount[i]1].flength=WriteF1()。 flag=0。 } else if(strcmp(strupr(a),N)==0){flag=0。 wgetchar=1。 } } printf(\n\39。 %s\39。 has been created successfully!\n,fname)。 } else {printf(\nFail!No Disk Space. Please format your disk.\n)。 wgetchar=1。 } } else {printf(\nError. FileMode\39。 s Range is 03\n)。 wgetchar=1。 } }} } int ExistF(char *filename) /*Whether FileName Exist,Existi,Not Exist0*/ {int i,j。 int exist=0。 int ExistD(char *dirname)。 j=ExistD(dirname)。 for(i=0。 ifcount[j]。 i++) if (strcmp(strupr(ufd[j]ufdfile[i].fname),strupr(filename))==0) {exist=1。 break。 } if (exist) return(i)。 else return(1)。 } int FindPANo() /*find out physical address num*/ {int i。 for(i=0。 iMAX。 i++) if (fpaddrno[i]==0) {fpaddrno[i]=1。 break。 } if (iMAX) return(i)。 else return(1)。 } int WriteF1() /*write file*/ {int length=0。 char c。 printf(Please input text(\39。 \39。 stands for end):\n)。 while((c=getchar())!=39。 39。 ) {fprintf(fp_file,%c,c)。 if (c!=39。 \n39。 ) length++。 } fprintf(fp_file,\n)。 fclose(fp_file)。 return(length)。 } void DeleteF() /*Delete File*/ {char fname[MAXNAME]。 char str[50],str1[50]。 int i,j,k,flag=1。 char a[25]。 /*whether delete*/ char *rtrim(char *str)。 /*remove the trailing blanks.*/ char *ltrim(char *str)。 /*remove the heading blanks.*/ int ExistF(char *filename)。 /*Whether FileName Exist,Existi,Not Exist0*/ int ExistD(char *dirname)。 if (strcmp(strupr(dirname),strupr(username))!=0) {printf(\nError. You can only delete file in your own dir.\n)。 wgetchar=1。 } else {printf(\nPlease input FileName:)。 gets(fname)。 ltrim(rtrim(fname))。 i=ExistF(fname)。 if (i=0) {k=ExistD(username)。 if(ifopen[k][i].ifopen==1) {printf(\nError. \39。 %s\39。 is in open status. Close it before delete.\n,fname)。 wgetchar=1。 } else { while(flag) {printf(\39。 %s\39。 will be deleted. Are you sure(Y/N):,fname)。 gets(a)。 ltrim(rtrim(a))。 if(strcmp(strupr(a),Y)==0) {fpaddrno[ufd[k]ufdfile[i].fpaddr]=0。 itoa(ufd[k]ufdfile[i].fpaddr,str,10)。 for(j=i。 jfcount[k]1。 j++) {strcpy(ufd[k]ufdfile[j].fname,ufd[k]ufdfile[j+1].fname)。 ufd[k]ufdfile[j].fpaddr=ufd[k]ufdfile[j+1].fpaddr。 ufd[k]ufdfile[j].flength=ufd[k]ufdfile[j+1].flength。 ufd[k]ufdfile[j].fmode=ufd[k]ufdfile[j+1].fmode。 ifopen[k][j]=ifopen[k][j+1]。 } fcount[k]。 strcpy(str1,c:\\osfile\\file\\file)。 strcat(str1,str)。 remove(str1)。 flag=0。 printf(\n\39。 %s\39。 has been deleted successfully.\n,fname)。 wgetchar=1。 } else if(strcmp(strupr(a),N)==0) {printf(\nError. \39。 %s\39。 hasn\39。 t been deleted.\n,fname)。 wgetchar=1。 flag=0。 } }}} else {printf(\nError. \39。 %s\39。 does not exist.\n,fname)。 wgetchar=1。 }} } void ModifyFM() /*Modify FileMode*/ {char fname[MAXNAME],str[50]。 int i,j,k,flag。 char fmode[25]。 /*whether delete*/ char *rtrim(char *str)。 /*remove the trailing blanks.*/ char *ltrim(char *str)。 /*remove the heading blanks.*/ void InputPW(char *password)。 /*input password,use 39。 *39。 replace*/ void SetPANo(int RorW)。 /*Set physical address num*/ int ExistF(char *filename)。 /*Whether FileName Exist,Existi,Not Exist0*/ int ExistD(char *dirname)。 if (strcmp(strupr(dirname),strupr(username))!=0) {printf(\ can only modify filemode in yourself dir.\n)。 wgetchar=1。 } else { printf(\nPlease input FileName:)。 gets(fname)。 ltrim(rtrim(fname))。 i=ExistF(fname)。 if (i=0) {k=ExistD(username)。 if(ifopen[k][i].ifopen==1) {printf(\nError.\39。 %s\39。 is in open status. Close it before modify.\n,fname)。 wgetchar=1。 } else { if(ufd[k]ufdfile[i].fmode==0) strcpy(str,read only)。 /*FileMode*/ else if(ufd[k]ufdfile[i].fmode==1) strcpy(str,write only)。 else if(ufd[k]ufdfile[i].fmode==2) strcpy(str,read and write)。 else strcpy(str,Protect)。 printf(\39。 %s\39。 filemode is %s.\n,fname,strupr(str))。 print。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。