文件管理系统文档格式.docx

上传人:b****6 文档编号:18869749 上传时间:2023-01-01 格式:DOCX 页数:25 大小:76.95KB
下载 相关 举报
文件管理系统文档格式.docx_第1页
第1页 / 共25页
文件管理系统文档格式.docx_第2页
第2页 / 共25页
文件管理系统文档格式.docx_第3页
第3页 / 共25页
文件管理系统文档格式.docx_第4页
第4页 / 共25页
文件管理系统文档格式.docx_第5页
第5页 / 共25页
点击查看更多>>
下载资源
资源描述

文件管理系统文档格式.docx

《文件管理系统文档格式.docx》由会员分享,可在线阅读,更多相关《文件管理系统文档格式.docx(25页珍藏版)》请在冰豆网上搜索。

文件管理系统文档格式.docx

删除文件:

delete<文件名>,当没在用户使用指定文件时,将其删除。

文件不存在时给出错误信息。

显示目录:

dir<目录名>,显示指定目录下的全部文件和第一级子目录,如果没有指定目录名,则显示当前目录下的相应内容。

创建目录:

create<目录名>,在指定路径下创建指定的目录,如没有指定路径,则在当前目录下创建指定的目录。

对于重名目录给出错误信息。

删除目录:

delete<目录名>,删除指定目录及其下的全部文件和子目录。

如果指定目录为空,可直接删除,否则给出用户提示是否删除。

关闭目录:

close<目录名>,关闭指定目录及其下的全部文件和子目录。

打开目录:

open<目录名>,打开指定目录。

重命名:

renameXXXYYY重命名指定目录

其他说明:

<目录名>和<文件名>都支持全路径名和相对路径名。

文件名由目录结构中各级文件名分量排列构成,各分量间用“/”隔开。

输入exit命令可退出此模拟文件管理系统。

3功能模块(或算法)描述

//显示时间

voidshow_time(SYSTEMTIME&

sys)

//显示当前目录中的所有文件和文件夹

voiddir(vector<

FCB>

&

a)

//登陆信息

intlogin()

//在当前目录中创建文件或文件夹

voidcreate(vector<

*&

a)

//在当前目录中删除文件或文件夹

voiddel(vector<

//关闭当前目录中的文件

voidclose(vector<

//显示出错信息

voiderror()

//判断当前目录中指定名称的文件是否存在

boolfind_file(vector<

a,string&

filename)

//判断当前目录中指定名称的文件夹是否存在

boolfind_file_server(vector<

filename)

//给当前目录中的文件或文件夹重命名

voidrename(vector<

//打开当前目录中的文件

voidopen(vector<

a)4程序运行结果

5心得体会

实验中主要问题及故障现象的分析及设计结论:

结构体的设计和运用很不熟练,结构体数组的运用,结构体的每个元素都是独立的一个

模块,但都统一被结构体变量所调用,结构体数组是一个逻辑数组。

编程体会和心得:

一个程序要有灵感,但这个灵感是你在前一百个想法都失败的情况下的第一百零一个想法,如果有了灵感就不要停下来尽可能的都花时间来写程序,这样慢慢你的灵感就会越来越多。

附源代码

#include<

iostream>

string>

vector>

new>

#include<

windows.h>

stdio.h>

#definePASSWD"

admin"

usingnamespacestd;

typedefstructFCB

{

stringFileName;

//文件名

stringFileType;

//文件类型

vector<

*subdirectory;

//下一级目录地址

*updirectory;

//上一级目录地址

stringparent;

//父文件夹名

SYSTEMTIMEcreating_time;

//创建时间

SYSTEMTIMElast_modified_time;

//最近访问时间

stringstatus;

//文件状态

}FCB;

cout<

<

sys.wYear<

"

/"

<

sys.wMonth<

sys.wDay<

sys.wHour<

:

"

sys.wMinute<

sys.wSecond;

}

intlength=a.size();

inti=0;

for(i=1;

i<

length;

i++)

{

cout<

a[i].FileName;

if(a[i].FileType!

="

{

cout<

."

a[i].FileType<

;

创建时间:

show_time(a[i].creating_time);

最近访问时间:

show_time(a[i].last_modified_time);

状态:

a[i].status<

endl;

}

else

创建时间:

}

{

intnumber=0;

//ceshi

charpwd[32];

inti=0;

while(i++<

3){

printf("

*********************************************************\n"

);

请输入文件系统访问密码:

scanf("

%s"

pwd);

if(strcmp(pwd,PASSWD)==0){

number=1;

登陆成功欢迎访问!

\n"

break;

}

if(i==4){

Sorry!

returnnumber;

//

//显示帮助信息

voidhelp()

{system("

cls"

printf("

文件管理系统\n"

指导老师:

文志诚\n"

本组组员,梁植程,吴楠,刘佳乐,何侃,陈周,毛伟\n"

dir"

显示当前目录中的所有文件和文件夹"

help"

显示帮助信息"

命令+?

显示该命令的说明文档,如:

dir?

createxxx"

在当前目录中创建文件xxx.yyy或文件夹xxx"

deletexxx"

在当前目录中删除文件xxx.yyy或文件夹xxx"

openxxx"

打开当前目录中的文件xxx.yyy或文件夹xxx"

closexxx"

关闭当前目录中的文件xxx.yyy或文件夹xxx"

cd/"

返回到上一级目录"

cdxxx"

转到当前目录的xxx子目录"

cdroot"

转到根目录root"

renamexxxyyy"

重命名"

exit"

退出"

//判断是否是帮助请求命令

boolis_require(string&

str)

return(str[str.length()-1]=='

?

'

//显示命令的说明

voidcommand_explan(string&

command)

if(command=="

)cout<

\"

dir\"

命令用于显示当前目录中的所有文件和文件夹"

elseif(command=="

help?

help\"

命令用于显示帮助信息"

create?

create\"

命令用于在当前目录中创建文件或文件夹,如:

createhello.txt,createhello,注意:

创建文件必须有扩展名,无扩展名则认为是文件夹,文件和文件不能同名,文件夹和文件夹不能同名,文件和文件夹可以同名"

delete?

delete\"

命令用于在当前目录中删除文件或文件夹,如:

deletehello.txt,deletehello"

open?

open\"

命令用于在当前目录中打开文件或文件夹,如:

openhello.txt,openhello"

close?

close\"

命令用于在当前目录中关闭文件或文件夹,如:

closehello.txt,closehello"

cd?

cd\"

命令用于跳转目录,如:

cdhello,\"

cd/\"

用于跳转到当前目录的上一级目录,\"

cdroot\"

用于直接转到根目录"

rename?

rename\"

命令用于给当前目录中的文件或文件夹重命名,如:

renamehello.txthi.cpp(可以修改扩展名),renamehello.txthi(不加扩展名则默认为原扩展名),renamehellohi(修改文件夹名)"

exit?

exit\"

命令用于退出系统"

elsecout<

nosuchcommand!

stringfile="

name="

type="

FCBfcb,fcb2;

intlength=0,i=0;

intsize=(*a).size();

cin>

>

file;

length=file.length();

for(i=0;

if(file[i]=='

.'

)break;

if(i<

length-1)

name=file.substr(0,i);

type=file.substr(i+1,length-i-1);

for(i=1;

size;

if((*a)[i].FileName==name&

(*a)[i].FileType!

{

cout<

Thefilenamehasbeenexisted!

return;

}

fcb.FileName=name;

fcb.FileType=type;

fcb.subdirectory=NULL;

fcb.updirectory=NULL;

fcb.parent="

GetLocalTime(&

fcb.creating_time);

fcb.last_modified_time);

fcb.status="

closed"

(*a).push_back(fcb);

else

(*a)[i].FileType=="

vector<

*sub_dir=newvector<

();

fcb2.FileName="

fcb2.FileType="

fcb2.subdirectory=NULL;

fcb2.updirectory=a;

fcb2.parent=name;

fcb2.creating_time);

fcb2.last_modified_time);

fcb2.status="

fcb.FileType="

fcb.subdirectory=sub_dir;

(*sub_dir).push_back(fcb2);

filename="

filetype="

file;

intlength=file.length();

intsize=a.size();

filename=file.substr(0,i);

filetype=file.substr(i+1,length-i-1);

if(a[i].FileName==filename&

a[i].FileType!

if(a[i].FileType==filetype)

{

a.erase(&

a[i]);

cout<

filename<

filetype<

isdeleted."

}

elsecout<

nosuchfile"

if(i==size)cout<

elseif(i==length)

if(a[i].FileName==file&

a[i].FileType=="

a.erase(&

file<

if(a[i].status=="

{

a[i].status="

opened"

GetLocalTime(&

a[i].last_modified_time);

cout<

a[i].FileName<

isopened."

return;

}

else

hasalreadybeenopened."

return;

if(a[i].status=="

a[i].status="

GetLocalTime(&

return;

else

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 小学教育 > 其它课程

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

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