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

加入VIP,免费下载
 

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

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

下载须知

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

版权提示 | 免责声明

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

文件管理系统源代码.docx

1、文件管理系统源代码文件管理系统一、实验目的通过设计一个多用户文件系统, 了解操作系统中文件的组织与管理, 熟悉文件管理所用 的数据结构,加深对文件系统内部功能实现过程的理解。二、实验内容1用 C 语言或 C+ 语言设计一个最多包括 N 个用户的多用户文件系统, 约定每个用户 最多保存 M 个文件。同时限制一个用户在进入系统后,最多打开 L 个文件。2系统应具备一定的健壮性。即能够检查用户所输入命令的正确性,出错时显示出必 要的信息。另外,对文件需设置必要的保护措施。3文件目录结构采用两级目录结构 : 主文件目录和用户文件目录/* 用户数 */* 一个用户可保存 M 个文件 */ /*用户只能一

2、次打开 L 个文件 */ /* 主文件目录 */#includeio.h #includeconio.h #includestdio.h #includestdlib.h #includemalloc.h #includestring.h #includectype.h #define N 30 #define M 20 #define L 5 typedef struct MFD char username100;char password100;FILE fp; /*文件指针 */MFD;/typedef struct UFD /* 用户文件目录 */ char filename256;c

3、har protect; /* 保护码 */int length; /* 文件长度 */ UFD;/* 打开文件目录 */ typedef struct OFDchar filename256;char opencode; /* 打开保护码 */ int fp; /* 读写指针 */OFD;/ typedef struct COMM /* 命令串 */char string256; /* 命令 */struct COMM *next;/* 后继指针 */ COMM;/* 主文件目录数组 */* 用户文件目录数组 */* 打开文件目录数组 */* 命令串指针 */MFD mainfdN;UFD

4、userfdM;OFD openfdL;/ COMM*command; char username10;int usernum,savenum,opennum; int workfile;void init();void init_ufd(char *username);/* void mesg(char *str);char *getpass();char *getuser();COMM *readcommand();void login();void logout();void setpass();void create();void mydelete();void myread();vo

5、id myopen();void myclose();void mywrite();void help();void dir();void mycopy();void myrename();/初始化用户文件目录 */ /*消息 */* 设置口令函数声明 */* 设置用户函数声明 */* 读命令串函数声明 */* 用户登录 */* 用户注销 */* 设置口令 */* 创建文件 */* 删除文件 */* 读文件 */* 打开文件 */* 关闭文件 */* 写文件 */*帮助 */* 列文件目录 */* 复制文件 */* 重命名文件名 */void main()init();for(;)readco

6、mmand();if(strcmp(command-string,create)=0)create();else if(strcmp(command-string,delete)=0)mydelete();else if(strcmp(command-string,open)=0) myopen();else if(strcmp(command-string,close)=0) myclose();else if(strcmp(command-string,read)=0) myread();else if(strcmp(command-string,write)=0) mywrite();e

7、lse if(strcmp(command-string,copy)=0) mycopy();else if(strcmp(command-string,rename)=0) myrename();else if(strcmp(command-string,login)=0) login();else if(strcmp(command-string,setpass)=0) setpass();else if(strcmp(command-string,logout)=0) logout();else if(strcmp(command-string,help)=0) help();else

8、if(strcmp(command-string,dir)=0) dir();else if(strcmp(command-string,exit)=0) break;elsemesg(Bad command!);/void init()FILE *fp;char tempname20,temppass20;int i=0;usernum=0;savenum=0;opennum=0;strcpy(username,); if(fp=fopen(mainfile.txt,r)!=NULL) while(!feof(fp)strcpy(tempname,);fgets(tempname,20,fp

9、);if(strcmp(tempname,)!=0)fgets(temppass,20,fp); tempnamestrlen(tempname)-1=0; temppassstrlen(tempname)-1=0; strcpy(mainfdusernum.username,tempname); strcpy(mainfdusernum.password,tempname); usernum+;fclose(fp);/void init_ufd(char *username)/* 初始化用户文件目录 */FILE *fp;char tempfile100,tempprot;int templ

10、ength;savenum=0;opennum=0;workfile=-1;if(fp=fopen(username,w+)!=NULL)while(!feof(fp)strcpy(tempfile,);fgets(tempfile,50,fp);if(strcmp(tempfile,)!=0)fscanf(fp,%c,&tempprot); fscanf(fp,%d,&templength); tempfilestrlen(tempfile)-1=0; strcpy(userfdsavenum.filename,tempfile); userfdsavenum.protect=temppro

11、t; userfdsavenum.length=templength; savenum+;fgets(tempfile,50,fp);fclose(fp);/void mesg(char *str)printf(n %sn,str);/char *getuser()char username20;char temp;int i;username0=0;for(i=0;i10;)while(!kbhit();temp=getch();if(isalnum(temp)|temp=_|temp=13) usernamei=temp; if(usernamei=13)usernamei=0; brea

12、k;putchar(temp);i+;usernamei=0;return(username);/char *getpass()char password20;char temp;int i;password0=0;for(i=0;i);gets(line);for(i=0;i0)tempend=0;newp=(COMM *)malloc(sizeof(COMM *);strcpy(newp-string,temp);newp-next=NULL;if(command=NULL) command=newp;elsep=command;while(p-next!=NULL) p=p-next;p

13、-next=newp; p=command;return(command);/void login() /* 用户注册 */FILE *fp;int i;char password20,confirm20,tempname20; if(command-next=NULL)printf(n User Name:); strcpy(tempname,getuser();else if(command-next-next!=NULL)mesg(Too many parameters!);return;else strcpy(tempname,command-next-string);for(i=0;

14、i=usernum) /* 新用户 */printf(n new user account,enter your password twice!); printf(n Password:);strcpy(password,getpass();/* 输入口令且返回之 */ printf(n Password:);strcpy(confirm,getpass(); /* 第二次输入口令 */ if(strcmp(password,confirm)=0)/* 用户数不能超过 N*/ if(usernum=N)mesg(Create new account false!number of user a

15、sscount limited.n login fasle!);elsestrcpy(mainfdusernum.username,tempname);/* 把新用户和口令填入 mainfd 中 */strcpy(mainfdusernum.password,password); usernum+;strcpy(username,tempname);mesg(Create a new user!n login success!);init_ufd(username); /* 初始化用户文件目录 */fp=fopen(mainfile.txt,w+); /* 把新用户填入 mainfile.tx

16、t 文件中 */for(i=0;inext!=NULL)mesg(Too many parameters!);else if(strcmp(username,)=0)mesg(No user login!);else strcpy(username,); opennum=0; savenum=0; workfile=-1; mesg(User logout!);/void setpass() /* 修改口令 */int i=0;FILE *fp;char oldpass20,newpass20,confirm20; if(strcmp(username,)=0) mesg(No user lo

17、gin!);else printf(n Old password:); strcpy(oldpass,getpass(); for(int i=0;iusernum;i+) if(strcmp(mainfdi.username,username)=0) break; if(strcmp(mainfdi.password,oldpass)!=0) mesg(Old password error!);elseprintf(n New password:); strcpy(newpass,getpass(); printf(n Confirm password:);strcpy(confirm,ge

18、tpass(); if(strcmp(newpass,confirm)!=0)mesg(Password not change! confirm different.);else strcpy(mainfdi.password,newpass); mesg( Password change !);fp=fopen(mainfile.txt,w+); for(i=0;inext=NULL) mesg(Too few parametets!);else if(command-next-next!=NULL)mesg(Too many parameters!);elsefor(i=0;inext-s

19、tring)=0) break;if(i=M)mesg(Error! connot create file! number of files limited!); elsestrcpy(userfdsavenum.filename,command-next-string); userfdi.protect=r;userfdi.length=rand();savenum+; mesg(Create file success!); fp=fopen(username,w+); for(i=0;inext=NULL) mesg(Too few parametets!);else if(command

20、-next-next!=NULL) mesg(Too many parameters!);else for(i=0;inext-string)=0) break;if(i=savenum)mesg(Error! the file not existed!); else tempsave=i; for(i=0;inext-string,openfdi.filename)=0) break; if(i=opennum) mesg(File not open);/else if(tempsave=savenum-1) savenum-;else for(;tempsavesavenum-1;temp

21、save+) strcpy(userfdtempsave.filename,userfdtempsave+1.filename); userfdtempsave.protect=userfdtempsave+1.protect; userfdtempsave.length=userfdtempsave+1.length;savenum-; mesg(Delete file success!); fp=fopen(username,w+);for(i=0;inext=NULL)mesg(Too few parametets!);else if(command-next-next!=NULL)mesg(Too many parameters!);elsestrcpy(tempfile,command-next-string); for(i=0;isavenum;i+) if(strcmp(tempfile,userfdi.filename)=0)

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

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