~qqworini/aesydict/online-improve

« back to all changes in this revision

Viewing changes to src/dictdatablock.cpp

  • Committer: Joey Chan
  • Date: 2015-04-02 15:10:17 UTC
  • Revision ID: qqworini@gmail.com-20150402151017-50skhy76lhkj7xgx
c++ functions initially done

Show diffs side-by-side

added added

removed removed

Lines of Context:
54
54
    return QString(data);
55
55
}
56
56
 
 
57
QString DictDataBlock::get_datablock(const qint32 &offset, const qint32 &size)
 
58
{
 
59
    if(!(dictfile->open(QIODevice::ReadOnly))) {
 
60
        error_message(tr("Faild to open dict file: %1.Error: %2").arg(dictfilename,dictfile->errorString()));
 
61
        return NULL;
 
62
    }
 
63
    quint32 offSet,length;
 
64
    offSet=offset;
 
65
    length=size;
 
66
    dictfile->seek(offSet);
 
67
    QByteArray data=dictfile->read(length);
 
68
    if(data.isEmpty()) {
 
69
        error_message(tr("Data block is empty."));
 
70
        dictfile->close();
 
71
        return NULL;
 
72
    }
 
73
    dictfile->close();
 
74
    return QString(data);
 
75
}
 
76
 
57
77
void DictDataBlock::clear()
58
78
{
59
79
    dictfilename.clear();