fs.h

来自「一个简单的虚拟机和虚拟操作系统」· C头文件 代码 · 共 64 行

H
64
字号
#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 + =
减小字号Ctrl + -
显示快捷键?