ImageVerifierCode 换一换
格式:DOCX , 页数:26 ,大小:245.60KB ,
资源ID:4469077      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/4469077.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(文件管理.docx)为本站会员(b****3)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

文件管理.docx

1、文件管理华中师范大学计算机科学系操作系统实验报告实验题目:文件管理 学生姓名: 学生学号: 日期:2011-12-18 实验 4 文件管理【实验目的】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;jh

3、ang;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() node1 *s; node1 *r; r=(node1 *)malloc(sizeof(node1); s=(node1 *)malloc(sizeof(node1); s=ml; r=zhizhen; char mlname20; cinmlnam

4、e; 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; /showweizhi(); return 0; else if(r-next=NULL) break; r=r-next; cout目录不存在awenjian; node *s1; s1=(node *)malloc(sizeof(node); /cout请输入文件的名称fname

5、; /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!=NULL) if(!strcmp(s-next-name,fname) 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=

6、i*lie+j+1; if(daxiao=1) juzhenij=-1; s1-time=tmpbuf; 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 dizhi2

7、010; int i=0; int j; node1 *s; node1 *r; r=(node1 *)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) cout:; else cout; cout;int wjgl:rd()

8、 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) if(!strcmp(r-next-name,ming) if(r-next-amulu!=NULL|r-next-awenjian!=NULL) cout目录不空不能删除next=

9、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-next=NULL; s-top=zhizhen; zhizhen-amulu=s; else if(!strcmp(r-name,ming) cout目录已经存在next!=NULL) if(!str

10、cmp(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创建成功awenjian;/ cout请输入文件的名称ming; int i,j; int temp; if(s=NULL) cout删除不成功name,ming) i=(s-begin-1)/lie; j=(s-b

11、egin-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)/lie; j=(s-begin-1)%lie; while(juzhenij!=-1) temp=juzhenij; juzhenij=0; i=(temp-1)/lie; j=(temp-1)%lie; juzhe

12、nij=0; s-next=s-next-next; / cout删除成功endl; return 0; cout文件不存在不能删除endl; return 0;void wjgl:tree() char c=getchar(); if(c= ) jiansuo(); else shuchu(zhizhen);void wjgl:showweishitu() /cout.width(); int j,k; cout位示图为endl; for(j=0;jhang;j+) for(k=0;klie;k+) coutsetiosflags(ios_base:left)setw(4)juzhenjk;

13、 coutamulu; cout . ; showweizhi(); couttop; if(zhizhen=NULL) ; else cout . ; showweizhi(); coutendl; zhizhen=r1; while(r!=NULL) i+; couttime name next; node *s; s=(node *)malloc(sizeof(node); s=sc-awenjian; while(s!=NULL) j+; k=k+s-daxiao; couttime name 大小 daxiao next; cout当前共有目录i个endl; cout当前共有文件j个

14、 总大小为:kendl; int count=0; for(j=0;jhang;j+) for(k=0;klie;k+) if(juzhenjk=0) count+; cout剩余countendl;void wjgl:jiansuo() int k=0; int i=0; int j=0; char name20;/ cout请输入名称name; int temp1=strlen(name); mulu *r; r=(node1 *)malloc(sizeof(node1); r=zhizhen-amulu; node *s; s=(node *)malloc(sizeof(node); s

15、=zhizhen-awenjian; while(r!=NULL) if(panduan(name,r-name)=1) i+; couttime name ; showweizhi(); coutnext; while(s!=NULL) if(panduan(name,s-name)=1) j+; couttime name 大小 daxiao daxiao; showweizhi(); coutnext; cout目录i个endl; cout文件j个 总大小为kendl; int count=0; for(j=0;jhang;j+) for(k=0;klie;k+) if(juzhenjk

16、=0) count+; cout剩余countendl;int wjgl:panduan(char a, char b) int biaoji=0; if(!strcmp(a,b) return 1; int temp=strlen(a); int temp1=strlen(b); int i,j; for(i=0,j=0;itemp&jtemp1) return 0; return 1;*/#include#includewjgl.husing namespace std;void menu() coutH-helpendl; coutS -查看位示图endl; coutMD-在目录文件中创

17、建子目录endl; coutCD-根据当前目录切换到指定目录endl; coutRD-搜索所要删除的目录是否为空目录,若是则删除endl; coutMK-在当前目录中创建文件名称endl; coutDEL-搜索所要删除的文件是否存在,若是则删除endl; coutDIR-列出当前目录的所有目录项endl; coutE-退出程序endl;int main() wjgl awjgl; /menu(); while(1) awjgl.showweizhi(); /cout请选择操作xuanxiang; if(!strcmp(xuanxiang,H)|!strcmp(xuanxiang,h) menu(); if(!strcmp(xuanxiang,MD)|!strcmp(xuanxiang,md) awjgl.md()

copyright@ 2008-2022 冰豆网网站版权所有

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