91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

通過模擬文件系統的實現,深入理解操作系統中文件系統的理論知識, 加深對教材中的重要算法的理解。同時通過編程實現這些算法,更好地掌握操作系統的原理及實現方法,提高綜合運用各專業課知識的能力。 本文件系統采用多級目錄,其中第一級對應于用戶賬號,第二級對應于用戶賬號下的文件,第三級對應文件夾下的文件,以此類推。另外,為了簡單本文件系統未考慮文件共享、文件系統安全以及管道文件與設備文件等特殊內容。

資源截圖

代碼片段和文件信息


#include“FSMain.h“
//新建用戶
bool?createuser()
{
struct?user?newuser;
char?name[10];
char?pass[10];
int?pride;
if(usernowpride!=1)
{
cout<<“當前用戶沒有新建用戶的權限\n“;
return?false;
}
FILE?*fp;
if((fp?=?fopen(“user““ab+“))==NULL)
{
cout<<“用戶表打開失敗\n“;
return?false;
}
else
{
cout<<“請輸入用戶名:“;
cin>>name;
if(strcmp(name“root“)==0)
{
printf(“Error:此為超級管理員\n“);
return?false;
}
rewind(fp);
while(!feof(fp))
{
fread(&newusersizeof(struct?user)1fp);
if(strcmp(newuser.namename)==0)
{
cout<<“該用戶名已經存在\n“;
fclose(fp);
return?false;
}
}
cout<<“請輸入用戶密碼:“;
cin>>pass;
cout<<“請輸入用戶權限(0普通用戶,1管理員):“;
cin>>pride;
strcpy(newuser.namename);
strcpy(newuser.passpass);
newuser.pride=pride;

// FILE?fpuser;//為新建用戶建立用戶目錄文件
if(!fopen(newuser.name“ab+“))
{
cout<<“用戶創建失敗\n“;
//如創建失敗則把已經建立的用戶目錄刪除
char?cmd[20]?=?“DEL?“;
strcat(cmdnewuser.name);
system(cmd);
fclose(fp);
return?false;
}
if(!fwrite(&newusersizeof(struct?user)1fp))
{
cout<<“創建失敗\n“;
fclose(fp);
return?false;
}
else
{

cout<<“用戶創建成功\n“;
fclose(fp);
return?true;
}
}
}

//用戶登陸
bool?login()
{
char?name[10];
char?pass[10];
cout<<“\n\t\t\t○用戶名:“;
cin>>name;
cout<<“\t\t\t○密??碼:“;
cin>>pass;
if((strcmp(“root“name)==0)&&(strcmp(“123456“pass)==0))//管理員
{
usernowpride?=?1;
strcpy(usernowname“root“);
return?true;
}

FILE?*fp=NULL;
struct?user?actuser;
if(!(fp=fopen(“user““ab+“)))
{
cout<<“Error:用戶表錯誤\n“;
return?false;
}
rewind(fp);
while(!feof(fp))
{
fread(&actusersizeof(struct?user)1fp);
if((strcmp(actuser.namename)==0)&&(strcmp(actuser.passpass)==0))
{
usernowpride?=?actuser.pride;//記錄當前用戶的權限
strcpy(usernownameactuser.name);//記錄當前用戶的主路徑
nowlevel=-1;//記錄當前目錄層次
fclose(fp);
//設置路徑
if(strcmp(usernowpath“\\“)!=0) //不是根目錄就添加斜杠
{
strcat(usernowpath“\\“);
}
strcat(usernowpathusernowname);
return?true;
}
}
cout<<“Error:用戶名或密碼無效,請核對后再輸入\n“;
fclose(fp);
return?false;
}

//初始化空閑區鏈表以及文件索引鏈
void?intlist()
{
//-----------------------------清空各鏈表
fidx=NULL;
fblk=NULL;
//-----------------------------
int?i=0;
struct?dreitem?dnow;
FILE?*fp;
if(!(fp=fopen(usernowname“rb“)))
{
cout<<“Error:打開用戶目錄失敗\n“;
return?;
}
else
{
int?enp;
int?sp;
fseek(fp02);
enp=ftell(fp);
fseek(fp00);
sp=ftell(fp);
if(sp==enp)?return;

while(!feof(fp))
{
fread(&dnowsizeof(struct?dreitem)1fp);
if(dnow.empty==0)
{
//把空閑區連到空閑鏈表中
struct?freeb?*fb?=getb(struct?freeb);
fb->number=i;
fb->next=NULL;
struct?freeb?*p=fblk;
if(p==NULL)
{
fblk=getb(struct?freeb);
fblk->next=fb;
}
else
{
while(p->next!=NULL)
{
p=p->next;
}
p->next=fb;
}
}
else
{
//

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2016-04-15?22:44??FileSystem\
?????目錄???????????0??2016-04-15?17:06??FileSystem\FileSystem_01\
?????文件?????????288??2016-04-15?16:04??FileSystem\FileSystem_01\1w
?????文件??????????96??2016-04-15?14:27??FileSystem\FileSystem_01\2w
?????目錄???????????0??2016-03-07?13:29??FileSystem\FileSystem_01\bin\
?????目錄???????????0??2016-04-01?14:11??FileSystem\FileSystem_01\bin\Debug\
?????文件?????1074748??2016-04-01?14:11??FileSystem\FileSystem_01\bin\Debug\FileSystem_01.exe
?????文件????????1157??2016-03-11?21:20??FileSystem\FileSystem_01\FileSystem_01.cbp
?????文件?????????367??2016-04-01?14:23??FileSystem\FileSystem_01\FileSystem_01.depend
?????文件????????1531??2016-04-15?17:06??FileSystem\FileSystem_01\FileSystem_01.layout
?????文件???????20364??2016-04-01?14:11??FileSystem\FileSystem_01\FSMain.cpp
?????文件????????1329??2016-03-11?16:55??FileSystem\FileSystem_01\FSMain.h
?????文件????????1016??2016-03-10?16:12??FileSystem\FileSystem_01\Login.cpp
?????目錄???????????0??2016-03-07?14:58??FileSystem\FileSystem_01\obj\
?????目錄???????????0??2016-04-01?14:11??FileSystem\FileSystem_01\obj\Debug\
?????文件???????35662??2016-04-01?14:11??FileSystem\FileSystem_01\obj\Debug\FSMain.o
?????文件???????17707??2016-03-10?16:35??FileSystem\FileSystem_01\obj\Debug\Login.o
?????文件??????????56??2016-04-15?14:26??FileSystem\FileSystem_01\user
?????文件??????640981??2016-04-15?17:04??FileSystem\操作系統課程設計(田慶?計133-2?201358503230?文件系統).docx

評論

共有 條評論