2022年文件系统模拟设计c++ 2.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年文件系统模拟设计c++ 2.pdf》由会员分享,可在线阅读,更多相关《2022年文件系统模拟设计c++ 2.pdf(11页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、#include stdio.h #include iostream.h #include string.h #include iomanip.h #define FILENAME_LENGTH 10 /文件名称长度#define COMMAND_LENGTH 10 /命令行长度#define PARA_LENGTH 30 /参数长度/账号结构typedef struct users char name8; char pwd10; users; /文件结构struct fnode char filenameFILENAME_LENGTH; int isdir; int isopen; char
2、 content255; /我是目录 /我是文件fnode *parent; fnode *child; fnode *prev; fnode *next; ; /账号users usrarray8 = usr1,usr1, usr2,usr2, usr3,usr3, usr4,usr4, usr5,usr5, usr6,usr6, usr7,usr7, usr8,usr8, ; fnode *initfile(char filename,int isdir); void createroot(); 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - -
3、- - - - - 名师精心整理 - - - - - - - 第 1 页,共 11 页 - - - - - - - - - int run(); int findpara(char *topara); bool chklogin(char *users, char *pwd); void help(); int mkdir(); int create(); int read(); int write(); int del(); int cd(); int dir(); fnode *root,*recent,*temp,*ttemp; char paraPARA_LENGTH,commandC
4、OMMAND_LENGTH,tempparaPARA_LENGTH,recentparaPARA_LENGTH; /创建文件与目录结点fnode* initfile(char filename,int isdir) fnode *node=new fnode; strcpy(node-filename,filename); node-isdir=isdir; node-isopen=0; node-parent=NULL; node-child=NULL; node-prev=NULL; node-next=NULL; return node; /创建文件存储结点void createroot
5、 () recent=root=initfile(/,1); root-parent=NULL; root-child=NULL; root-prev=root-next=NULL; strcpy(para,/); int mkdir() temp=initfile( ,1); cintemp-filename; if(recent-child=NULL) 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 2 页,共 11 页 - - - - - - - - - temp-parent
6、=recent; temp-child=NULL; recent-child=temp; temp-prev=temp-next=NULL; else ttemp=recent-child; while(ttemp-next) ttemp=ttemp-next; if(strcmp(ttemp-filename,temp-filename)=0&ttemp-isdir=1) printf( 对不起 ,目录已存在 !); return 1; ttemp-next=temp; temp-parent=NULL; temp-child=NULL; temp-prev=ttemp; temp-next
7、=NULL; return 1; int create() temp=initfile( ,0); cintemp-filename; cintemp-content; if(recent-child=NULL) temp-parent=recent; temp-child=NULL; recent-child=temp; temp-prev=temp-next=NULL; cout 文件建立成功!child; 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 3 页,共 11 页 -
8、 - - - - - - - - while(ttemp-next) ttemp=ttemp-next; if(strcmp(ttemp-filename,temp-filename)=0&ttemp-isdir=0) printf( 对不起 ,文件已存在 !); return 1; ttemp-next=temp; temp-parent=NULL; temp-child=NULL; temp-prev=ttemp; temp-next=NULL; cout 文件建立成功!endl; return 1; int dir() int i=0,j=0; temp=new fnode; temp=
9、recent; if(temp!=root) cout .child=NULL) coutTotal: directors i files j child; while(temp) if(temp-isdir) cout filenameendl;i+; else cout filenamenext; coutTotal: directors i files j filename; if(recent-child=NULL) cout 文件不存在 !child-filename,filename)=0) coutchild-contentchild; while(temp-next) if(s
10、trcmp(temp-next-filename,filename)=0) coutnext-contentendl; return 1; cout 文件不存在 !filename; if(recent-child=NULL) cout 文件不存在 !child-filename,filename)=0) 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 5 页,共 11 页 - - - - - - - - - recent-child-isopen=1;/ 设置文件标记为打开cinr
11、ecent-child-content; recent-child-isopen=0;/ 设置文件标记为关闭cout 文件写入成功!child; while(temp-next) if(strcmp(temp-next-filename,filename)=0) recent-child-isopen=1;/ 设置文件标记为打开cintemp-next-content; recent-child-isopen=0;/ 设置文件标记为关闭cout 文件写入成功!endl; return 1; cout 文件不存在 !topara; if(strcmp(topara,.)=0) int i; wh
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 2022年文件系统模拟设计c+ 2022 文件系统 模拟 设计 c+
![提示](https://www.taowenge.com/images/bang_tan.gif)
限制150内