| 165 | // *************************************************************** |
| 166 | |
| 167 | int PackageDialog::insertFile(const QString& FileName, QFile& File, |
| 168 | QDataStream& Stream) |
| 169 | { |
| 170 | QByteArray FileContent; |
| 171 | |
| 172 | if(!File.open(QIODevice::ReadOnly)) { |
| 173 | QMessageBox::critical(this, tr("Error"), |
| 174 | tr("Cannot open \"%1\"!").arg(FileName)); |
| 175 | return -1; |
| 176 | } |
| 177 | |
| 178 | Q_ULONG Count = File.size(); |
| 179 | char *p = (char*)malloc(Count+FileName.length()+2); |
| 180 | strcpy(p, FileName.toLatin1()); |
| 181 | File.read(p+FileName.length()+1, Count); |
| 182 | File.close(); |
| 183 | |
| 184 | Count += FileName.length()+1; |
| 185 | FileContent = qCompress((unsigned char*)p, Count); |
| 186 | free(p); |
| 187 | |
| 188 | Stream.writeBytes(FileContent.data(), FileContent.size()); |
| 189 | return 0; |
| 190 | } |
| 191 | |
| 192 | // --------------------------------------------------------------- |
| 193 | int PackageDialog::insertDirectory(const QString& DirName, |