教学文库网 - 权威文档分享云平台
您的当前位置:首页 > 精品文档 > 政务民生 >

操作系统2014课程设计(5)

来源:网络收集 时间:2026-07-24
导读: InputPW(loginpw); /*input new password,use '*' replace*/ printf(\ InputPW(logincpw); if (strcmp(loginpw,logincpw)==0) {strcpy(ufd_lp.ufdname,strupr(loginame)); strcpy(ufd_lp.ufdpword,loginpw); fp_mfd

InputPW(loginpw); /*input new password,use '*' replace*/

printf(\ InputPW(logincpw);

if (strcmp(loginpw,logincpw)==0)

{strcpy(ufd_lp.ufdname,strupr(loginame)); strcpy(ufd_lp.ufdpword,loginpw); fp_mfd=fopen(\

fwrite(&ufd_lp,sizeof(OSUFD_LOGIN),1,fp_mfd); fclose(fp_mfd);

strcpy(username,strupr(loginame)); strcpy(dirname,loginame); strcpy(str,\ strcat(str,username);

if((fp_ufd=fopen(str,\{fp_ufd=fopen(str,\ fclose(fp_ufd); }

fp_mfd=fopen(\

for(j=0;fread(&ufd_lp,sizeof(OSUFD_LOGIN),1,fp_mfd)!=0;j++) {strcpy(str,\ strcat(str,ufd_lp.ufdname);

ufd[j]=(OSUFD*)malloc(sizeof(OSUFD));

strcpy(ufd[j]->ufdname,strupr(ufd_lp.ufdname)); fp_ufd=fopen(str,\

for(i=0;fread(&ufd[j]->ufdfile[i],sizeof(OSFILE),1,fp_ufd)!=0;i++,fcount[j]++) {ifopen[j][i].ifopen=0; ifopen[j][i].openmode=4;} fclose(fp_ufd);} fclose(fp_mfd); ucount=j; SetPANo(0);

printf(\ loginsuc=1; return; } else

{printf(\ flag=1; while(flag)

{printf(\ gets(a);

ltrim(rtrim(a));

if (strcmp(strupr(a),\

else if(strcmp(strupr(a),\

} } } } }

void SetPANo(int RorW) /*Set physical address num,0-read,1-write*/ {int i,j; if (RorW==0)

{if((fp_file_p=fopen(\ {fp_file_p=fopen(\ fclose(fp_file_p); }

fp_file_p=fopen(\ for(i=0;fread(&j,sizeof(int),1,fp_file_p)!=0;i++) fpaddrno[j]=1; /*for(i=1;i

if ((i)==0) fpaddrno[i]=1;*/ } else

{fp_file_p=fopen(\ /*for(i=1;i

if((i)==0) fpaddrno[i]=0;*/ for(i=0;i

fwrite(&i,sizeof(int),1,fp_file_p); }

fclose(fp_file_p); }

void InputPW(char *password) /*input password,use '*' replace*/ {int j;

for(j=0;j<=7;j++) {password[j]=getch(); if ((int)(password[j])!=13) {if((int)(password[j])!=8) putchar('*'); else {if (j>0) {j--;j--;

putchar('\\b');putchar(' ');putchar('\\b'); }

else j--; }

} else

{password[j]='\\0'; break; } }

password[j]='\\0'; }

void DirF() /*Dir FileSystem*/ {int i,j,count=0;

char sfmode[25],sfpaddr[25],str[25];

int ExistD(char *dirname); /*Whether DirName Exist,Exist-i,Not Exist-0*/ clrscr();

if (strcmp(strupr(ltrim(rtrim(dirname))),\ {printf(\

printf(\eMode\

j=ExistD(dirname); for(i=0;i

{printf(\ getch(); clrscr();

printf(\eMode\ }

itoa(ufd[j]->ufdfile[i].fpaddr,str,10); strcpy(sfpaddr,\strcat(sfpaddr,str);

if (ufd[j]->ufdfile[i].fmode==0) strcpy(sfmode,\else if(ufd[j]->ufdfile[i].fmode==1) strcpy(sfmode,\else if(ufd[j]->ufdfile[i].fmode==2)strcpy(sfmode,\else strcpy(sfmode,\

printf(\.flength,\ }

printf(\ else

{printf(\

printf(\ for(i=0;i

{if ((i==0)&&(i!=0))

{printf(\ getch(); clrscr();

printf(\}

printf(\count=count+fcount[i]; }

printf(\ } }

int ExistD(char *dirname) /*Whether DirName Exist,Exist-i,Not Exist-0*/ {int i; int exist=0;

for(i=0;i

if (strcmp(strupr(ufd[i]->ufdname),strupr(dirname))==0) {exist=1; break; }

if (exist) return(i); else return(-1); }

void CdF() /*Exchange Dir*/ {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,\fmode,\

{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),\{fp_file=fopen(str,\

…… 此处隐藏:1917字,全部文档内容请下载后查看。喜欢就下载吧 ……
操作系统2014课程设计(5).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.jiaowen.net/wendang/447902.html(转载请注明文章来源)
Copyright © 2020-2025 教文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:78024566 邮箱:78024566@qq.com
苏ICP备19068818号-2
Top
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)