欢迎来到冰豆网! | 帮助中心 分享价值,成长自我!
冰豆网
全部分类
  • IT计算机>
  • 经管营销>
  • 医药卫生>
  • 自然科学>
  • 农林牧渔>
  • 人文社科>
  • 工程科技>
  • PPT模板>
  • 求职职场>
  • 解决方案>
  • 总结汇报>
  • 党团工作>
  • ImageVerifierCode 换一换
    首页 冰豆网 > 资源分类 > DOCX文档下载
    分享到微信 分享到微博 分享到QQ空间

    操作系统试验模拟文件管理系统.docx

    • 资源ID:7790949       资源大小:21.25KB        全文页数:17页
    • 资源格式: DOCX        下载积分:12金币
    快捷下载 游客一键下载
    账号登录下载
    微信登录下载
    三方登录下载: 微信开放平台登录 QQ登录
    二维码
    微信扫一扫登录
    下载资源需要12金币
    邮箱/手机:
    温馨提示:
    快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
    如填写123,账号就是123,密码也是123。
    支付方式: 支付宝    微信支付   
    验证码:   换一换

    加入VIP,免费下载
     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    操作系统试验模拟文件管理系统.docx

    1、操作系统试验模拟文件管理系统【实验报告正文】一、实验目的和要求(必填)实验目的:通过在VC平台下编程,设计和调试一个简单的文件系统,通过模拟文件操作命令的执行,来模拟文件系统对文件及目录的管理。实验要求:两名学生成组结对完成实验,仿真出文件系统中对文件和目录的操作。二、实验容(必填)文件管理:实现一个简单的文件系统三、实验原理或实验方法(必填)原理:通过结构体来描述文件和目录,利用链表知识实现目录树结构,通过对链表的操作实现整个文件系统中目录和文件的相关操作。方法:学生两人结对进行实验,分别实现对文件和目录的操作。对文件的操作包括:创建文件create、读文件read、写文件write、删除文

    2、件delete。对目录的操作包括:创建目录mkdir、切换目录cd、展示目录容dir、删除目录rm。四、主要仪器设备或实验条件Windows操作系统,VC开发环境五、实验步骤(含实验数据记录处理)或操作设计过程记录#include stdio.h#include iostream.h#include string.h#define FILENAME_LENGTH 10 /文件名称长度#define MAND_LENGTH 10 /命令行长度#define PATH_LENGTH 30 /参数长度struct filenode char filenameFILENAME_LENGTH; int

    3、isdir; char content255; filenode *parent; filenode *child; filenode *prev; filenode *next;filenode *initnode(char filename,int isdir); void createroot(); int run(); int findpath(char *topath); void help(); int mkdir(); int create(); int read(); int write(); int del(); int rm(); int cd(); int dir();f

    4、ilenode *root,*recent,*temp,*ttemp,*temp_child;char pathPATH_LENGTH,mandMAND_LENGTH,temppathPATH_LENGTH,recentpathPATH_LENGTH;/创建文件或目录的存储节点filenode* initnode(char filename,int isdir) filenode *node=new filenode; strcpy(node-filename,filename); node-isdir=isdir; node-parent=NULL; node-child=NULL; nod

    5、e-prev=NULL; node-next=NULL; return node;/初始化文件系统根结点void createroot () recent=root=initnode(/,1); root-parent=NULL; root-child=NULL; root-prev=root-next=NULL; strcpy(path,/); void help() coutendl; coutcreate: 建立文件。 endl; coutread: 读取文件。 endl; coutwrite: 写入文件。 endl; coutdelete: 删除文件。 endl; coutrm: 删除

    6、目录。 endl; coutmkdir: 建立目录。 endl; coutcd: 切换目录。 endl; coutdir: 显示目录。 endl; coutlogout: 退出登录。 endl;int dir()int i=0,j=0;temp=new filenode;temp=recent;if(temp=root)cout .endl; if(temp!=root)cout .child=NULL) coutTotal: directors i files j child;while(temp) if(temp-isdir) cout filenameendl;i+; else cout

    7、 filenamenext; coutTotal: directors i files j filename; if(recent-child=NULL) cout文件不存在!child-filename,filename)=0) coutchild-contentchild; while(temp-next) if(strcmp(temp-next-filename,filename)=0) coutnext-contentendl; return 0; cout文件不存在!filename; if(recent-child=NULL) cout文件不存在!child-filename,fi

    8、lename)=0) cinrecent-child-content; cout文件写入成功!child; while(temp-next) if(strcmp(temp-next-filename,filename)=0) cintemp-next-content; cout文件写入成功!endl;return 0; cout文件不存在!filename; temp=new filenode; if(recent-child) temp=recent-child; while(temp-next & (strcmp(temp-filename,filename)!=0 | temp-isdi

    9、r!=0) temp=temp-next; if(strcmp(temp-filename,filename)!=0 | temp-isdir!=0) cout不存在该文件!endl; return 0; else cout不存在该文件!parent=NULL) temp-prev-next=temp-next; if(temp-next) temp-next-prev=temp-prev; temp-prev=temp-next=NULL; else if(temp-next) temp-next-parent=temp-parent; temp-parent-child=temp-next

    10、; delete temp; cout文件已删除!filename; temp=new filenode; if(recent-child) temp=recent-child; while(temp-next & (strcmp(temp-filename,filename)!=0 | temp-isdir!=1) temp=temp-next; if(strcmp(temp-filename,filename)!=0 | temp-isdir!=1) cout不存在该目录!endl; return 0; else cout不存在该目录!parent=NULL) temp-prev-next

    11、=temp-next; if(temp-next) temp-next-prev=temp-prev; temp-prev=temp-next=NULL; else if(temp-next) temp-next-parent=temp-parent; temp-parent-child=temp-next; delete temp; cout目录已删除!topath; if(strcmp(topath,.)=0) return 0; if(strcmp(topath,.)=0) int i; while(recent-prev) recent=recent-prev; /向前回溯,找到第一次

    12、创建的目录 if(recent-parent) recent=recent-parent; i=strlen(path); / printf(%d %sn,i,path); while(pathi!=/ & i0) i-; /找到最右边的/ if(i!=0) pathi=0; /printf(%s,path); /path中不止有一个/ else pathi+1=0; else findpath(topath); return 0;int findpath(char *topath) unsigned int i=0; int sign=1; if(strcmp(topath,/)=0) /如

    13、果命令是cd / recent=root; strcpy(path,/); return 0; temp=recent; strcpy(temppath,path); if(topath0=/) /cd命令以cd /开始 recent=root-child; i+; strcpy(path,/);/ printf(n%s,path); else if(recent!=NULL & recent!=root) strcat(path,/); / printf(n%sn,path); if(recent & recent-child) if(recent-isdir) recent=recent-

    14、child; else printf(路径错误!n); return 1; while(ichild) i+; if(recent-isdir) recent=recent-child; else printf(路径错误n); return 1; strcat(path,/); while(topathi!=/ & ifilename,recentpath)!=0 | (recent-isdir!=1) & recent-next!=NULL) recent=recent-next; if(strcmp(recent-filename,recentpath)=0) if(recent-isdi

    15、r=0) strcpy(path,temppath); recent=temp; printf(是文件不是目录。n); return 1; strcat(path,recent-filename); if(strcmp(recent-filename,recentpath)!=0 | recent=NULL) strcpy(path,temppath); recent=temp; printf(输入路径错误n); return 1; return 0;int mkdir() temp=initnode( ,1); cintemp-filename; if(recent-child=NULL)

    16、temp-parent=recent; temp-child=NULL; recent-child=temp; temp-prev=temp-next=NULL; printf(目录建立成功!n); else ttemp=recent-child; if(strcmp(ttemp-filename,temp-filename)=0&ttemp-isdir=1) printf(目录已存在!n); return 1; while(ttemp-next) ttemp=ttemp-next; if(strcmp(ttemp-filename,temp-filename)=0&ttemp-isdir=1

    17、) printf(目录已存在!n); return 1; ttemp-next=temp; temp-parent=NULL; temp-child=NULL; temp-prev=ttemp; temp-next=NULL; printf(目录建立成功!n); return 0;int create() temp=initnode( ,0); cintemp-filename; if(recent-child=NULL) temp-parent=recent; temp-child=NULL; recent-child=temp; temp-prev=temp-next=NULL; cout

    18、文件创建成功!child; if(strcmp(ttemp-filename,temp-filename)=0&ttemp-isdir=0) printf(文件已存在!n); return 1; while(ttemp-next) ttemp=ttemp-next; if(strcmp(ttemp-filename,temp-filename)=0&ttemp-isdir=0) printf(文件已存在!n); return 1; ttemp-next=temp; temp-parent=NULL; temp-child=NULL; temp-prev=ttemp; temp-next=NUL

    19、L; cout文件建立成功!endl; return 0;int run() coutfilesystem:path; cinmand; if(strcmp(mand,mkdir)=0) mkdir(); else if(strcmp(mand,dir)=0) dir(); else if(strcmp(mand,cd)=0) cd(); else if(strcmp(mand,create)=0) create(); else if(strcmp(mand,read)=0) read(); else if(strcmp(mand,rm)=0) rm(); else if(strcmp(man

    20、d,write)=0) write(); else if(strcmp(mand,delete)=0) del(); else if(strcmp(mand,help)=0) help(); else if(strcmp(mand,logout)=0) return 0; else cout请参考help提供的命令列表!endl; return 1; void main() cout*endl; cout*操作系统课程设计项目*endl; cout* 简单文件系统模拟 *endl; cout* 键入help可以获取帮助 *endl; cout*endl; cout*endl;coutendl;createroot();while(1)if(!run()break;


    注意事项

    本文(操作系统试验模拟文件管理系统.docx)为本站会员主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

    copyright@ 2008-2022 冰点文档网站版权所有

    经营许可证编号:鄂ICP备2022015515号-1

    收起
    展开