9 #include <initializer_list>
16 namespace fs = std::filesystem;
76 void scanFile(
const fs::path& infilePath);
95 void writeHeader(
const std::string& inputName, std::ofstream& writer);
105 void writeBody(
char& chr,
int& bufferSize,
const std::string& infileName, std::ofstream& writer);
117 void compress(
const std::string& infileName);
142 void compressFiles(std::initializer_list<std::string> infileNames);
This file exports the constants used in throughout the project.
This class models a node structure used for building Huffman Binary Tree.
This class compresses files and folders using Huffman Compression Algorithm.
void deleteTree(BinNode *node)
Frees all heap storage associated with the Huffman Tree.
fs::path writeIntoFile(const std::string &infileName)
Write the header and body section to compressed file.
void compressFolder(const std::string &directoryName)
Compresses a directory and its entire content recursively.
BinNode * rootNode
Root node for Huffman tree.
void clear()
Resets all the attributes for next compression operation.
void readFrequency()
Reads entire input file and finds frequency of each unique characters.
HashMap< char, std::string > codeMap
Prefix-free binary code for each value of the source symbol.
void compressFile(const std::string &infileName)
Compresses a single input file.
HashMap< char, int > frequency
Frequency of occurrence for each unique symbol in the source.
void compress(const std::string &infileName)
Utility function to compress file.
BinNode * createHuffmanTree()
Creates a Huffman Tree form unique characters along with their frequency of occurrences.
void compressFiles(std::initializer_list< std::string > infileNames)
Compresses multiple source files into single compressed(.huf) file.
void scanFile(const fs::path &infilePath)
Validates input file path and proceeds on reading frequency.
void writeBody(char &chr, int &bufferSize, const std::string &infileName, std::ofstream &writer)
Write the body section to compressed file.
std::ifstream infile
Instance of ifstream class for reading characters from source.
std::vector< fs::path > inputFiles
List of input files given by the user.
void writeHeader(const std::string &inputName, std::ofstream &writer)
Write the header section to compressed file.
void writeTree(std::ofstream &writer, BinNode *head)
Write the entire Huffman tree in to the file header section using a pre-order traversal algorithm.
void generateHuffmanCode(BinNode *rootNode, std::string codeString)
Generates prefix code for each unique characters in the source.