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

  • 大小: 16KB
    文件類型: .zip
    金幣: 2
    下載: 0 次
    發(fā)布日期: 2021-06-14
  • 語言: 其他
  • 標(biāo)簽: 文件系統(tǒng)??

資源簡介

實(shí)驗(yàn)內(nèi)容: 通過對具體的文件存儲(chǔ)空間的管理、文件的物理結(jié)構(gòu)、目錄結(jié)構(gòu)和文件操作的實(shí)現(xiàn),加深對文件系統(tǒng)內(nèi)部功能和實(shí)現(xiàn)過程的理解。 要求: 1.在內(nèi)存中開辟一個(gè)虛擬磁盤空間作為文件存儲(chǔ)器,在其上實(shí)現(xiàn)一個(gè)簡單的單用戶文件系統(tǒng)。在退出這個(gè)簡單的文件系統(tǒng)時(shí),將該虛擬文件系統(tǒng)保存到磁盤上,以便下次再將它恢復(fù)到內(nèi)存的虛擬磁盤空間中。 2.提供以下操作: ?new:建立一個(gè)新的簡單文件系統(tǒng); ?sfs:打開一個(gè)簡單文件系統(tǒng); ?exit:退出打開的簡單文件系統(tǒng); ?mkdir:創(chuàng)建子目錄; ?rmdir:刪除子目錄; ?ls:顯示目錄; ?cd:更改當(dāng)前目錄; ?create:創(chuàng)建文件; ?open:打開文件; ?close:關(guān)閉文件; ?read:讀文件; ?write:寫文件; ?delete:刪除文件。

資源截圖

代碼片段和文件信息

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

#define?GENERAL?1//1代表普通文件2代表目錄文件0表示空文件
#define?DIRECTORY?2
#define?Zero?0

struct?FCB
{
char?fname[16];?//文件名
char?type;??//?0空文件??1目錄文件?2空文件???
int?size;????//文件大小
int?fatherBlockNum;????//當(dāng)前的父目錄盤塊號
int?currentBlockNum;????//當(dāng)前的盤塊

void?initialize()
{
strcpy(fname“\0“);
type?=?Zero;
size?=0;
fatherBlockNum?=?currentBlockNum?=?0;
}
};?

const?char*?FilePath?=?“C:\\myfiles“;/*常量設(shè)置*/
const?int?BlockSize?=?512;???????//盤塊大小
const?int?OPEN_MAX?=?5;??????????//能打開最多的文件數(shù)
const?int?BlockCount?=?128;???//盤塊數(shù)
const?int?DiskSize?=?BlockSize?*?BlockCount;????//磁盤大小
const?int?BlockFcbCount?=?BlockSize/sizeof(FCB);//目錄文件的最多FCB數(shù)

int?OpenFileCount?=?0;?//?統(tǒng)計(jì)當(dāng)前打開文件數(shù)目?

struct?OPENLIST??????//用戶文件打開表
{
int?files;??????//當(dāng)前打開文件數(shù)
FCB?f[OPEN_MAX];????//FCB拷貝
OPENLIST()
{
files=0;
for(int?i=0;i f[i].fatherBlockNum?=?-1;//為分配打開
f[i].type=GENERAL;
}
}
};

struct?dirFile/*-------------目錄文件結(jié)構(gòu)---------------*/
{
struct?FCB?fcb[BlockFcbCount];
void?init(int?_FatherBlockNumint?_CurrentBlockNumchar?*name)//父塊號,當(dāng)前塊號,目錄名
{
strcpy(fcb[0].fnamename);?//本身的FCB
fcb[0].fatherBlockNum=_FatherBlockNum;
fcb[0].currentBlockNum=_CurrentBlockNum;
fcb[0].type=DIRECTORY;?????//標(biāo)記目錄文件
for(int?i=1;i fcb[i].fatherBlockNum=_CurrentBlockNum;?//標(biāo)記為子項(xiàng)
fcb[i].type=Zero;????//?標(biāo)記為空白項(xiàng)
}
}
};

struct?DISK/**********************************************************************/
{
int?FAT1[BlockCount];?????//FAT1
int?FAT2[BlockCount];?????//FAT2
struct?dirFile?root;????//根目錄
char?data[BlockCount-3][BlockSize];
void?format(){
memset(FAT10BlockCount);?????//FAT1
memset(FAT20BlockCount);?????//FAT2
FAT1[0]=FAT1[1]=FAT1[2]=-2;?//012盤塊號依次代表FAT1FAT2根目錄區(qū)
FAT2[0]=FAT2[1]=FAT2[2]=-2;??//FAT作備份
root.init(22“C:\\“);//根目錄區(qū)
memset(data0sizeof(data));//數(shù)據(jù)區(qū)
}
};

FILE?*fp;??????//磁盤文件地址
char?*?baseAddr;????//虛擬磁盤空間基地址
string?currentPath=“C:\\“;???//當(dāng)前路徑
int?current=2;????//當(dāng)前目錄的盤塊號
string?cmd;??????//輸入指令
struct?DISK?*osPoint;????//磁盤操作系統(tǒng)指針
char?command[16];????//文件名標(biāo)識(shí)
struct?OPENLIST*?openlist;?//用戶文件列表指針

int??format();
int??mkdir(char?*sonfname);
int?rmdir(char?*sonfname);
int?create(char?*name);
int?listshow();
int?delfile(char?*name);
int?changePath(char?*sonfname);
int?write(char?*name);
int?exit();
int?open(char?*file);
int?close(char?*file);
int??read(char?*file);
/*------------初始化-----------------------*/
int?format()
{
current?=?2;
currentPath=“C:\\“;???//當(dāng)前路徑
osPoint->format();//打開文件列表初始化
delete?openlist;
openlist=new?OPENLIST;
/*-------保存到磁盤上myfiles--------*/
fp?=?fopen(FilePath“w+“);
fwrite(baseAddrsizeof(char)DiskSizefp);
fclose(fp);
printf(“格式化成功!!\n“);
return?1;
}

int??mkdir(char?*sonfname)/*-----------------------創(chuàng)建子目錄--------

?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件???????16310??2018-06-23?20:55??實(shí)驗(yàn)四.cpp

評論

共有 條評論

相關(guān)資源