第一范文网 - 专业文章范例文档资料分享平台

操作系统实验报告模板

来源:用户分享 时间:2025/7/24 4:22:53 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

int i,FcbIndex;

//确保没有打开过该文件 = 相同名字 + 相同目录

for(i=0;i

if(openlist->f[i].type ==GENERAL && strcmp(openlist->f [i].fname,file)==0 &&openlist->f[i].fatherBlockNum == current) {

printf(\该文件已经被打开!\\n\ return 0; } }

//确保有空的打开文件项 if(openlist->files == OPEN_MAX) {

printf(\打开文件数目达到上限!无法再打开新文件.\\n\ return 0; }

//确保当前目录下有该文件,并且记录下它的FCB下标

struct dirFile *dir; //当前目录的指针

if(current==2)

dir=&(osPoint->root); else

dir=(struct dirFile *)(osPoint->data [current-3]);

for(i = 1;i< BlockFcbCount;i++) { //查找该文件

if(dir->fcb[i].type==GENERAL && strcmp(dir->fcb[i].fname,file)==0 ) {

FcbIndex=i; break; } }

if(i==BlockFcbCount) {

printf(\当前目录下不存在该文件!\\n\ return 0; }

//装载新文件进入打开文件列表,(FCB信息,文件数++) ??难道名字过不来? openlist->f[OpenFileCount] = dir->fcb[FcbIndex]; //FCB拷贝 openlist->files ++; printf(\文件打开成功!\\n\ OpenFileCount++; return 1; }

int close(char *file)

{

//释放该文件所占内存 //释放用户打开文件列表表项 int i;

//在打开文件列表中查找 file(还需要考虑同名不同目录文件的情况!!!) for(i=0;i

if((openlist->f [i].type = GENERAL)&&

(strcmp(openlist->f [i].fname,file)==0)) {

if(openlist->f[i].fatherBlockNum == current) { break; } else {

printf(\该文件已打开,但未在当前目录下,无法关闭!\\n\ return 0; } } }

if(i==OPEN_MAX) {

printf(\该文件未在打开列表

中!\\n\ return 0; }

int active=i; openlist->files --;

openlist->f[active].initialize(); OpenFileCount--; printf(\该文件已关闭!\\n\ return 1; } void main() {

/*********************************************************************/ printf(\我的文件系统

************************* \\n\

printf(\ :安全退出 \\n\

printf(\创建目录. \\n\

printf(\删除目录. \\n\

printf(\ dirname :显示当前目录下信息. \\n\

printf(\创建一个新文件,并且打开. \\n\

printf(\选择一个打开的文件写入信息 \\n\

printf(\ filename :选择一个打开的文件读取信息. \\n\

printf(\-----------------\\n\\n\

printf(\ filename :删除文件. while(1){ \\n\

cout<

printf(\ filename :打开文件. \\n\

printf(\关闭文件. \\n\

//创建用户文件打开表 openlist=new OPENLIST; //申请虚拟空间并且初始化 BaseAddr=(char *)malloc(DiskSize); //虚拟磁盘初始化

osPoint=(struct DISK *)(BaseAddr); //加载磁盘文件

if((fp=fopen(FilePath,\

fread(BaseAddr,sizeof(char),DiskSize,fp); printf(\加载磁盘文件( %s )成功,现 在可以进行操作了!\\n\\n\ }

else{

printf(\这是你第一次使用该文件 管理系统!\\t正在初始化...\\n\ format();

printf(\初始化已经完成,现在可以 进行操作了!\\n\\n\ }

cin>>cmd; if(cmd==\

cin>>command; mkdir(command); }

else if(cmd==\ cin>>command; rmdir(command); }

else if(cmd==\ listshow(); }

else if(cmd==\ cin>>command; create(command); } else if(cmd==\ cin>>command; write(command); }

else if(cmd==\ cin>>command; read(command);

}

else if(cmd==\ cin>>command; delfile(command); }

else if(cmd==\ cin>>command; open(command); }

else if(cmd==\ cin>>command; close(command);

}

else if(cmd==\ exit(); break; }

else cout<<\无效指令,请重新输入:\ }

printf(\system!\\n\ }

【实验截图】

这是刚打开时的界面

搜索更多关于: 操作系统实验报告模板 的文档
操作系统实验报告模板.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c04af51rmet9bpag88o2p_5.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top