#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; //当前的父目录盘块号 int currentBlockNum; //当前的盘块 void initialize() { strcpy(fname,"\0"); type = Zero; size =0; fatherBlockNum = currentBlockNum = 0; } }; const char* FilePath = "C:\\myfiles";/*常量设置*/ const int BlockSize = 512; //盘块大小 const int OPEN_MAX = 5; //能打开最多的文件数 const int BlockCount = 128; //盘块数 const int DiskSize = BlockSize * BlockCount; //磁盘大小 64K const int FcbCount = BlockSize/sizeof(FCB);//目录文件的最多 FCB 数 int OpenFileCount = 0; // 统计当前打开文件数目 struct OPENLIST //用户文件打开表 { int files; //当前打开文件数 FCB f[OPEN_MAX]; //FCB 拷贝 OPENLIST() { files=0; for(int i=0;i