当前位置:首页 > os实验指导书
{char dname[MAXNAME];
char *rtrim(char *str); /*remove the trailing blanks.*/ char *ltrim(char *str); /*remove the heading blanks.*/
int ExistD(char *filename); /*Whether FileName Exist,Exist-i,Not Exist-0*/ printf(\ gets(dname);
ltrim(rtrim(dname));
if (ExistD(dname)>=0) strcpy(dirname,strupr(dname));
else if(strcmp(strupr(dname),\ else printf(\}
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,Exist-i,Not Exist-0*/ int ExistD(char *dirname);
if (strcmp(strupr(dirname),strupr(username))!=0)
{printf(\ else {
printf(\ gets(fname);
ltrim(rtrim(fname)); if (ExistF(fname)>=0)
{printf(\
wgetchar=1; } else
{printf(\3-Protect):\
gets(fmode);
ltrim(rtrim(fmode));
if((strcmp(fmode,\ {fpaddrno=FindPANo(); if (fpaddrno>=0) {i=ExistD(username);
rcmp(fmode,\
}
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),\
{fp_file=fopen(str,\
ufd[i]->ufdfile[fcount[i]-1].flength=WriteF1(); flag=0;
}
else if(strcmp(strupr(a),\ }
printf(\ } else
{printf(\ }
else {printf(\
}}
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(\ while((c=getchar())!='#') {fprintf(fp_file,\ if (c!='\\n') length++; } fprintf(fp_file,\ 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,Exist-i,Not Exist-0*/ int ExistD(char *dirname); if (strcmp(strupr(dirname),strupr(username))!=0) {printf(\ else {printf(\ gets(fname); ltrim(rtrim(fname)); i=ExistF(fname); if (i>=0) {k=ExistD(username); if(ifopen[k][i].ifopen==1) {printf(\ else { while(flag) {printf(\gets(a); ltrim(rtrim(a)); if(strcmp(strupr(a),\ {fpaddrno[ufd[k]->ufdfile[i].fpaddr]=0; itoa(ufd[k]->ufdfile[i].fpaddr,str,10); for(j=i;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; delete.\\n\ ifopen[k][j]=ifopen[k][j+1]; } fcount[k]--; strcpy(str1,\strcat(str1,str); remove(str1); flag=0; printf(\wgetchar=1; } else if(strcmp(strupr(a),\ {printf(\ wgetchar=1; flag=0;} }}} else {printf(\}
共分享92篇相关文档