FileHandler.cpp
/**
 * Prepares to exit the software by creating the final text file
 * @param binFile The final binary file to be used as input
 * @param filename The final text file as output
 */
Prepares to exit the software by creating the final text file
@param binFile The final binary file to be used as input
@param filename The final text file as output
Prepares to exit the software by creating the final text file @param binFile The final binary file to be used as input @param filename The final text file as output
void FileHandler::createFinalFile(std::FILE* binFile, std::string filename) {
    std::FILE* pFile = std::fopen(filename.c_str(), "wb");
    std::fclose(pFile);
    std::ofstream out(filename.c_str());
    std::fseek(binFile, 0L, SEEK_END);
    long size = ftell(binFile);
    std::fseek(binFile, 0, SEEK_SET);
    int length = size / sizeof(int);
    for (int i = 0; i < length; i++){
        int result;
        std::fread(&result, sizeof(int), 1, binFile);
        out << result;
        if (i+1 < length)
            out << ",";
    }
}
void FileHandler :: createFinalFile ( std :: FILE * binFile , std :: string filename ) { std :: FILE * pFile = std :: fopen ( filename . c_str ( ) , " " ) ; std :: fclose ( pFile ) ; std :: ofstream out ( filename . c_str ( ) ) ; std :: fseek ( binFile , 0L , SEEK_END ) ; long size = ftell ( binFile ) ; std :: fseek ( binFile , 0 , SEEK_SET ) ; int length = size / sizeof ( int ) ; for ( int i = 0 ; i < length ; i ++ ) { int result ; std :: fread ( & result , sizeof ( int ) , 1 , binFile ) ; out << result ; if ( i + 1 < length ) out << " " ; } }
Prepares to exit the software by creating the final text file
 @param binFile The final binary file to be used as input
 @param filename The final text file as output
Prepares to exit the software by creating the final text file @param binFile The final binary file to be used as input @param filename The final text file as output