![操作系統(tǒng)課程設(shè)計報告二級文件系統(tǒng)java_第1頁](http://file3.renrendoc.com/fileroot_temp3/2022-3/13/a3e011ff-0dfd-4496-9167-053e78128ac4/a3e011ff-0dfd-4496-9167-053e78128ac41.gif)
![操作系統(tǒng)課程設(shè)計報告二級文件系統(tǒng)java_第2頁](http://file3.renrendoc.com/fileroot_temp3/2022-3/13/a3e011ff-0dfd-4496-9167-053e78128ac4/a3e011ff-0dfd-4496-9167-053e78128ac42.gif)
![操作系統(tǒng)課程設(shè)計報告二級文件系統(tǒng)java_第3頁](http://file3.renrendoc.com/fileroot_temp3/2022-3/13/a3e011ff-0dfd-4496-9167-053e78128ac4/a3e011ff-0dfd-4496-9167-053e78128ac43.gif)
![操作系統(tǒng)課程設(shè)計報告二級文件系統(tǒng)java_第4頁](http://file3.renrendoc.com/fileroot_temp3/2022-3/13/a3e011ff-0dfd-4496-9167-053e78128ac4/a3e011ff-0dfd-4496-9167-053e78128ac44.gif)
![操作系統(tǒng)課程設(shè)計報告二級文件系統(tǒng)java_第5頁](http://file3.renrendoc.com/fileroot_temp3/2022-3/13/a3e011ff-0dfd-4496-9167-053e78128ac4/a3e011ff-0dfd-4496-9167-053e78128ac45.gif)
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認(rèn)領(lǐng)
文檔簡介
1、操作系統(tǒng)課程設(shè)計報告題目:為Linux系統(tǒng)設(shè)計一個簡單的二級文件系統(tǒng)指導(dǎo)老師:翟一鳴時間:2012.8.30課程設(shè)計的目的課程設(shè)計目的使學(xué)生熟悉文件管理系統(tǒng)的設(shè)計方法;加深對所學(xué)各種文件操作的了解及其操作方法的特點。通過模擬文件系統(tǒng)的實現(xiàn),深入理解操作系統(tǒng)中文件系統(tǒng)的理論知識加深對教材中的重要算法的理解。同時通過編程實現(xiàn)這些算法,更好地掌握操作系統(tǒng)的原理及實現(xiàn)方法,提高綜合運用各專業(yè)課知識的能力。,課程設(shè)計的要求1,可以實現(xiàn)下列幾條命令:login用戶登錄dir列目錄create創(chuàng)建文件delete刪除文件open打開文件close關(guān)閉文件read讀文件write寫文件2 .列目錄時要列出文件
2、名,物理地址,保護碼和文件長度3 .源文件可以進行讀寫保護三算法設(shè)計本次二級文件系統(tǒng)主要分為五大模塊,分別是用戶登錄模塊、新建目錄模塊、新建文件模塊、刪除文件模塊和讀取文件模塊。用戶登錄成功后才可以進行其他模塊的操作。1用戶登錄模塊用戶登錄模塊要求用戶輸入用戶,當(dāng)輸入正確后才能進行其他模塊操作,否則提示用戶名不存在并詢問用戶是否用此名進行注冊。若用戶名未滿,則提示注冊成功,否則提示用現(xiàn)有注冊用戶,進行登錄,并返回到登錄界面。用戶登錄模塊流程圖如圖1所示。2新建文件模塊新建文件模塊是在用戶出入create指令后進行的,進入后會要求用戶輸入文件名,并判斷文件名是否存在,若沒有則在要求用戶輸入文件讀
3、寫權(quán)限,否則重新輸入新的文件名。新建文件模塊流程圖如圖2所示。3刪除文件模塊刪除文件模塊是根據(jù)用戶鼠標(biāo)右擊時選擇到的節(jié)點來確定要刪除節(jié)點的名字與路徑,然后判斷該節(jié)點是目錄還是文件。若是文件則直接刪除文件,若是目錄則進入該目錄再刪除其全部文件。刪除文件*II塊流程圖如圖4所示。讀取文件模塊,要求用戶要在文件打開的前提下,將磁盤中的內(nèi)容讀取到內(nèi)存中。讀取圖5讀取文件模塊流程圖5寫入文件模塊寫入文件模塊,思路與讀取文件模塊將本相同,只是添加了對讀寫權(quán)限的判斷。6遍歷文件遍歷文件,根據(jù)在用戶登陸時,記錄的值,在二維數(shù)組中,找到用戶的所有文件對象,將相應(yīng)的必須屬性全部打印出來。四程序源代碼1 .文件對象
4、相關(guān)代碼packagecom.file;importjava.io.Serializable;publicclassFileProimplementsSerializableStringfilename;Stringcontent;Stringusername;intflag;intprotectintflag,intprotect)publicFilePro(Stringfilename,Stringusername,Stringcontent,this.filename=filename;this.username=username;this.content=content;this.fl
5、ag=flag;tect=protect;)2 .文件讀寫操作packagecom.file;importjava.io.*;importjava.util.*;publicclassFileConObjectdata=newObject7100;ObjectInputStreamin=null;ObjectOutputStreamout=null;Stringpath="D:file"publicFileCon()for(inti=0;i<7;i+)for(intj=0;j<100;j+)dataij=newFilePro("&quo
6、t;,null,"”,1,0);)publicObject口readData()tryin=newObjectInputStream(newBufferedInputStream(newFileInputStream(path);data=(Object)in.readObject();catch(EOFExceptione)catch(Exceptione)returndata;publicvoidwriteData(Objectdata)tryout=newObjectOutputStream(newBufferedOutputStream(newFileOutputStream
7、(path);out.writeObject(data);out.flush();catch(Exceptione)e.printStackTrace();3 .用戶名操作publicclassUserConList<String>list=newArrayList<String>();ObjectInputStreamin=null;ObjectOutputStreamout=null;Stringpath="D:user"publicList<String>readUser()tryin=newObjectInputStream(ne
8、wBufferedInputStream(newFileInputStream(path);list=(List<String>)in.readObject();catch(EOFExceptione)catch(Exceptione)returnlist;publicvoidwriteUser(List<String>list)tryout=newObjectOutputStream(newBufferedOutputStream(newFileOutputStream(path);out.writeObject(list);out.flush();catch(Exc
9、eptione)e.printStackTrace();4 .主程序packagecom.file;importjava.util.*;publicclassFileSystemObject口data=newObject7100;FileConfc=newFileCon();List<String>user=newArrayList<String>();UserConuc=newUserCon();Stringcmd=newString2;intcurrentuser=0;publicFileSystem()data=fc.readData();user=uc.read
10、User();publicstaticvoidmain(Stringargs)FileSystemfs=newFileSystem();fs.help();)publicvoidhelp()System.out.println(System.out.print(System.out.println(System.out.print(System.out.println(System.out.println(System.out.println(System.out.println(System.out.print(System.out.println(System.out.print(Syst
11、em.out.println(System.out.print(System.out.println(System.out.print(System.out.println(System.out.print(System.out.println("歡迎使用該文件系統(tǒng)")"create");"創(chuàng)建文件");"dir");"列目錄文件");"exit退出系統(tǒng)");“以下命令需加文件名")“eg:open*");"open");"打
12、開文件");"close");“關(guān)閉文件");"read");"讀文件");"write");"寫文件”);"delete");“刪除文件");command();)publicvoidcommand()System.out.print("root:>");Stringcomd=null;Scannerinput=input=newScanner(System.in上comd=input.nextLine();Stringcmd=
13、newString2;cmd=comd.split("");if(cmd0.equals("login")login();elseif(cmd0.equals("create")create();elseif(cmd0.equals("dir")dir();elseif(cmd0.equals("delete")delete(cmd1);elseif(cmd0.equals("open")open(cmd1);elseif(cmd0.equals(close(cmd1);el
14、seif(cmd0.equals(read(cmd1);elseif(cmd0.equals(write(cmd1);elseif(cmd0.equals(System.out.println(System.exit(0);elseSystem.out.println(command();publicvoidlogin()booleanf=false:System.out.println(Scannerinput=input="close")"read")"write")"exit")"退出系統(tǒng)!&quo
15、t;);“指令錯誤!”);"請輸入用戶名:");newScanner(System.in)Stringusername=input.next();for(inti=0;i<user.size();i+)if(user.get(i).equals(username)System.out.println("登陸成功!");currentuser=i;f=true;break;if(!f)System.out.println("該用戶不存在,是否以此用戶名注冊?y注冊,其他返回");Stringcho=input.next();if(
16、cho.equals("y")if(user.size()=7)System.out.println("對不起用戶已滿,請利用其他已注冊賬戶登錄");elseuser.add(username);uc.writeUser(user);System.out.println("注冊成功!t#重新登錄");login();command();/目錄publicvoiddir()System.out.println("文件名t"+"用戶名t"+"物理地址t"+"保護碼t&q
17、uot;+"文件長度");for(inti=0;i<100;i+)FileProfp1=(FilePro)datacurrentuseri;if(!fp1.filename.equals("")System.out.println(fp1.filename+"t"+fp1.username+"t"+currentuser+i+"t"+tect+"t"+fp1.content.length();)command();)/創(chuàng)建文件publicvoidcreat
18、e()Scannerinput=input=newScanner(System.in£booleanf=true;booleanfl=false;Stringfilename=null;dofl=false;System.out.print("請輸入文加名:");filename=input.next();for(inti=0;i<100;i+)FileProfp1=(FilePro)datacurrentuseri;if(fp1.filename.equals(filename)System.out.println("文件已存在!");
19、fl=true;break;)while(fl);System.out.print("請輸入權(quán)限:");intprotect=input.nextInt();FileProfp=newFilePro(filename,user.get(currentuser),"",1,protect);for(inti=0;i<100;i+)FileProfp1=(FilePro)datacurrentuseri;if(fp1.filename.equals("")datacurrentuseri=fp;fc.writeData(data);
20、System.out.println("創(chuàng)建成功!");f=false;break;)if(f)System.out.println("磁盤已滿");)command();)/刪除文件publicvoiddelete(Stringfile)booleanf=true;for(inti=0;i<100;i+)FileProfp1=(FilePro)datacurrentuseri;if(fp1.filename.equals(file)fp1.filename=""fp1.content=null;fp1.flag=1;fp1.u
21、sername=null;fc.writeData(data);System.out.println("刪除成功!");f=false;break;)if(f)System.out.println("無此文件");)command();)/打開文件publicvoidopen(Stringfile)booleanf=true;for(inti=0;i<100;i+)FileProfp1=(FilePro)datacurrentuseri;if(fp1.filename.equals(file)if(fp1.flag=0)System.out.pri
22、ntln("文件已打開!");elsefp1.flag=0;");System.out.println("文件打開成功!)f=false;break;)if(f)System.out.println("無此文件");)command();)/關(guān)閉文件publicvoidclose(Stringfile)booleanf=true;for(inti=0;i<100;i+)FileProfp1=(FilePro)datacurrentuseri;if(fp1.filename.equals(file)if(fp1.flag=1)Sy
23、stem.out.println("文件未打開!");elsefp1.flag=1;System.out.println("文件關(guān)閉成功!");)f=false;break;)if(f)System.out.println("無此文件");)command();)/讀文件publicvoidread(Stringfile)booleanf=true;for(inti=0;i<100;i+)FileProfp1=(FilePro)datacurrentuseri;if(fp1.filename.equals(file)if(fp1
24、.flag=1)System.out.println("文件未打開!請先將文件打開!");elsecontent);System.out.println(fp1.f=false;break;)if(f)System.out.println("無此文件");)command();)/寫文件publicvoidwrite(Stringfile)Scannerinput=input=newScanner(System.in);booleanf=true;for(inti=0;i<100;i+)FileProfp1=(FilePro)datacurrentuseri;if(fp1.filename.equals(file)if(fp1.flag=1)System.out.println("文件未打開!請先將文件打開!");else");if(tect!=0)System.out.println("對不起,您沒有寫入的權(quán)限!elseSystem.out.println("請輸入要寫入的內(nèi)容:");Stringss=input.next();fp1.con
溫馨提示
- 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)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 八年級歷史人教版下冊聽課評課記錄:第5課 三大改造
- 林地長期承包合同范本
- 鄉(xiāng)鎮(zhèn)精裝修商鋪出租合同范本
- 儲存場地租賃合同范本
- 廣告公司材料采購合同范本
- 二零二五年度無子女離婚協(xié)議書及子女教育資助合同
- 二零二五年度酒店會議室場地租賃及配套交通合同
- 二零二五年度酒吧租賃合同合同簽訂后的租賃物維護責(zé)任
- 2025年度商鋪轉(zhuǎn)讓三方合同附品牌使用權(quán)及營銷支持
- 夏令營代理商合作協(xié)議書范本
- 三星SHP-DP728指紋鎖說明書
- 預(yù)應(yīng)力錨索張拉及封錨
- 烤煙生產(chǎn)沿革
- GB 1886.227-2016食品安全國家標(biāo)準(zhǔn)食品添加劑嗎啉脂肪酸鹽果蠟
- 毛澤東思想課件-第七章 毛澤東思想的活的靈魂
- 公共關(guān)系效果的評估課件
- 建筑施工安全員理論考核試題與答案
- 高速公路用地勘測定界及放線定樁技術(shù)標(biāo)書
- 華萊士標(biāo)準(zhǔn)化體系
- 快捷smt全自動物料倉儲方案
- keysight眼圖和抖動噪聲基礎(chǔ)知識與測量方法
評論
0/150
提交評論