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

資源簡介

這是一份操作系統(tǒng)的課程設(shè)計,是關(guān)于模擬一個文件管理系統(tǒng)的

資源截圖

代碼片段和文件信息

#include
#include
#include
#include

typedef?struct?mfd{
??char?username[14];///用戶名?14B
??char?password[14];?//?密碼14B
??int?ufd_id;??//該用戶的UFD所在的物理塊號(2B)
}MFD;

typedef?struct?ufd{
?char?filename[14];??//文件名14B;
?int?mode;??///文件權(quán)限0-readonly;1-writeonly;2-read/write
?int?length;?///文件長度(總塊數(shù))
?int?addr;//該文件的第1個文件塊對應(yīng)的物理塊號
}UFD;???

typedef?struct?uof{
?char?filename[14];??//文件名14B;
?int?mode;??///文件權(quán)限0-readonly;1-writeonly;2-read/write
?int?length;?///文件長度(總塊數(shù))
?int?addr;//該文件的第1個文件塊對應(yīng)的物理塊號
?int?state;//0-建立,1-打開
?int?readptr;
?int?writeptr;
}UOF;?

typedef?struct?disk{
int?id;
char?flag;//0-空閑,1-已分配
int?next;
}DISK;

MFD?mfdlist[16];
UFD?ufdlist[16];
UOF?uoflist[16];
DISK?disklist[99];
char?command[10]parameter1[14]parameter2[512];//用來存放命令和參數(shù)
MFD?cur_mfd;//當(dāng)前用戶的mfd
char?cur_user[14];//當(dāng)前用戶的用戶名
/*初始化函數(shù)——
從disk.txt中讀取mfd表的內(nèi)容
*/
initial_mfd()
{
ifstream?input_file;//創(chuàng)建輸入文件
ofstream?output_file;//創(chuàng)建輸出文件

char?name[14];
char?pass[14];
char?ch1ch2;
int?idtemp1temp2;
input_file.open(“disk.txt“ios::binary|ios::ate);//以二進(jìn)制“文件指針位于文件尾”的方式打開文件
if(!input_file){
cout<<“open?file?error!\n“;
return?1;
}
input_file.seekg(513ios::beg);//mfdlist存放在1#盤塊
for(int?k=0;k<16;k++)
{
for(int?i=0;i<14;i++)
{
input_file.get(name[i]);
if(name[i]==‘?‘)
{
name[i]=‘\0‘;
break;
}
}
input_file.seekg(13-iios::cur);
for(int?j=0;j<14;j++)
{
input_file.get(pass[j]);
if(pass[j]==‘?‘)
{
pass[j]=‘\0‘;
break;
}
}
input_file.seekg(13-jios::cur);

input_file.get(ch1);
input_file.get(ch2);
temp1=int(ch1)-48;//將字符轉(zhuǎn)為int
temp2=int(ch2)-48;
if(ch2!=‘?‘)
{
id=temp1*10+temp2;//十位數(shù)
}
else
{
id=temp1;//個位數(shù)
}
strcpy(mfdlist[k].usernamename);
strcpy(mfdlist[k].passwordpass);
mfdlist[k].ufd_id=id;

}
input_file.close();//關(guān)閉文件
return?0;
}
/*格式化硬盤-disk.txt
100個盤塊,每個盤塊大小是512字節(jié)數(shù)據(jù)+\n
并且第0#盤塊存放disklist,初始化disklist每一項的flag=0
next=0,id<=0~99*/
void?format(){
ofstream?output_file;//創(chuàng)建輸出文件
output_file.open(“disk.txt“ios::binary|ios::ate);//以二進(jìn)制“文件指針位于文件尾”的方式打開文件
output_file.seekp(0ios::beg);
for(int?j=0;j<100;j++)
{
for(int?i=0;i<512;i++)
{
output_file<<‘?‘;
}
output_file<<‘\n‘;
}
output_file.seekp(0ios::beg);
for(int?i=0;i<100;i++)
{
output_file< if(i<10)
{
output_file<<‘?‘;
}
output_file<<‘0‘;
output_file<<0;
output_file<<‘?‘;
}
output_file.close();
for(int?k=0;k<16;k++)
{
strcpy(mfdlist[k].username““);
strcpy(ufdlist[k].filename““);
}
cout<<“成功格式化系統(tǒng)!\n“;
}

/*找到一個空閑盤塊,返回它的盤塊號id*/
int?getdisk()
{
for(int?i=34;i<100;i++)
{
if(disklist[i].flag==‘0‘)
{
?????disklist[i].flag=‘1‘;
return?disklist[i].id;
}
}
return?0;
}

//從mfd中找user的條目
int?findmfd(char?user[]){
int?i=0;
while(strcmp(mfdlist[i].username““)!=0&&strcmp(mfdlist[i].

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件???????3399??2009-06-22?20:41??526813模擬一個文件管理系統(tǒng)\程序\all_sj.dsp

?????文件????????520??2009-06-22?20:41??526813模擬一個文件管理系統(tǒng)\程序\all_sj.dsw

?????文件????????798??2004-12-21?15:43??526813模擬一個文件管理系統(tǒng)\程序\all_sj.h

?????文件??????33792??2009-06-22?20:41??526813模擬一個文件管理系統(tǒng)\程序\all_sj.ncb

?????文件??????48640??2009-06-22?20:41??526813模擬一個文件管理系統(tǒng)\程序\all_sj.opt

?????文件????????246??2009-06-22?20:41??526813模擬一個文件管理系統(tǒng)\程序\all_sj.plg

?????文件??????51300??2009-06-30?02:14??526813模擬一個文件管理系統(tǒng)\程序\Debug\disk.txt

?????文件??????50176??2009-06-30?02:16??526813模擬一個文件管理系統(tǒng)\程序\Debug\vc60.idb

?????文件??????61440??2009-06-30?02:16??526813模擬一個文件管理系統(tǒng)\程序\Debug\vc60.pdb

?????文件?????241780??2009-06-30?02:16??526813模擬一個文件管理系統(tǒng)\程序\Debug\模擬文件系統(tǒng).exe

?????文件?????308132??2009-06-30?02:16??526813模擬一個文件管理系統(tǒng)\程序\Debug\模擬文件系統(tǒng).ilk

?????文件??????73809??2009-06-30?02:16??526813模擬一個文件管理系統(tǒng)\程序\Debug\模擬文件系統(tǒng).obj

?????文件?????291304??2009-06-30?02:16??526813模擬一個文件管理系統(tǒng)\程序\Debug\模擬文件系統(tǒng).pch

?????文件?????599040??2009-06-30?02:16??526813模擬一個文件管理系統(tǒng)\程序\Debug\模擬文件系統(tǒng).pdb

?????文件??????51300??2005-06-29?23:10??526813模擬一個文件管理系統(tǒng)\程序\disk.txt

?????文件??????22843??2009-06-30?02:16??526813模擬一個文件管理系統(tǒng)\程序\模擬文件系統(tǒng).cpp

?????文件???????3475??2009-06-30?02:16??526813模擬一個文件管理系統(tǒng)\程序\模擬文件系統(tǒng).dsp

?????文件????????532??2009-06-30?02:16??526813模擬一個文件管理系統(tǒng)\程序\模擬文件系統(tǒng).dsw

?????文件??????50176??2009-06-30?02:16??526813模擬一個文件管理系統(tǒng)\程序\模擬文件系統(tǒng).ncb

?????文件??????48640??2009-06-30?02:16??526813模擬一個文件管理系統(tǒng)\程序\模擬文件系統(tǒng).opt

?????文件????????778??2009-06-30?02:16??526813模擬一個文件管理系統(tǒng)\程序\模擬文件系統(tǒng).plg

?????目錄??????????0??2009-06-30?02:16??526813模擬一個文件管理系統(tǒng)\程序\Debug

?????目錄??????????0??2009-06-30?02:16??526813模擬一個文件管理系統(tǒng)\程序

?????目錄??????????0??2009-06-23?12:16??526813模擬一個文件管理系統(tǒng)

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

??????????????1942120????????????????????24


評論

共有 條評論

相關(guān)資源