Пример #1
0
CompileVersion::CompileVersion(QWidget *parent) :
    ui(new Ui::CompileVersion)
{
    ui->setupUi(this);
    Qt::WindowFlags flags=Qt::Window;
    this->setWindowFlags(flags|Qt::CustomizeWindowHint);
    this->setWindowModality(Qt::ApplicationModal);

    this->setWindowOpacity(0.75);
    QString file=QString("%1\\config\\%2").arg(QApplication::applicationDirPath()).arg(FILE_VERSION);
    QFile dummyFile(file);
    if (dummyFile.open(QIODevice::ReadOnly)){
        QByteArray readed=dummyFile.readAll();
        ui->m_text->setText(QString(readed));
        ui->m_text->update();
        dummyFile.close();
    }
    else{
        ui->m_text->setText("NO changes log provided");
    }

    setCompileVersion(IN2_RELEASE_VERSION);
    connect(ui->m_pbExit,SIGNAL(clicked()),this,SLOT(Exit()));
}
Пример #2
0
void AdvHuffman::Encoding(const char* inputFile, const char* outputFile, double *entrpy, double *bps){
    // Setting up files
    string dummyFile(outputFile);
    dummyFile += "Dummy";
    ifstream infile(inputFile, ios::in|ios::binary);
    ofstream ofile(dummyFile.c_str(), ios::out|ios::binary);

    // First process: converting the file into a text file which contains the "uncompressed"
    // string representation of bit code
    int totalBits = 0;
    char karakter;
    infile.get(karakter);
    unsigned char c = karakter;
    insertAfter(c);
    UpdateNomorNode();
    Update(TabKar[c],true);
    ofile << charToCode(c);
    totalBits += charToCode(c).length();

    // Next
    while (infile.get(karakter)) {
        unsigned char c = karakter;
        *bps += charToCode(c).length();
        if (TabKar[c] == -1){
            ofile << NYTcodeFromTree(512);
            totalBits += NYTcodeFromTree(512).length();
            insertAfter(c);
            ofile << charToCode(c);
            totalBits += charToCode(c).length();
            UpdateNomorNode();
            Update(TabNode[TabKar[c]].getParent(),true);
        } else {
            ofile << charCodeFromTree(512,c);
            totalBits += charCodeFromTree(512,c).length();
            Update(TabKar[c],false);
        }
    }
    infile.close();
    ofile.close();

    // Converting the resulting file with the string bit code representation into the
    // compressed form
    infile.open(dummyFile.c_str(), ios::in|ios::binary);
    ofile.open(outputFile, ios::out|ios::binary);
    char container[8];
    int idx = 0;

    ofile << getFileName(inputFile).toStdString();
    ofile << ' ';
    ofile << totalBits;
    ofile << ' ';
    char cc;
    while (infile.get(cc)) {
        char bit = cc - 48;
        container[idx] = bit;
        idx++;
        if (idx == 8) {
            idx = 0;
            ofile << arrToChar(container);
        }
    }
    // Putting dummy bits if the container is not empty
    if (idx != 0) {
        while (idx != 8) {
            container[idx] = 0;
            idx++;
        }
    }
    ofile << arrToChar(container);
    infile.close();
    ofile.close();

    // Remove dummy file
    remove(dummyFile.c_str());
}