MCPcopy Create free account
hub / github.com/Qucs/qucs / insertFile

Method insertFile

qucs/dialogs/packagedialog.cpp:167–190  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

165// ***************************************************************
166
167int 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// ---------------------------------------------------------------
193int PackageDialog::insertDirectory(const QString& DirName,

Callers

nothing calls this directly

Calls 2

sizeMethod · 0.80
dataMethod · 0.80

Tested by

no test coverage detected