




已閱讀5頁,還剩15頁未讀, 繼續(xù)免費(fèi)閱讀
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(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打開文件CLOSE關(guān)閉文件READ讀文件WRITE寫文件列目錄時(shí)要列出文件名,物理地址,保護(hù)碼和文件長(zhǎng)度。源文件可以進(jìn)行讀寫保護(hù)。首先應(yīng)確定文件系統(tǒng)的數(shù)據(jù)結(jié)構(gòu):主目錄、子目錄及活動(dòng)文件等。主目錄和子目錄都以文件的形式存放于磁盤,這樣便于查找和修改。用戶創(chuàng)建的文件,可以編號(hào)存儲(chǔ)于磁盤上。如:file0,file1,file2并以編號(hào)作為物理地址,在目錄中進(jì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. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 分配生考試數(shù)學(xué)試卷
- 高二上冊(cè)期末數(shù)學(xué)試卷
- 2025年04月山東工商學(xué)院校醫(yī)院臨床醫(yī)師(省屬高校事業(yè)編制)招聘筆試歷年專業(yè)考點(diǎn)(難、易錯(cuò)點(diǎn))附帶答案詳解
- 2025至2030吹風(fēng)機(jī)行業(yè)市場(chǎng)深度研究與戰(zhàn)略咨詢分析報(bào)告
- 廣東初中期末數(shù)學(xué)試卷
- 中藥材種植技術(shù)培訓(xùn)與中藥材市場(chǎng)分析研究考核試卷
- 乳粉生產(chǎn)質(zhì)量管理中的質(zhì)量信息共享與溝通平臺(tái)搭建考核試卷
- 體育賽事觀眾互動(dòng)的線上線下融合模式考核試卷
- 辦公自動(dòng)化系統(tǒng)調(diào)度系統(tǒng)的實(shí)時(shí)性優(yōu)化技術(shù)考核試卷
- 高中理科必修三數(shù)學(xué)試卷
- 設(shè)備安裝施工環(huán)境保護(hù)工作措施
- 養(yǎng)老院服務(wù)評(píng)價(jià)與改進(jìn)制度
- 地理標(biāo)志產(chǎn)品質(zhì)量要求 清澗紅棗
- 風(fēng)險(xiǎn)經(jīng)理崗位資格考試練習(xí)試題附答案
- 《建筑業(yè)企業(yè)資質(zhì)等級(jí)標(biāo)準(zhǔn)》(建建200182號(hào))-20210829233
- 城鎮(zhèn)污泥標(biāo)準(zhǔn)檢驗(yàn)方法CJT221-2023 知識(shí)培訓(xùn)
- 村打井施工合同范本
- 屋頂分布式光伏電站施工組織設(shè)計(jì)方案
- 員工委派協(xié)議書
- DB11T 1034.2-2024交通噪聲污染緩解工程技術(shù)規(guī)范 第2部分:聲屏障措施
- 初一語文期末試卷及參考答案
評(píng)論
0/150
提交評(píng)論