#include #include #include #include "hufftree.h" bool encode( istream& ins, ostream& outs ) { hufftree tree; obitstream outbits( outs ); //Don't forget to call outbits.flush() before return ins.seekg( 0 ); // Read from the beginning of the input file // TODO // 1. First pass over the input file, get the count of each character // 2. Built the tree ins.seekg( 0 ); // Read again from the beginning of the input file ins.clear ( ~ios::eofbit & ins.rdstate() ); // 3. Second pass over the input file to encode it. return true; } int main( int argc, char* argv[] ) { ifstream infile; ofstream outfile; // Get filename and open file. // if( argc != 3 ) { cerr << "Usage: encode inputfile outputfile" << endl; return 1; } else { infile.open( argv[1], ios::in ); if( !infile ) { cerr << "Could not open inputfile " << argv[1] << "!" << endl; return -1; } outfile.open ( argv[2], ios::out ); if ( !outfile ) { cerr << "Could not open outputfile " << argv[2] << "!" << endl; return -1; } } // Encode the input file // if( !encode( infile, outfile ) ) cerr << "Trouble reading file " << argv[1] << "!" << endl; return 0; }