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

Method extractLibrary

qucs/dialogs/packagedialog.cpp:473–497  ·  view source on GitHub ↗

---------------------------------------------------------------

Source from the content-addressed store, hash-verified

471
472// ---------------------------------------------------------------
473int PackageDialog::extractLibrary(QFile& PkgFile, Q_UINT32 Count)
474{
475 char *p = (char*)malloc(Count);
476 PkgFile.read(p, Count);
477 QByteArray Content = qUncompress((unsigned char*)p, Count);
478 free(p);
479
480 p = Content.data();
481 QFile File(QucsSettings.QucsHomeDir.absolutePath() +
482 QDir::toNativeSeparators("/user_lib/") + QString(p));
483 if(File.exists()) {
484 MsgText->append(tr("ERROR: User library \"%1\" already exists!").arg(QString(p)));
485 return -1;
486 }
487
488 if(!File.open(QIODevice::WriteOnly)) {
489 MsgText->append(tr("ERROR: Cannot create library \"%1\"!").arg(QString(p)));
490 return -1;
491 }
492
493 File.write(p+strlen(p)+1, Content.size()-strlen(p)-1);
494 File.close();
495 MsgText->append(tr("Create library \"%1\"").arg(QString(p)));
496 return 1;
497}

Callers

nothing calls this directly

Calls 3

dataMethod · 0.80
sizeMethod · 0.80
QStringClass · 0.70

Tested by

no test coverage detected