2022年操作系统实验文件管 .pdf
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_05.gif)
《2022年操作系统实验文件管 .pdf》由会员分享,可在线阅读,更多相关《2022年操作系统实验文件管 .pdf(13页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、- 1 - 实验七文件管理(磁盘中创建和删除文件夹)姓名:蒙吉学号: 20072411603 指导老师:曹玉林实验目的: 1)了解磁盘的物理组织。2)掌握 windows 系统提供的有关对磁盘操作的函数。3)根据输入的扇区号读/写指定扇区。实验准备知识: 需要了解已经学过的VC+ 工程文件的运行步骤以及它的操作界面常用的设置方法。实验内容: 在已做过的实验五、六的基础上编写一个程序,分别完成如下功能。1) 有个 help 帮助提示。2) 查看位示图。3) 在目录文件中创建子目录。4) 根据当前目录切换到指定目录。5) 搜索所要删除的目录是否为空目录,若是则删除。6) 在当前目录中创建文件名称。
2、7) 搜索所要删除的文件是否存在,若是则删除。8) 列出当前目录的所有目录项,退出程序等。实验要求:深入理解操作系统设备当作文件处理的特性。参考源代码:/ wjgl.cpp: implementation of the wjgl class. / / #include wjgl.h / / Construction/Destruction / wjgl:wjgl() hang=16; lie=16; int j,k; /cout 矩阵的行 hang; /cout 矩阵的列 lie; srand(time(NULL); for(j=0;jlie;j+) juzhen0j=1; for(j=1;j
3、hang;j+) for(k=0;klie;k+) juzhenjk=(rand()%2); cout 当前没有任何目录和文件,系统为 你 自 动 进 入C: , 如 需 帮 助 请 选 择Hname,C); ml-awenjian=NULL; ml-top=NULL; ml-next=NULL; ml-amulu=NULL; wjgl:wjgl() int wjgl:cd() 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 1 页,共 13 页 - - - - - - - - -
4、- 2 - node1 *s; node1 *r; r=(node1 *)malloc(sizeof(node1); s=(node1 *)malloc(sizeof(node1); s=ml; r=zhizhen; char mlname20; cinmlname; if(!strcmp(mlname,.) if(zhizhen-top=NULL) cout 不存在该目录的根目录top; / showweizhi(); return 0; else r=r-amulu; while(r!=NULL) if(!strcmp(r-name,mlname) zhizhen=r; /showweiz
5、hi(); return 0; else if(r-next=NULL) break; r=r-next; cout目录不存在 awenjian; node *s1; s1=(node *)malloc(sizeof(node); /cout 请输入文件的名称fname; /cout 请输入文件的大小daxiao; strcpy(s1-name,fname); s1-daxiao=daxiao; s1-next=NULL; if(s=NULL) zhizhen-awenjian=s1; s1-time=tmpbuf; / cout文件创建成功name,fname) cout文件名字重复next
6、!=NULL) if(!strcmp(s-next-name,fname) 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 2 页,共 13 页 - - - - - - - - - - 3 - cout文 件名字 重复next; s-next=s1; int i,j,k; k=0; int i1=-1; int j1=-1; for(i=0;ihang;i+) for(j=0;jbegin=i*lie+j+1; if(daxiao=1) juzhenij=-1; s1-time=tm
7、pbuf; return 0; else i1=i; j1=j; k+; continue; else if(daxiao-k=1) juzheni1j1=i*lie+j+1; juzhenij=-1; s1-time=tmpbuf; return 0; juzheni1j1=i*lie+j+1; i1=i; j1=j; k+; s1-next=NULL; s1-time=tmpbuf; return 0; void wjgl:showweizhi() cout.setf(3); char dizhi2010; int i=0; int j; node1 *s; node1 *r; r=(no
8、de1 *)malloc(sizeof(node1); s=(node1 *)malloc(sizeof(node1); r=zhizhen; s=r-top; strcpy(dizhii,r-name); i+; /coutname; while(s!=NULL) strcpy(dizhii,s-name); /coutname; s=s-top; i+; for(j=i;j0;j-) coutdizhij-1; if(i=j) 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 3
9、页,共 13 页 - - - - - - - - - - 4 - cout:; else cout; cout; int wjgl:rd() showweizhi(); node1 *r; r=(node1 *)malloc(sizeof(node1); r=zhizhen-amulu; cout 输 入 要 删 除 的 目 录 的 名 字ming; if(r=NULL) cout 目录不存在 name,ming) if(r-amulu!=NULL|r-awenjian!=NULL) cout 目 录 不 空 不 能 删 除amulu=r-next; /cout 删除成功 next!=NULL
10、) if(!strcmp(r-next-name,ming) if(r-next-amulu!=NULL|r-next-awenjian!=NULL) cout 目录不空不能删除next=r-next-next; /cout 删除成功 endl; return 0; cout 目录不存在 amulu; char ming20; cinming; if(r=NULL) node1 *s; s=(node1 *)malloc(sizeof(node1); s-time=tmpbuf; strcpy(s-name,ming); s-awenjian=NULL; s-amulu=NULL; s-nex
11、t=NULL; s-top=zhizhen; zhizhen-amulu=s; else if(!strcmp(r-name,ming) cout目录已经存在next!=NULL) if(!strcmp(r-next-name,ming) cout 目 录 已 经 存 在next; node1 *s; s=(node1 *)malloc(sizeof(node1); s-time=tmpbuf; strcpy(s-name,ming); s-awenjian=NULL; s-amulu=NULL; s-next=NULL; s-top=zhizhen; r-next=s; / cout创建成功
12、 awenjian; / cout请输入文件的名称ming; int i,j; int temp; if(s=NULL) cout 删除不成功 name,ming) i=(s-begin-1)/lie; j=(s-begin-1)%lie; while(juzhenij!=-1) temp=juzhenij; juzhenij=0; i=(temp-1)/lie; j=(temp-1)%lie; juzhenij=0; zhizhen-awenjian=s-next; cout删除成功 next!=NULL) if(!strcmp(s-next-name,ming) i=(s-begin-1)
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 2022年操作系统实验文件管 2022 操作系统 实验 文件
![提示](https://www.taowenge.com/images/bang_tan.gif)
限制150内