您好,欢迎访问三七文档
当前位置:首页 > 临时分类 > 操作系统课程设计文档
课程设计日期:2010学年秋学期《操作系统》课程设计题目:模拟磁盘操作系统专业:软件工程班级:软件2班姓名:XX学号:20083880指导教师:XXX成绩:计算机与信息工程学院2010年12月15日附件:课程设计内容模拟磁盘操作系统一:课程设计的目的1、掌握操作系统基本理论与管理方式;2、在算法基础上,解决实际的管理功能的问题,提高学生实际应用、编程的能力。3.了解文件系统的一般原理。二:课程设计的内容和要求1、涉及编程题目时,要求详细书写文档内容;2.问题分析及解决方案确定;3、形成编程思路;4、使用具体语言实现算法;5、上机调试程序;6、编写课程设计报告.三:课程设计说明书和图纸要求3.1设计题目与要求要求:1.自定义磁盘操作系统命令解释器所需要的各种常用命令的数据结构;2.至少具有显示文件、时间、日期、删除文件操作命令;3.提供命令运行界面;4.设置一定的内部命令和外部命令3.2总的设计思想及系统平台、语言、工具等设计思想:通过用户输入不同的命令来调用不同的方法来实现磁盘操作系统,包括文件的增,删,查,改。平台:xp语言:java工具:eclipse,myeclipse3.3数据结构与模块说明(功能与流程图)主程序流程图:显示子目录和子文件的流程图:创建文件或文件夹的流程图复制文件或文件夹流程图四:程序设计4.1函数定义//root的get方法publicStringgetRoot();//root的set方法publicvoidsetRoot(Stringroot);//Start的构造方法publicStart();//程序开始privatevoidlaunch();//Deal的构造方法Deal(Starts,BufferedReaderbr);//输出子目录和子文件名publicvoidshowChildren();//改变根目录publicvoidchangeRoot(Stringtype);//返回上级父目录publicvoidback();//创建文件夹或文件publicvoidcreate();//打开文件方法publicvoidopen(Stringtype);//复制文件或文件夹的选择方法publicvoidcopy(Stringfilepath);//复制文件的方法publicvoidcopyFile(Filesrc,Filedec);//复制文件夹的方法publicvoidcopyDir(Filefile,Filefile2);//显示文件夹结构的初始化方法publicvoidshow();//显示文件夹结构的方法publicvoidlist(Filef,intlevel);//删除文件夹或文件的方法publicvoiddelete(Filefile);//文件重命名或文件夹重命名方法publicbooleanfileReName(Stringtype);//文件或文件夹移动的方法publicvoidmove(Stringfilepath);4.2变量定义BufferedReaderbr=null;//输入流,用于接收用户的输入Dealdeal;//对象名Stringtype=null;//用户的选择的功能Stringroot;//默认的根目录4.3源程序Start.javaimportjava.io.BufferedReader;importjava.io.File;importjava.io.IOException;importjava.io.InputStreamReader;publicclassStart{privateBufferedReaderbr=null;privateStringroot=C:/DocumentsandSettings/Administrator;privateDealdeal=null;//root的get方法publicStringgetRoot(){returnroot;}//root的set方法publicvoidsetRoot(Stringroot){this.root=root;}publicstaticvoidmain(String[]args){newStart().launch();}//Start的构造方法publicStart(){br=newBufferedReader(newInputStreamReader(System.in));deal=newDeal(this,br);}//程序开始privatevoidlaunch(){try{Stringtype=null;while(true){System.out.println(*****************************);System.out.println(root);type=br.readLine();if(type.matches(\\w:)){Filefile=newFile(type);if(file.exists()){this.setRoot(type);}else{System.out.println(文件目录不存在!);}}elseif(type.matches(cd\\s\\.\\.)){deal.back();}elseif(type.matches(cd\\s.+)){//cd\\s\\w{1,}(/\\w{1,})*(/\\w{1,}\\.\\w{1,})?deal.changeRoot(type);//--}elseif(type.equalsIgnoreCase(dir)){deal.showChildren();//对D盘无效}elseif(type.equalsIgnoreCase(create)){deal.create();}elseif(type.matches(open\\s\\w{1,}\\.\\w{1,})){deal.open(type);}elseif(type.matches(copy\\s.{1,})){deal.copy(type);}elseif(type.equalsIgnoreCase(show)){deal.show();}elseif(type.equalsIgnoreCase(delete)){deal.delete(newFile(root));deal.back();}elseif(type.matches(rename\\s.{1,})){if(deal.fileReName(type)){deal.back();}}elseif(type.matches(move\\s.+)){deal.move(type);deal.back();}elseif(type.equalsIgnoreCase(help)){System.out.println(x:--------------------进入x盘);System.out.println(cd+空格+目录----------进入子目录);System.out.println(cd+空格+..------------返回上一级目录);System.out.println(dir-------------------列出当前目录下的所有子目录和文件);System.out.println(create----------------创建文件夹或文件);System.out.println(open+空格+文件名------打开文件);System.out.println(copy------------------复制当前文件或文件夹);System.out.println(move------------------移动当前文件或文件夹);System.out.println(show------------------列出当前目录下所有子目录和文件的结构);System.out.println(delete----------------删除当前文件夹或文件);System.out.println(rename+空格+目录名----重命名当前目录);System.out.println(rename+空格+文件名--------重命名当前文件);System.out.println(help------------------显示帮助信息);System.out.println(exit------------------退出);}elseif(type.equalsIgnoreCase(exit)){System.exit(0);}else{System.out.println(输入的不是正确命令!);}}}catch(IOExceptione){e.printStackTrace();}}}Deal.javaimportjava.awt.Frame;importjava.io.BufferedReader;importjava.io.File;importjava.io.FileInputStream;importjava.io.FileNotFoundException;importjava.io.FileOutputStream;importjava.io.IOException;importjava.util.Date;importjavax.swing.JOptionPane;publicclassDeal{privateStartstart=null;privateBufferedReaderbr=null;//构造方法Deal(Starts,BufferedReaderbr){this.start=s;this.br=br;}//输出子目录和子文件名publicvoidshowChildren(){Filefile=newFile(start.getRoot());System.out.println(file.getAbsolutePath());if(file.exists()){if(file.isDirectory()){Stringstr[]=file.list();for(inti=0;istr.length;i++){System.out.println(str[i]);}}else{System.out.println(已到达文件末尾!);}}else{System.out.println(输入的不是正确命令!);}}//改变根目录publicvoidchangeRoot(Stringtype){Stringfilepath=type.substring(3);Filefile=newFile(start.getRoot()+/+filepath);if(file.exists()){start.setRoot(start.getRoot()+/+filepath);}else{System.out.println(目录不存在!);}}//返回上级父目录publicvoidback(){Stringroot=start.getRoot();if(root.matches(\\w:)){System.out.println(已到达磁盘根目录,无法继续返回父目录!);return;}else{Stringbackroot=root.substring(0,start.getRoot().lastIndexOf(/));start.setRoot(backroot);}}//创建文件夹或文件publicvoidcreate(){System.out.println(1.创建文件目录);System.out.println(2.创建文件);try{Stringtype=br.readLine();if(type.equals(1)){System.out.println(请输入需要创建的文件目录,以/分隔);Stringmsg=br.readLine();while(!ms
本文标题:操作系统课程设计文档
链接地址:https://www.777doc.com/doc-3897855 .html