操作系統(tǒng)文件管理試驗報告_第1頁
操作系統(tǒng)文件管理試驗報告_第2頁
操作系統(tǒng)文件管理試驗報告_第3頁
操作系統(tǒng)文件管理試驗報告_第4頁
操作系統(tǒng)文件管理試驗報告_第5頁
已閱讀5頁,還剩11頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、操作系統(tǒng)實驗報告實驗名稱:文件管理專業(yè)班級:網絡工程1301學 號:姓 名:2015年6月16日實驗一文件管理一、實驗目的文件管理是操作系統(tǒng)的一個非常重要的組成部分。學生應獨立用高級語言編寫和調試一個簡單的文件系統(tǒng), 模擬文件管理的工作過程。 從而對各種文件操作命令的實質內容和執(zhí) 行過程有比較深入的了解,掌握它們的實施方法,加深理解課堂上講授過的知識。二、預備知識1. VS2010的使用2. C#的學習3. 文件主目錄與子目錄的理解三、實驗內容與步驟用高級語言編寫和調試一個簡單的文件系統(tǒng),模擬文件管理的工作過程。要求設計一個10個用戶的文件系統(tǒng),每次用戶可保存10個文件,一次運行用戶可以打開5

2、個文件。系統(tǒng)能夠檢查打入命令的正確性,出錯時能顯示出錯原因。對文件必須設置保護措施,例如只能執(zhí)行,允許讀等。在每次打開文件時,根據(jù)本次打開的要求,在此設置保護級別,即有二級保護。文件的操作至少有 Create、 delete、 open、close、read、write 等命令。所編寫的程序應采用二級文件目錄,即設置主文件目錄和用戶文件目錄。前者應包含文件主及它們的目錄區(qū)指針;后者應給出每個文件占有的文件目錄,即文件名,保護碼,文件長度以及它們存放的位置等。另外為打開文件設置運行文件目錄(AFD ),在文件打開時應填入打開文件號,本次打開保護碼和讀寫指針等。程序流程圖:邏輯設計:保存的文件,文

3、件的狀使用線性數(shù)組表表示MFD,泛型數(shù)組表示UFD,每個元素包括用戶ID、數(shù)、再使用線性表表示文件信息,每個元素包括文件名,文件屬性(保護碼) 態(tài)等信息。物理設計:/主目錄private mfd;/當前用戶private curre ntuser;/ III文件/ public class public stri ng ;public int size=20;public int read=0;public int write = 0;public string author;/ /文件系統(tǒng)用戶/ public class public stri ng user name;public Lis

4、t ufd = new List();public int ;步驟詳述:1、主目錄及用戶目錄機構顯示:tuiser_0,30*nfd_usci,-_0 0j-nfd_usep_0 d_us e廣_皿.user_l3 d_usei*_l Q-nfdUsei*-!.usei*_2,2Bj-nf d_user-_2 0nf d_us ei-_2 0jinrd_user_2 jusei*_3,3 d_user-_3 d_user_3 0,nfd_usei*_32、當前操作用戶登錄:請輸入用戶名nF 4_ws:ei_2當前用戶:3、文件管理系統(tǒng)菜單:歡迎進入文件管理系統(tǒng)$ere a,七巳c peni c

5、 loseexit請輸人操作命今;4、create 命令:5、open 命令:諳輸入操作命令open蒂輸入文件名:54120701文件不存在!幘輸入操作命令;ppen恃輸入文件名;541207030124I1JY TXT肉功打開文件!1D:3FileName:5 41267S30124NJY.TXTKi2e:20ftutop :mfd_usei*_26、close 命令:7、delete 命令:贋輸入操作命令; delete 清輸入文件名:54120703ei24HJ.IKT陸功刪除文件8、read命令9、write 命令請輸入操作命令: 請輸入文件名;541207030124MJV.TKT己

6、呂入文件!10、exit 命令請輸入操作命令:escit您好I您已經成功退岀系統(tǒng)辛四、實驗總結通過這次的課程設計使我認識到要將操作系統(tǒng)這門計算機專業(yè)的課學好不 僅僅是要把書上的基本知識學好而且還要不斷進行實踐,將所學的跟實踐操作結 合起來才能更好地鞏固所學,才能提高自己實踐能力通過這次的設計使我認識到只停留在表面理解問題是很難使問題得到很好的解決的,實踐能力與理論知識 同樣重要。可以說此課程設計的理論難度并不大,但是若要深入發(fā)掘其中的東西, 并且實際去編程實現(xiàn),就遇到了相當大的難度。因為與之涉及的很多方面并沒有 學過,需要自己去自學和實踐檢驗。五、程序清單using System;using

7、System.Collectio ns.Ge neric;using System丄inq;using System.Text;n amespaceclass Programstatic void Main( stri ng args)/初始化用戶自模擬文件系統(tǒng)ExplorerI nUser explorer = new ExplorerI nUser();III III 文件管理系統(tǒng)for用戶自模擬III public class ExplorerI nUser/ 命令列表delete,private string command= create, open, close, read, wr

8、ite,exit ;/ 主目錄 private mfd;/ 當前用戶 private currentuser;/ / 構造函數(shù)/ public ExplorerInUser()INI();/ / 初始化系統(tǒng)/ private void INI()if (currentuser = null)/ 主目錄實現(xiàn) IniUserList();/ 系那是菜單 InilizeMenu(); bool isinput = false;/ 輸入正確的命令 while (!isinput)string input = Console.ReadLine(); isinput=CommandGroup(input)

9、;#region 主目錄/ / 獲取用戶個數(shù)/ / private int GetUserCount() string input = Console.ReadLine();tryint user_size = Convert.ToInt32(input); return user_size;catch (Exception e) Console.WriteLine(e.Message); return 0;/ / 生成用戶及用戶管理文件/ private void IniUserList()int user_size = GetUserCount(); mfd=new user_size;f

10、or (int i = 0; i user_size; i+)mfdi = new (); mfdi.username = mfd_user_+i; mfdi. = 3;Console.WriteLine(mfd: + mfdi.username + mfdi.);for (int j = 0; j 3; j+)();= mfdi.username;Console.WriteLine(-ufd:+,+,+);mfdi.ufd.Add(file);IniLogin();/ / 用戶登錄/ private void IniLogin() 請輸入用戶名: );Console.WriteLine( b

11、ool issuccess = false; while (!issuccess)string username = Console.ReadLine();for (int i = 0; i mfd.Length; i+)if (mfdi.username.Equals(username) issuccess = true; currentuser = mfdi; Console.WriteLine( 當前用戶: +username); break;if (!issuccess)Console.WriteLine( 請重新輸入輸入用戶名: ); #endregion#region 菜單/ /

12、初始化菜單/ private void InilizeMenu()Console.WriteLine( 歡迎進入文件管理系統(tǒng) !); Console.WriteLine(create);Console.WriteLine(open);Console.WriteLine(close);Console.WriteLine(delete);Console.WriteLine(read);Console.WriteLine( write);Console.WriteLine( exit);Console.WriteLine( 請輸入操作命令: );/ / 功能分組判斷/ / / private boo

13、l CommandGroup(string command) bool isexit = true;switch (command)case create: create(); break;case open: open(); break;case close: close(); break;case delete: delete(); break;case read: read(); break;case write: write(); break;case exit: exit(); return true; break;default:isexit = false; break;if (

14、isexit) INI(); else Console.WriteLine( return isexit;#endregion請重新輸入操作命令:); #region 操作命令方法/ / 創(chuàng)建新的文件/ private void create()Console.WriteLine( 請輸入新件名: ); string = Console.ReadLine();currentuser.;file = new ();= currentuser.username; currentuser.ufd.Add(file); Console.WriteLine(成功創(chuàng)建文件! );/ / 打開指定的文件/

15、private void open() Console.WriteLine( 請輸入文件名: ); string = Console.ReadLine();for (int i = 0; i currentuser.ufd.Count; i+););if (currentuser.ufdi.()Console.WriteLine( 成功打開文件! );Console.WriteLine(ID:+i);Console.WriteLine(:+);Console.WriteLine(Size:currentuser.ufdi.size);Console.WriteLine(Autor:curren

16、tuser.ufdi.author);return; Console.WriteLine( 文件不存在!/ / 關閉所有打開的文件/ private void close() Console.WriteLine( 已關閉文件 );/ / 刪除文件/ private void delete()Console.WriteLine( 請輸入文件名:string = Console.ReadLine();for (int i = 0; i currentuser.ufd.Count; i+) if (currentuser.ufdi.()currentuser.ufd.RemoveAt(i););Co

17、nsole.WriteLine( return; Console.WriteLine(/ / 讀取文件/ private void read() Console.WriteLine(成功刪除文件!文件不存在! );請輸入文件名: );string = Console.ReadLine();for (int i = 0; i currentuser.ufd.Count; i+)if (currentuser.ufdi.()Console.WriteLine( return; Console.WriteLine(/ / 寫入文件已讀取文件! );文件不存在! );/ private void write() Console.WriteLine( 請輸入文件名: ); string = Console.ReadLine();for (int i = 0; i currentuser.ufd.Count; i+) !);if (currentuser.ufdi.() Console.WriteLine( return; Console.WriteLine(/ / 退出系統(tǒng)/ private void exit() Consol

溫馨提示

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

評論

0/150

提交評論