云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > 计算机操作系统实验讲义

计算机操作系统实验讲义

  • 62 次阅读
  • 3 次下载
  • 2025/5/3 5:02:55

void create(char *str,int num)//在当前目录下创建一个名字为str的文件,长度为num

{

int flag=1;//1表示没有与该名字重名的文件 DirectoryNode *tempnode,*newnode; tempnode=workDirFile->subFile;

while(tempnode)//查找该结点,若有重名文件则报错 { if(tempnode->type==1) { if(!stricmp(tempnode->name,str)) { printf(\ flag=0; } } if (flag==0) break; tempnode=tempnode->next; }

tempnode=workDirFile->subFile; if(flag) { newnode=new DirectoryNode; strcpy(newnode->name,str); newnode->size=num; newnode->type=1; newnode->next=NULL; if(tempnode!=NULL) { while(tempnode->next) { tempnode=tempnode->next; } tempnode->next=newnode; } else { workDirFile->subFile=newnode; } } }

//显示从根目录开始的所有目录和文件及其层次结点

void lsall()//要使用在头文件中定义的队列结构 {

struct DirectoryNode *temp; struct DirectoryNode *tempnode; DataType data; Tp sq;

temp=workDirFile; InitCycQueue(&sq); data.DirFile=&root; strcpy(data.name,\ EncycQueue(&sq,data);

while(Empty(&sq)) { data=OutCycQueue(&sq); printf(\ workDirFile=data.DirFile; dir(); tempnode=workDirFile->subFile; while(tempnode) { if(tempnode->type==0) { data.DirFile=tempnode; strcpy(data.name,tempnode->name); EncycQueue(&sq,data); } tempnode=tempnode->next; } }

workDirFile=temp; }

void cd(char *str)//str表示当前目录下的某个子目录名,如果存在则转移到该目录下

{

int flag=1;

DirectoryNode *tempnode;

tempnode=workDirFile->subFile; if(!stricmp(str,\改变到根目录下 { strcpy(path,\ workDirFile=&root;

flag=0; } else { while(tempnode && flag)//改变到某个目录下 { if(tempnode->type==0) { if(!stricmp(tempnode->name,str)) { workDirFile=tempnode; strcat(path,\ strcat(path,str); flag=0; } } tempnode=tempnode->next; } } if(flag) cout<

void del(char *str)//删除文件 {

int flag=1; char ch='y';

DirectoryNode *tempnode,*oldtempnode; tempnode=workDirFile->subFile; oldtempnode=tempnode; while(tempnode && flag) { if(tempnode->type==1) { if(!stricmp(tempnode->name,str)) { cout<>ch; if(ch='y'||ch=='Y') { if(tempnode==workDirFile->subFile) workDirFile->subFile=tempnode->next; else oldtempnode->next=tempnode->next; flag=0;

free(tempnode); } else flag=0; } //删除成功! } oldtempnode=tempnode; tempnode=tempnode->next; }

if(flag) cout<

void delnode(DirectoryNode *curnode)//删除当前目录下的名字curnode的结点

{

struct DirectoryNode *tempnode,*tempArraynode; if(curnode==NULL) return; if(curnode->type==0) { tempnode=curnode->subFile; while(tempnode) { tempArraynode=tempnode; tempnode=tempnode->next; delnode(tempArraynode);//递归调用 } }

delete curnode; }

void rd(char *str)//删除当前目录下的名字为str的子目录 {

int flag=0; char ch='y';

DirectoryNode *tempnode,*oldtempnode; oldtempnode=NULL;

tempnode=workDirFile->subFile; while(tempnode&&!flag) { if(tempnode->type==0) { if(!stricmp(tempnode->name,str)) flag=1; }

搜索更多关于: 计算机操作系统实验讲义 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

void create(char *str,int num)//在当前目录下创建一个名字为str的文件,长度为num { int flag=1;//1表示没有与该名字重名的文件 DirectoryNode *tempnode,*newnode; tempnode=workDirFile->subFile; while(tempnode)//查找该结点,若有重名文件则报错 { if(tempnode->type==1) { if(!stricmp(tempnode->name,str)) { printf(\ flag=0; } } if (flag==0) break; tempnode=tempnode->next; } t

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com