文件系統(tǒng)設(shè)計(jì).doc_第1頁(yè)
文件系統(tǒng)設(shè)計(jì).doc_第2頁(yè)
文件系統(tǒng)設(shè)計(jì).doc_第3頁(yè)
文件系統(tǒng)設(shè)計(jì).doc_第4頁(yè)
文件系統(tǒng)設(shè)計(jì).doc_第5頁(yè)
已閱讀5頁(yè),還剩15頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

文件系統(tǒng)設(shè)計(jì)1文件系統(tǒng)下列幾條命令LOGIN用戶登陸DIR列文件目錄CREATE創(chuàng)建文件DELETE刪除文件OPEN打開(kāi)文件CLOSE關(guān)閉文件READ讀文件WRITE寫(xiě)文件列目錄時(shí)要列出文件名,物理地址,保護(hù)碼和文件長(zhǎng)度。源文件可以進(jìn)行讀寫(xiě)保護(hù)。首先應(yīng)確定文件系統(tǒng)的數(shù)據(jù)結(jié)構(gòu):主目錄、子目錄及活動(dòng)文件等。主目錄和子目錄都以文件的形式存放于磁盤,這樣便于查找和修改。用戶創(chuàng)建的文件,可以編號(hào)存儲(chǔ)于磁盤上。如:file0,file1,file2并以編號(hào)作為物理地址,在目錄中進(jìn)行登記。程序見(jiàn)下(本程序需要在c:下建一個(gè)名為osfile的目錄及一個(gè)名為file的子目錄):#includestdio.h#includestring.h#includeconio.h#includestdlib.h#defineMAXNAME25/*thelargestlengthofmfdname,ufdname,filename*/#defineMAXCHILD50/*thelargestchild*/#defineMAX(MAXCHILD*MAXCHILD)/*thesizeoffpaddrno*/typedefstruct/*thestructureofOSFILE*/intfpaddr;/*filephysicaladdress*/intflength;/*filelength*/intfmode;/*filemode:0-ReadOnly;1-WriteOnly;2-ReadandWrite(default);*/charfnameMAXNAME;/*filename*/OSFILE;typedefstruct/*thestructureofOSUFD*/charufdnameMAXNAME;/*ufdname*/OSFILEufdfileMAXCHILD;/*ufdownfile*/OSUFD;typedefstruct/*thestructureofOSUFDLOGIN*/charufdnameMAXNAME;/*ufdname*/charufdpword8;/*ufdpassword*/OSUFD_LOGIN;typedefstruct/*fileopenmode*/intifopen;/*ifopen:0-close,1-open*/intopenmode;/*0-readonly,1-writeonly,2-readandwrite,3-initial*/OSUFD_OPENMODE;OSUFD*ufdMAXCHILD;/*ufdandufdownfiles*/OSUFD_LOGINufd_lp;intucount=0;/*thecountofmfdsufds*/intfcountMAXCHILD;/*thecountofufdsfiles*/intloginsuc=0;/*whetherloginsuccessfully*/charusernameMAXNAME;/*recordloginusersname22*/chardirnameMAXNAME;/*recordcurrentdirectory*/intfpaddrnoMAX;/*recordfilephysicaladdressnum*/OSUFD_OPENMODEifopenMAXCHILDMAXCHILD;/*recordfileopen/close*/intwgetchar;/*whethergetchar()*/FILE*fp_mfd,*fp_ufd,*fp_file_p,*fp_file;voidmain()inti,j,choice1;charchoice50;/*choiceoperation:dir,create,delete,open,delete,modify,read,write*/intchoiceend=1;/*whetherchoiceend*/char*rtrim(char*str);/*removethetrailingblanks.*/char*ltrim(char*str);/*removetheheadingblanks.*/voidLoginF();/*LOGINFileSystem*/voidDirF();/*DirFileSystem*/voidCdF();/*ChangeDir*/voidCreateF();/*CreateFile*/voidDeleteF();/*DeleteFile*/voidModifyFM();/*ModifyFileMode*/voidOpenF();/*OpenFile*/voidCloseF();/*CloseFile*/voidReadF();/*ReadFile*/voidWriteF();/*WriteFile*/voidQuitF();/*QuitFileSystem*/voidhelp();if(fp_mfd=fopen(c:osfilemfd,rb)=NULL)fp_mfd=fopen(c:osfilemfd,wb);fclose(fp_mfd);for(i=0;i,strupr(dirname);elseprintf(Badcommandorfilename.nC:%s,strupr(username);gets(choice);strcpy(choice,ltrim(rtrim(strlwr(choice);if(strcmp(choice,dir)=0)choice1=1;elseif(strcmp(choice,creat)=0)choice1=2;elseif(strcmp(choice,delete)=0)choice1=3;elseif(strcmp(choice,attrib)=0)choice1=4;elseif(strcmp(choice,open)=0)choice1=5;elseif(strcmp(choice,close)=0)choice1=6;elseif(strcmp(choice,read)=0)choice1=7;elseif(strcmp(choice,modify)=0)choice1=8;elseif(strcmp(choice,exit)=0)choice1=9;elseif(strcmp(choice,cls)=0)choice1=10;elseif(strcmp(choice,cd)=0)choice1=11;elseif(strcmp(choice,help)=0)choice1=20;elsechoice1=12;switch(choice1)case1:DirF();choiceend=1;break;case2:CreateF();choiceend=1;if(!wgetchar)getchar();break;case3:DeleteF();choiceend=1;if(!wgetchar)getchar();break;case4:ModifyFM();choiceend=1;if(!wgetchar)getchar();break;case5:choiceend=1;OpenF();if(!wgetchar)getchar();break;case6:choiceend=1;CloseF();if(!wgetchar)getchar();break;case7:choiceend=1;ReadF();if(!wgetchar)getchar();break;case8:choiceend=1;WriteF();if(!wgetchar)getchar();break;case9:printf(nYouhaveexitedthissystem.);QuitF();exit(0);break;case10:choiceend=1;clrscr();break;case11:CdF();choiceend=1;break;case20:help();choiceend=1;break;default:choiceend=0;elseprintf(nAccessdenied.);voidhelp(void)printf(nTheCommandListn);printf(nCdAttribCreatModifyReadOpenClsDeleteExitClosen);char*rtrim(char*str)/*removethetrailingblanks.*/intn=strlen(str)-1;while(n=0)if(*(str+n)!=)*(str+n+1)=0;break;elsen-;if(n0)str0=0;returnstr;char*ltrim(char*str)/*removetheheadingblanks.*/cha

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論