




已閱讀5頁,還剩15頁未讀, 繼續(xù)免費(fèi)閱讀
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
文件系統(tǒng)設(shè)計(jì)1文件系統(tǒng)下列幾條命令LOGIN用戶登陸DIR列文件目錄CREATE創(chuàng)建文件DELETE刪除文件OPEN打開文件CLOSE關(guān)閉文件READ讀文件WRITE寫文件列目錄時要列出文件名,物理地址,保護(hù)碼和文件長度。源文件可以進(jìn)行讀寫保護(hù)。首先應(yīng)確定文件系統(tǒng)的數(shù)據(jù)結(jié)構(gòu):主目錄、子目錄及活動文件等。主目錄和子目錄都以文件的形式存放于磁盤,這樣便于查找和修改。用戶創(chuàng)建的文件,可以編號存儲于磁盤上。如:file0,file1,file2并以編號作為物理地址,在目錄中進(jìn)行登記。程序見下(本程序需要在c:下建一個名為osfile的目錄及一個名為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. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 小農(nóng)場美術(shù)課件
- 幼兒園安全教育之文具安全
- 無源濾波電路課件
- 安徽宜城公開招聘農(nóng)村(村務(wù))工作者筆試題含答案2024年
- 江蘇南通公開招聘農(nóng)村(村務(wù))工作者筆試題含答案2024年
- 湖北隨州2025年公開招聘農(nóng)村黨務(wù)(村務(wù))工作者筆試題帶答案分析
- 溯源文明傳承規(guī)范
- 高中語文詞性解析與應(yīng)用
- 創(chuàng)意美術(shù)《苦瓜寫生》教學(xué)課件
- 中國節(jié)日中的風(fēng)俗禁忌
- GB/T 25146-2010工業(yè)設(shè)備化學(xué)清洗質(zhì)量驗(yàn)收規(guī)范
- GB/T 212-2008煤的工業(yè)分析方法
- GB/T 17390-2010潛油電泵拆卸報(bào)告的編寫
- GB/T 10822-2003一般用途織物芯阻燃輸送帶
- 班主任工作坊活動方案
- 國開電大 管理概論 形考任務(wù)一(畫組織結(jié)構(gòu)圖)
- 三自由度并聯(lián)機(jī)器人結(jié)構(gòu)設(shè)計(jì)
- 倉儲裝卸服務(wù)合同
- 式雙鉤五點(diǎn)安全帶培訓(xùn)課件
- 名片設(shè)計(jì) 課件
- 鉗工實(shí)操評分表(凹凸配合)
評論
0/150
提交評論