📄 bfile.h
字号:
#ifndef _BFILE_H
#define _BFILE_H
#include <string>
#include <iostream>
#include <cmath>
#include "qtree.h"
#include "Cache.h"
#include "generaldef.h"
#include "utility.h"
class BlockFile {
public:
FILE* fp; // os file pointer
char* filename;
int blocklength; // length of a block
int act_block; // block # of fp's position (fp can stay at block boundaries)
int number; // total # of blocks
bool new_flag; // specifies if this is a new file
string *file_cont;
int *file_cont_no; //No. of data entry stored in each block
BlockFile(char* name, int b_length);
~BlockFile();
void put_bytes(char* bytes,int num) { fwrite(bytes,num,1,fp); }
void get_bytes(char* bytes,int num) { fread(bytes,num,1,fp); }
void fwrite_number(int num); // to write an integer
int fread_number(); // to read an integer
void seek_block(int bnum) { fseek(fp,(bnum-act_block)*blocklength,SEEK_CUR); } //bnum: the destine block's # (to find "block X")
void fread_header(char * header);
void fset_header(char* header);
bool fread_block(Entry** dataArray,int pos);
// bool fwrite_block(Block b,int i);
bool fwrite_one_data(Entry* data, int pos);
bool fmove_one_data(char* data, int pos);
int fappend_block();
bool fdelete_last_blocks(int num);
bool file_new() { return new_flag; }
int get_blocklength() { return blocklength; }
int get_num_of_blocks() { return number; }
int retrieve_index(string node_id);
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -