个人收集整理 仅供参考学习
int WriteF1(); /*write file*/
int ExistF(char *filename); /*Whether FileName Exist,Exist-i,Not Exist-0*/mLPVzx7ZNw int ExistD(char *dirname);
if (strcmp(strupr(dirname),strupr(username))!=0)
{printf(\);wgetchar=1;}AHP35hB02d else {
printf(\); gets(fname);
ltrim(rtrim(fname)); if (ExistF(fname)>=0)
{printf(\,fname);NDOcB141gT wgetchar=1; } else
{printf(\3-Protect):\);1zOk7Ly2vA gets(fmode); ltrim(rtrim(fmode));
if((strcmp(fmode,\)==0)||(strcmp(fmode,\)==0)||(strcmp(fmode,\)==0)||(strcmp(fmode,\)==0))fuNsDv23Kh {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,\); itoa(fpaddrno,str1,10); strcat(str,str1); fp_file=fopen(str,\); fclose(fp_file); fcount[i]++; while(flag) {printf(\); gets(a); ltrim(rtrim(a)); ufd[i]->ufdfile[fcount[i]-1].flength=0; if(strcmp(strupr(a),\)==0) {fp_file=fopen(str,\); ufd[i]->ufdfile[fcount[i]-1].flength=WriteF1(); flag=0;
13 / 20
个人收集整理 仅供参考学习
}
elseif(strcmp(strupr(a),\)==0){flag=0;wgetchar=1;}tqMB9ew4YX } printf(\,fname);HmMJFY05dE } else {printf(\);wgetchar=1;}ViLRaIt6sk }
else {printf(\);wgetchar=1;}9eK0GsX7H1 }} }
int ExistF(char *filename) /*Whether FileName Exist,Exist-i,Not Exist-0*/naK8ccr8VI {int i,j; int exist=0;
int ExistD(char *dirname); j=ExistD(dirname); for(i=0;i if (strcmp(strupr(ufd[j]->ufdfile[i].fname),strupr(filename))==0)B6JgIVV9ao {exist=1; break; } if (exist) return(i); elsereturn(-1); } int FindPANo() /*find out physical address num*/ {int i; for(i=0;i if (fpaddrno[i]==0) {fpaddrno[i]=1;break;} if (i int WriteF1() /*write file*/ {int length=0; char c; printf(\);P2IpeFpap5 while((c=getchar())!='#') {fprintf(fp_file,\,c); if (c!='\\n') length++; } fprintf(fp_file,\); fclose(fp_file); 14 / 20 个人收集整理 仅供参考学习 return(length); } void DeleteF() /*Delete File*/ { printf(\请同学们自己完成\\n\); } 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.*/3YIxKpScDM char *ltrim(char *str); /*remove the heading blanks.*/gUHFg9mdSs void InputPW(char *password); /*input password,use '*' replace*/uQHOMTQe79 void SetPANo(int RorW); /*Set physical address num*/IMGWiDkflP int ExistF(char *filename); /*Whether FileName Exist,Exist-i,Not Exist-0*/WHF4OmOgAw int ExistD(char *dirname); if (strcmp(strupr(dirname),strupr(username))!=0) {printf(\filemode in yourself dir.\\n\);wgetchar=1;}aDFdk6hhPd else { printf(\); gets(fname); ltrim(rtrim(fname)); i=ExistF(fname); if (i>=0) {k=ExistD(username); if(ifopen[k][i].ifopen==1) {printf(\modify.\\n\,fname);wgetchar=1;}ozElQQLi4T else { if(ufd[k]->ufdfile[i].fmode==0) strcpy(str,\); /*FileMode*/CvDtmAfjiA elseif(ufd[k]->ufdfile[i].fmode==1) strcpy(str,\);QrDCRkJkxh elseif(ufd[k]->ufdfile[i].fmode==2) strcpy(str,\);4nCKn3dlMX else strcpy(str,\); printf(\,fname,strupr(str));ijCSTNGm0E printf(\);vfB1pxanfk gets(fmode); ltrim(rtrim(fmode)); if(strcmp(fmode,\)==0) {ufd[k]->ufdfile[i].fmode=0; 15 / 20 个人收集整理 仅供参考学习 printf(\successfully.\\n\,fname);JbA9VhEou1 wgetchar=1; } elseif(strcmp(fmode,\)==0) {ufd[k]->ufdfile[i].fmode=1; printf(\successfully.\\n\,fname);X7Ahr18pJI wgetchar=1; } elseif(strcmp(fmode,\)==0) {ufd[k]->ufdfile[i].fmode=2; printf(\successfully.\\n\,fname);b3zqXLCqXo wgetchar=1; } elseif(strcmp(fmode,\)==0) {ufd[k]->ufdfile[i].fmode=3; printf(\,fname);pZyytu5rc5 wgetchar=1; } else {printf(\,fname);wgetchar=1;}DVyGZezsrM } } else {printf(\,fname);wgetchar=1;}}RQxPvY3tFs } void OpenF() /*Open File*/ { printf(\请同学们自己完成\\n\); } void CloseF() /*Close File*/ { printf(\请同学们自己完成\\n\); } void ReadF() /*Read File*/ {int i,k,n=0; char fname[MAXNAME]; char str[255],str1[255],c; char *rtrim(char *str); /*remove the trailing blanks.*/5MxX1IxuU9 16 / 20