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

資源簡(jiǎn)介

廣東工業(yè)大學(xué) 操作系統(tǒng) 實(shí)驗(yàn)四 文件系統(tǒng)

一、實(shí)驗(yàn)?zāi)康?br /> 模擬文件系統(tǒng)實(shí)現(xiàn)的基本功能,了解文件系統(tǒng)的基本結(jié)構(gòu)和文件的各種管理方法,加深理解文件系統(tǒng)的內(nèi)部功能及內(nèi)部實(shí)現(xiàn)。通過(guò)用高級(jí)語(yǔ)言編寫(xiě)和調(diào)試一個(gè)簡(jiǎn)單的文件系統(tǒng),模擬文件管理的工作過(guò)程,從而對(duì)各種文件操作命令的實(shí)質(zhì)內(nèi)容和執(zhí)行過(guò)程有比較深入的了解。

二、實(shí)驗(yàn)內(nèi)容和要求
編程模擬一個(gè)簡(jiǎn)單的文件系統(tǒng),實(shí)現(xiàn)文件系統(tǒng)的管理和控制功能。要求本文件系統(tǒng)采用
兩級(jí)目錄,即設(shè)置主文件目錄[MFD]和用戶文件目錄[UED]。另外,為打開(kāi)文件設(shè)置運(yùn)行文件
目錄[AFD]。設(shè)計(jì)一個(gè)10個(gè)用戶的文件系統(tǒng),每次用戶可保存10個(gè)文件,一次運(yùn)行用戶可
以打開(kāi)5個(gè)文件,并對(duì)文件必須設(shè)置保護(hù)措施。在用戶程序中通過(guò)使用文件系統(tǒng)提供的Create、open、read、write、close、delete等文件命令,對(duì)文件進(jìn)行操作。
……
……
……

資源截圖

代碼片段和文件信息

#include
#include
#include
#include
using?namespace?std;

class?AFD; //類聲明
class?MFD;

//用戶文件目錄
class?UFD{
protected:
string?fname; //文件名
int?pcode; //保護(hù)碼
int?length; //文件長(zhǎng)度(AFD中為寫(xiě)指針)
public:
UFD?*next;

virtual?void?printfile();
UFD?*findfile1(string?fname);
string?getfname();
int?getpcode();
int?getlength();
void?addfile();
void?editfile(int?len); //更新文件長(zhǎng)度
void?createfile();
void?deletefile(AFD?*run);
void?openfile(AFD?*run);
void?bye(AFD?*run);
};


//運(yùn)行目錄文件
class?AFD:public?UFD{
private:
int?readp; //讀指針
public:
AFD?*next; //下一打開(kāi)文件

virtual?void?printfile();
AFD?*findfile2(string?fname);
int?getreadp();
void?addfile(AFD?*runstring?nameint?codeint?len); //添加打開(kāi)文件
void?editfile(int?wlenint?rlen); //更新讀寫(xiě)指針
void?readfile();
void?writefile();
void?closefile(UFD?*user);
};


//主文件目錄
//MFD帶頭結(jié)點(diǎn)
class?MFD{
public:
string?uname; //用戶名
UFD?*dir; //該用戶文件目錄指針
MFD?*next; //下一用戶

void?init(); //新建MFD初始化
UFD*?finduser(string?username); //搜索用戶
};

//初始化MFD內(nèi)容
void?MFD::init(){
uname=“\n“;
dir=NULL;
next=NULL;
MFD?*temp1=this;
UFD?*temp2;
int?usernum;
int?filenum;
cout<<“===========新建MFD===========“< cout<<“創(chuàng)建用戶數(shù):“;
cin>>usernum;
for(int?i=1;i<=usernum;i++){
temp1->next=new?MFD;
cout<<“\n第“< cin>>temp1->next->uname;

cout<<“用戶“<next->uname<<“文件數(shù):“;
cin>>filenum;
temp1->next->dir=new?UFD;
temp2=temp1->next->dir;
temp2->next=NULL;
for(int?j=0;j temp2->next=new?UFD;
temp2->next->addfile();
temp2=temp2->next;
}

temp1->next->next=NULL;
temp1=temp1->next;
}
}

//傳入用戶名
//在MFD查找用戶
//返回用戶UFD指針
UFD*?MFD::finduser(string?username){
MFD?*temp;
for(temp=next;temp;temp=temp->next){ //查找用戶
if(0==temp->uname.compare(username))return?temp->dir; //用戶名比較
}
return?NULL; //沒(méi)找到用戶
}

//------------------------------------------------------------------------------------
//增加UFD文件
//用于修改文件內(nèi)容
void?UFD::addfile(){
cout<<“創(chuàng)建文件名:“;
cin>>fname;getchar();
cout<<“文件“< for(cin>>pcode;pcode!=1&&pcode!=2&&pcode!=3;){
cout<<“重新輸入保護(hù)碼(1.讀?2.寫(xiě)?3.執(zhí)行):“;
cin>>pcode;
}
cout<<“文件“< for(cin>>length;cin.fail();){
cerr<<“長(zhǎng)度輸入錯(cuò)誤“< cin.clear();
cout<<“重新輸入文件“< }
next=NULL;
}

//創(chuàng)建UFD文件
void?UFD::createfile(){
UFD?*temp;
temp=new?UFD;
temp->addfile();
temp->next=next;
next=temp;
}

//查找用戶文件
//返回相應(yīng)文件前一指針
UFD*?UFD::findfile1(string?fname){
UFD?*temp1*temp2;
for(temp1=thistemp2=temp1->next;temp2;){
if(0==temp2->fname.compare(fname))break; //比較找到文件
temp1=temp2;
temp2=temp2->next;
}
if(!temp2)return?NULL; //沒(méi)找到
else?return?temp1; //找到返回前一指針
}

//傳入AFD
//查找并刪除要求文件
void?UFD::deletefile(AFD?*run){
string?name;
UFD?*delf*temp;
AFD?*delf2*temp2;
printfile();
cout<<“輸入要?jiǎng)h除文件名:“;
cin>>name;getchar()

?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----

?????文件???????5379??2010-11-20?10:24??8.png

?????文件??????10362??2010-11-20?10:25??9.png

?????文件??????11058??2010-11-20?10:27??10.png

?????文件???????8247??2010-11-20?10:28??11.png

?????文件???????2450??2010-11-20?10:29??12.png

?????文件???????5213??2010-11-20?10:30??13.png

?????文件???????9230??2010-11-20?11:16??文件系統(tǒng).cpp

?????文件?????577622??2010-12-14?19:09??文件系統(tǒng).exe

?????文件??????11508??2010-11-20?10:17??1.png

?????文件???????2178??2010-11-20?10:17??2.png

?????文件???????5084??2010-11-20?10:18??3.png

?????文件???????8185??2010-11-20?10:19??4.png

?????文件???????7386??2010-11-20?10:20??5.png

?????文件???????4548??2010-11-20?10:24??6.png

?????文件???????4490??2010-11-20?10:24??7.png

-----------?---------??----------?-----??----

???????????????672940????????????????????15


評(píng)論

共有 條評(píng)論

相關(guān)資源