C语言文件系统设计(源代码+论文).rar

您所在的位置:网站首页 文件系统设计题 C语言文件系统设计(源代码+论文).rar

C语言文件系统设计(源代码+论文).rar

2023-06-01 06:08| 来源: 网络整理| 查看: 265

文件系统设计

①下列几条命令LOGIN 用户登陆DIR 列文件目录CREATE 创建文件DELETE 删除文件OPEN 打开文件CLOSE 关闭文件READ 读文件WRITE 写文件②列目录时要列出文件名,物理地址,保护码和文件长度。③源文件可以进行读写保护。①首先应确定文件系统的数据结构:主目录、子目录及活动文件等。主目录和子目录都以文件的形式存放于磁盘,这样便于查找和修改。②用户创建的文件,可以编号存储于磁盘上。如:file0,file1,file2…并以编号作为物理地址,在目录中进行登记。程序见下(本程序需要在c:下建一个名为osfile的目录及一个名为file的子目录):#include ""#include ""#include ""#include ""#define MAXNAME 25 /*the largest length of mfdname,ufdname,filename*/#define MAXCHILD 50 /*the largest child*/#define MAX (MAXCHILD*MAXCHILD) /*the size of fpaddrno*/typedef struct /*the structure of OSFILE*/ {int fpaddr; /*file physical address*/ int flength; /*file length*/ int fmode; /*file mode:0-Read Only;1-Write Only;2-Read and Write(default);*/ char fname[MAXNAME]; /*file name*/ } OSFILE;typedef struct /*the structure of OSUFD*/ {char ufdname[MAXNAME]; /*ufd name*/ OSFILE ufdfile[MAXCHILD]; /*ufd own file*/ }OSUFD;typedef struct /*the structure of OSUFD'LOGIN*/ {char ufdname[MAXNAME]; /*ufd name*/ char ufdpword[8]; /*ufd password*/ } OSUFD_LOGIN;typedef struct /*file open mode*/ {int ifopen; /*ifopen:0-close,1-open*/ int openmode; /*0-read only,1-write only,2-read and write,3-initial*/ }OSUFD_OPENMODE;OSUFD *ufd[MAXCHILD]; /*ufd and ufd own files*/OSUFD_LOGIN ufd_lp;int ucount=0; /*the count of mfd's ufds*/int fcount[MAXCHILD]; /*the count of ufd's files*/int loginsuc=0; /*whether login essfully*/char username[MAXNAME]; /*record login user's name22*/char dirname[MAXNAME];/*record current directory*/int fpaddrno[MAX]; /*record file physical address num*/OSUFD_OPENMODE ifopen[MAXCHILD][MAXCHILD]; /*record file open/close*/int wgetchar; /*whether getchar()*/FILE *fp_mfd,*fp_ufd,*fp_file_p,*fp_file;void main(){int i,j,choice1; char choice[50]; /*choice operation:dir,create,delete,open,delete,modify,read,write*/ int choiceend=1; /*whether choice end*/ char *rtrim(char *str); /*remove the t



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3