操作系统文件管理实验报告要点.pdf

上传人:tbuqq 文档编号:5208631 上传时间:2020-02-21 格式:PDF 页数:12 大小:202.71KB
返回 下载 相关 举报
操作系统文件管理实验报告要点.pdf_第1页
第1页 / 共12页
操作系统文件管理实验报告要点.pdf_第2页
第2页 / 共12页
操作系统文件管理实验报告要点.pdf_第3页
第3页 / 共12页
操作系统文件管理实验报告要点.pdf_第4页
第4页 / 共12页
操作系统文件管理实验报告要点.pdf_第5页
第5页 / 共12页
点击查看更多>>
资源描述

《操作系统文件管理实验报告要点.pdf》由会员分享,可在线阅读,更多相关《操作系统文件管理实验报告要点.pdf(12页珍藏版)》请在三一文库上搜索。

1、操作系统实验报告 实验名称:文件管理 专业班级:网络工程 1301 学号: 姓名: 2015 年 6 月 16 日 实验一文件管理 一、实验目的 文件管理是操作系统的一个非常重要的组成部分。学生应独立用高级语言编写和调试 一个简单的文件系统,模拟文件管理的工作过程。从而对各种文件操作命令的实质内容和执 行过程有比较深入的了解,掌握它们的实施方法,加深理解课堂上讲授过的知识。 二、预备知识 1.VS2010的使用 2.C# 的学习 3.文件主目录与子目录的理解 三、实验内容与步骤 用高级语言编写和调试一个简单的文件系统,模拟文件管理的工作过程。要求设计一 个 10 个用户的文件系统,每次用户可保

2、存10 个文件,一次运行用户可以打开5 个文件。 系统能够检查打入命令的正确性,出错时能显示出错原因。对文件必须设置保护措施,例如 只能执行,允许读等。在每次打开文件时,根据本次打开的要求,在此设置保护级别,即 有二级保护。文件的操作至少有Create、 delete、 open、close、read、write 等命令。 所编写的程序应采用二级文件目录,即设置主文件目录和用户文件目录。前者应包含文件 主及它们的目录区指针;后者应给出每个文件占有的文件目录,即文件名,保护码,文件长 度以及它们存放的位置等。另外为打开文件设置运行文件目录(AFD ) ,在文件打开时应 填入打开文件号,本次打开保

3、护码和读写指针等。 程序流程图: 逻辑设计: 使用线性数组表表示MFD ,泛型数组表示UFD ,每个元素包括用户ID、保存的文件 数、再使用线性表表示文件信息,每个元素包括文件名,文件属性(保护码),文件的状 态等信息。 物理设计: /主目录 private FileUser mfd; /当前用户 private FileUser currentuser; / / 文件 / public class FileObject public string filename; public int size=20; public int read=0; public int write = 0; pu

4、blic string author; / / 文件系统用户 / public class FileUser public string username; public List ufd = new List(); public int filecount=0; 步骤详述: 1、主目录及用户目录机构显示: 2、当前操作用户登录: 3、文件管理系统菜单: 4、create命令: 5、open 命令: 6、close 命令: 7、delete 命令: 8、read 命令 9、write 命令 10、exit 命令 四、实验总结 通过这次的课程设计使我认识到要将操作系统这门计算机专业的课学好不 仅

5、仅是要把书上的基本知识学好而且还要不断进行实践,将所学的跟实践操作结 合起来才能更好地巩固所学,才能提高自己实践能力. 通过这次的设计使我认识 到只停留在表面理解问题是很难使问题得到很好的解决的,实践能力与理论知识 同样重要。可以说此课程设计的理论难度并不大, 但是若要深入发掘其中的东西, 并且实际去编程实现, 就遇到了相当大的难度。 因为与之涉及的很多方面并没有 学过,需要自己去自学和实践检验。 五、程序清单 using System; using System.Collections.Generic; using System.Linq; using System.Text; namesp

6、ace filemanagesystem class Program static void Main(string args) /初始化用户自模拟文件系统 ExplorerInUser explorer = new ExplorerInUser(); / / 文件管理系统 for 用户自模拟 / public class ExplorerInUser /命令列表 private string command = “create“, “open“, “close“, “delete“, “read“, “write“,“exit“ ; /主目录 private FileUser mfd; /当

7、前用户 private FileUser currentuser; / / 构造函数 / public ExplorerInUser() INI(); / / 初始化系统 / private void INI() if (currentuser = null) /主目录实现 IniUserList(); /系那是菜单 InilizeMenu(); bool isinput = false; /输入正确的命令 while (!isinput) string input = Console.ReadLine(); isinput=CommandGroup(input); #region 主目录 /

8、 / 获取用户个数 / / private int GetUserCount() string input = Console.ReadLine(); try int 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 FileUseruser_size

9、; for (int i = 0; i / 用户登录 / private void IniLogin() Console.WriteLine(“请输入用户名: “); bool issuccess = false; while (!issuccess) string username = Console.ReadLine(); for (int i = 0; i / 初始化菜单 / private void InilizeMenu() Console.WriteLine(“欢迎进入文件管理系统 !“); Console.WriteLine(“-create-“); Console.WriteL

10、ine(“-open-“); Console.WriteLine(“-close-“); Console.WriteLine(“-delete-“); Console.WriteLine(“-read-“); Console.WriteLine(“-write-“); Console.WriteLine(“-exit-“); Console.WriteLine(“请输入操作命令: “); / / 功能分组判断 / / / private bool CommandGroup(string command) bool isexit = true; switch (command) case “cr

11、eate“: 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 (isexit) INI(); else Console.WriteLine(“请重新输入操作命令: “

12、); return isexit; #endregion #region 操作命令方法 / / 创建新的文件 / private void create() Console.WriteLine(“请输入新件名: “); string filename = Console.ReadLine(); currentuser.filecount+; FileObject file = new FileObject(); file.filename = filename; file.author = currentuser.username; currentuser.ufd.Add(file); Con

13、sole.WriteLine(“成功创建文件! “); / / 打开指定的文件 / private void open() Console.WriteLine(“请输入文件名: “); string filename = Console.ReadLine(); for (int i = 0; i / 关闭所有打开的文件 / private void close() Console.WriteLine(“已关闭文件 “); / / 删除文件 / private void delete() Console.WriteLine(“请输入文件名: “); string filename = Conso

14、le.ReadLine(); for (int i = 0; i / 读取文件 / private void read() Console.WriteLine(“请输入文件名: “); string filename = Console.ReadLine(); for (int i = 0; i / 写入文件 / private void write() Console.WriteLine(“请输入文件名: “); string filename = Console.ReadLine(); for (int i = 0; i / 退出系统 / private void exit() Conso

15、le.WriteLine(“您好,您已经成功退出系统!“); Console.ReadKey(); #endregion / / 文件 / public class FileObject public string filename; public int size=20; public int read=0; public int write = 0; public string author; / / 文件系统用户 / public class FileUser public string username; public List ufd = new List(); public int filecount=0;

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 其他


经营许可证编号:宁ICP备18001539号-1