RubbishBin/zip-unzip-search/include/file_io.h

83 lines
1.6 KiB
C
Raw Normal View History

2024-10-30 17:23:52 +08:00
//
// Created by ricardo on 22-12-11.
//
#ifndef ZIP_UNZIP_SEARCH_FILE_IO_H
#define ZIP_UNZIP_SEARCH_FILE_IO_H
#include "string"
/**
*
*/
struct MetaData
{
/**
*
*/
int HuffmanNodeLength;
/**
*
*/
int HuffmanRoot;
/**
* 使
*/
int LastBufferUsedLength;
};
class FileIO
{
public:
/**
*
* @param fileName
* @return delete
*/
static int* ReadCharFrequency(const std::string& fileName);
/**
*
* @param inputFile
* @param outputFile
*/
static void WriteZipFile(const std::string& inputFile, const std::string& outputFile);
/**
*
* @param inputFile
* @param outputFile
*/
static void WriteUnzipFile(const std::string& inputFile, const std::string& outputFile);
/**
*
* @param inputFileName
* @param outputFileName
* @return
*/
static double CalculateZipRate(const std::string& inputFileName, const std::string& outputFileName);
};
class BinaryBuffer
{
public:
explicit BinaryBuffer(std::string& inputFileName);
~BinaryBuffer();
char read();
int position = 0;
private:
FILE* file = nullptr;
int buffer;
int bufferPos;
bool readFinishedFlag;
};
#endif //ZIP_UNZIP_SEARCH_FILE_IO_H