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

📄 fatvol.h

📁 Jazmyn is a 32-bit, protected mode, multitasking OS which runs on i386 & above CPU`s. Its complete
💻 H
字号:
#ifndef _FATVOL_H
#define _FATVOL_H

#define FREE_CLUS       0
#define EOC             0x0FFFFFFF
#define BAD_CLUS        0x0FFFFFF7
#define CLNSHUTBITMASK  0x08000000
#define HRDERRBITMASK   0x04000000

/*constants for attr field of short dir structure*/
#define ATTR_READ_ONLY  0x01
#define ATTR_HIDDEN     0x02
#define ATTR_SYSTEM     0x04
#define ATTR_VOLUME_ID  0x08
#define ATTR_DIRECTORY  0x10
#define ATTR_ARCHIVE    0x20
#define ATTR_LONG_NAME \
(ATTR_READ_ONLY | ATTR_HIDDEN | ATTR_SYSTEM | ATTR_VOLUME_ID)


/*types of FAT*/
#define UNKNOWN 0
#define FAT12   1
#define FAT16   2
#define FAT32   3

#define _CR(r,o,d,s,n,b) \
do {\
        r.opcode = o;\
        r.dev_num = d;\
        r.start = s;\
        r.num = n;\
        r.buf = b;\
}while(0)

struct fldir
{
        byte	ldir_ord;
        byte	ldir_name1[10];
        byte	ldir_attr;
        byte	ldir_type;
        byte	ldir_chksum;
        byte	ldir_name2[12];
        ushort	ldir_fst_clusLO;
        byte	ldir_name3[4];
};

struct part_info
{
        uint	start_sec;
        uint	end_sec;
};

struct BPB
{
        byte	OEMname[8];
        uint	bps;
        uint	spc;
        uint	rsc;
        uint	numFATs;
        uint	rec;
        uint	totsec16;
        uint	media;
        uint	FATsz16;
        uint	spt;
        uint	numheads;
        uint	totsec32;
        uint	FATsz32;
};

class fatbuffer;
	
class FATvolume
{
//private:
public:
	int		mem_flag;
	char		drive;
       uint		rds;
        uint		FATstart;
        uint		fds;
        uint		totsec;
        uint		datasec;
        uint            coc;
        int		FATtype;
        int		dev;
        part_info       _pi;
        BPB		_bpb;

//public:
      uint	FATsz;
      int	slot;
	static fdir	root;
	static fdir	pwd;
      static fdir     ppwd;
	static uint	totsz;
      static fatbuffer _fb;
      byte	*mem_FAT;
	int	mounted;


	FATvolume();
	~FATvolume();
	void	init_volume(uint start,uint end,char drv,int slt_nr,int dv_nr);
	int	is_FAT();
	int	mount();
	int	unmount();
	char*	get_next_name(char* path,char* pname);
        fdir*   get_dir_entry(char *name,uint &n,uint &clus_nr,uint &index);
	int	put_dir_entry(char *name,byte attr,uint fsize);
        int     creat_dir_entry(char *name,fdir *dir,uint start,uint nfe,byte attr,uint fsize);
	int	del_dir_entry(char *name);
	void*	read_file(char *name,uint &size);
	int	write_file(char *name,void *buf,uint size);
	int	delete_file(char *name);
	int	get_short_dir_entry(char *name,fdir &d);
	char*	strip(char *name);
	char*	gen_basis_name(char *name);
        int     is_8_3(char *name);
	byte*	get_unicode(char* name,uint &num);
	int	is_dot_dotdot(char* name);
	int	get_nfe(char* name);
	uint	get_start_clus(fdir *dir);
	uint	get_next_clus(uint start,uint &clus_nr,fdir *dir);
	int	write_clus(uint clus_nr,void *buf);
	int	read_clus(uint clus_nr,void *buf);
	uint	expand_clus(uint clus_nr);
	uint	contract_clus(uint clus_nr);
	uint	alloc_first_clus(char *name,byte attr);
	int	is_empty(fdir &dir);
	void*	read_clus_chain(uint start,uint &size);
	int	write_clus_chain(uint start,void *buf,uint size);
	int	free_clus_chain(uint start);
	int	is_directory(fdir &dir);
	char*	gen_tail(char* name);
        int     get_behind(byte *str,char *ret,int &n,int &num);
	void*	get_FAT_ent_addr(uint N);
	uint	get_FAT_entry(uint N);
	void	put_FAT_entry(uint N,uint value);
	int	read_root(fdir &r);
	int	set_root();
	static void	save_root(fdir &r);
	static void	restore_root(fdir &r);
	int	chdir(char *path);
        byte    chksum(char *name);
        uint    get_free_clus();
        
	  ushort  get_FAT_time()
	  {
		return 0;
	  }
        ushort  get_FAT_date()
	  {
		return 0;
	  }


	char get_drive()
	{
		return drive;
	}
};

extern "C" int is_equal(fdir &d1,fdir &d2);

#endif


⌨️ 快捷键说明

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