⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fs.h

📁 一个简单的虚拟机和虚拟操作系统
💻 H
字号:
#pragma once
#include "StdAfx.h"
#include "disk.h"
#include "dictionary.h"
#include "iostream"
using namespace std;

class FS
{
public:
	FS();
	~FS();
public:
	/*
	 * free the blocks whose indexes are stroed
	 * in the array tofree
	 */
	bool free(int num,int*tofree);
	/*
	 * allocate blocks for file, if successful
	 * then store their indexes in the array alloc
	 */
	bool allocate(int num,int*alloc);

public:
	/*
	 * return the free size
	 */
	int getFreeSize()const;
	/*
	 * return a pointer point to the block of
	 * the given index
	 */
	char* getBlock(int index)const;
	bool readBlock(int index,char* buffer)const;
	bool writeBlock(int index,const char* buffer);
	Dictionary*getRoot()const
	{
		return root;
	}
	Dictionary*getCurrent()const
	{
		return current;
	}
	Dictionary*setCurrent(Dictionary*c)
	{
		if(c == NULL)return NULL;
		current = c;
		Dictionary*old = current;
		return old;
	}
public:
	void save(CArchive&ar)const;
	void load(CArchive&ar);
	void reset();
	void format();

private:
	bool used[BLOCK_NUM];
	int freeSize;
	Dictionary* root;
	Dictionary* current;
	Disk disk;
};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -