基于Linux的模拟文件系统的设计与实现(3)

2019-03-28 15:36

{

last=user->conHead; while(last->next!=NULL) last=last->next; last->next=add; }

user->c_num++;

add->fileHead=NULL; add->f_num=0;

//fulfill the new folder name char name[10]; Content *check;

char buffer[2];

fgets(buffer,2,stdin);

con_r:printf(\create a new folder:\\nfolder name(9,only alphabet and number can be used):\\n\scanf(\

check=user->conHead; while(check!=add) {

if(strcmp(name,check->name)==0) {

printf(\goto con_r; }

check=check->next; }

//check legality of the name int i=0;

for(;i<=9;i++) {

if(name[i]>=97&&name[i]<=122)//lower continue; else

if(name[i]>=48&&name[i]<=57)//num continue; else

10

if(name[i]>=65&&name[i]<=90)//upper continue; else

if(name[i]=='\\0') break; else {

printf(\goto con_r; } }

strcpy(add->name,name);

printf(\return; }

//step1

void FolderDelete() {

if(cur_user->conHead==NULL) {

printf(\return; }

Content *front,*current;

char name[10];

printf(\con_d:printf(\scanf(\

if(name[0]=='#') return;

//seek folder name

current=cur_user->conHead; while(current!=NULL) {

if(!strcmp(current->name,name)) break; else

11

current=current->next; }

if(current==NULL) {

printf(\goto con_d; }

//if has any files

while(current->fileHead!=NULL) {

char buffer[2];

fgets(buffer,2,stdin);

printf(\char judge;

scanf(\

if(judge=='n'||judge=='y'||judge=='N'||judge=='Y') if(judge=='n'||judge=='N') return; else break; else {

printf(\continue; } }

//user recognise char psw[10];

printf(\char buffer[2];

fgets(buffer,2,stdin); fgets(psw,10,stdin);

if(strcmp(cur_user->psw,psw)!=0) {

printf(\return; }

12

//execute delete operation front=cur_user->conHead; if(front==current) //if curren is the head file {

cur_user->conHead=current->next; free(current);

printf(\return; }

while(front->next!=current) front=front->next;

front->next=current->next; free(current); cur_user->c_num--;

printf(\return; }

//step1

void FolderViewAllFiles() {

printf(\

Content *con;

con=cur_user->conHead; int fi_num=0;

while(con!=NULL) {

printf(\%s-----------------\\n\

File *fi;

fi=con->fileHead; while(fi!=NULL) {

printf(\| %s\\n\

13

printf(\| |\\n\fi=fi->next; }

fi_num+=con->f_num; con=con->next; }

printf(\return; }

//step1

void FolderIntoFolder() {

void MenuFolder();

if(cur_user->conHead==NULL) {

printf(\return; }

printf(\char name[10];

char buffer[2];

fgets(buffer,2,stdin);

Content *check;

printf(\con_g:printf(\scanf(\

if(name[0]=='#') return;

check=cur_user->conHead; while(check!=NULL) {

14


基于Linux的模拟文件系统的设计与实现(3).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:2018年高考数学一轮复习第十一章计数原理、概率、随机变量及其分

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: