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

📄 freebitmap.cpp

📁 模拟Linux文件系统 在任一OS下
💻 CPP
字号:
#include"disk.h"
extern disk DISK;
/*
freebitmap::freebitmap(){
	for(int i=0;i<12800;i++)
		freemap[i]=0x0;
}
int freebitmap::applyfor(){
	char c;
	bool t;
	for(int i=0;i<13;i++)
		
		for(int j=0;j<1000;j++){
		 iof.get(c);
		 t=c&0x1;
		 if(t){
			 c=c|0x80;
			 seekp(-1,ios::cur);
			 iof.put(c);
			 seekp(-1,ios::cur);
			 return i*1000*8+1;
		 }
		 if(t){
			 c=c|0x40;
			 seekp(-1,ios::cur);
			 iof.put(c);
			 seekp(-1,ios::cur);
			 return i*1000*8+2;
		 }
		 if(t){
			 c=c|0x20;
			 seekp(-1,ios::cur);
			 iof.put(c);
			 seekp(-1,ios::cur);
			 return i*1000*8+3;
		 }
		 		 		 
		 if(t){
			 c=c|0x10;
			 seekp(-1,ios::cur);
			 iof.put(c);
			 seekp(-1,ios::cur);
			 return i*1000*8+4;
		 }
		 if(t){
			 c=c|0x8;
			 seekp(-1,ios::cur);
			 iof.put(c);
			 seekp(-1,ios::cur);
			 return i*1000*8+5;
		 }
		 
		 if(t){
			 c=c|0x4;
			 seekp(-1,ios::cur);
			 iof.put(c);
			 seekp(-1,ios::cur);
			 return i*1000*8+6;
		 }
		 if(t){
			 c=c|0x2;
			 seekp(-1,ios::cur);
			 iof.put(c);
			 seekp(-1,ios::cur);
			 return i*1000*8+7;
		 }
		 if(t){
			 c=c|0x1;
			 seekp(-1,ios::cur);
			 iof.put(c);
			 seekp(-1,ios::cur);
			 return i*1000*8+8;
		 }
		}
}*/
freebitmap::freebitmap(fstream i){
	iof=i;
}
int freebitmap::freebitmap_location(int sit){
	int d=sit/1000;
	int k=sit%1000;
	int j=k/8;
	int w=k%8;
	DISK.block_to_buffer(d+freebitmapbeg,j);
	return w;
}
int freebitmap::freebitmap_read(int sit){
	int k=freebitmap_location(sit);
	char c;
	iof.get(c);
	if(k==0){
		c=c&0x80;
		if(c)return 1;
		return 0;
	}
	if(k==1){
		c=c&0x40;
		if(c)return 1;
		return 0;
	}
	if(k==2){
		c=c&0x20;
		if(c)return 1;
		return 0;
	}
	if(k==3){
		c=c&0x10;
		if(c)return 1;
		return 0;
	}
	if(k==4){
		c=c&0x8;
		if(c)return 1;
		return 0;
	}
	if(k==5){
		c=c&0x4;
		if(c)return 1;
		return 0;
	}
	if(k==6){
		c=c&0x2;
		if(c)return 1;
		return 0;
	}
	if(k==7){
		c=c&0x1;
		if(c)return 1;
		return 0;
	}
	return 0;
}
void freebitmap::freebitmap_set(int sit){
	int k=freebitmap_location(sit);
	char c;
    iof.get(c);
	if(k==0)
		c=c|0x80;
	if(k==1)
		c=c|0x40;
	if(k==2)
		c=c|0x20;
	if(k==3)
		c=c|0x10;
	if(k==4)
		c=c|0x8;
	if(k==5)
		c=c|0x4;
	if(k==6)
		c=c|0x2;
	if(k==7)
		c=c|0x1;
	freebitmap_location(sit);
	iof.put(c);
}
void freebitmap::freebitmap_clear(int sit){
	int k=freebitmap_location(sit);
	char c;
    iof.get(c);
	if(k==0)
		c=c&0x7f;
	if(k==1)
		c=c&0xbf;
	if(k==2)
		c=c&0xdf;
	if(k==3)
		c=c&0xef;
	if(k==4)
		c=c&0xf7;
	if(k==5)
		c=c&0xfb;
	if(k==6)
		c=c&0xfd;
	if(k==7)
		c=c&0xfe;
	freebitmap_location(sit);
	iof.put(c);
}
int freebitmap::freebitmap_applyfor(){
	int k;
	for(int i=0;i<blockamount;i++){
		k=freebitmap_read(i);
		if(k)continue;
		return i;
	}
	return -1;
}

⌨️ 快捷键说明

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