MCPcopy Create free account
hub / github.com/chris2511/xca / openLocalDatabase

Method openLocalDatabase

lib/database_model.cpp:449–478  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

447}
448
449void database_model::openLocalDatabase(const QString &connName,
450 const QString &descriptor)
451{
452 QSqlDatabase db = QSqlDatabase::database(connName);
453 XFile f(descriptor);
454 qDebug() << connName << descriptor;
455 if (!f.exists(descriptor)) {
456 f.open(QIODevice::WriteOnly);
457 f.setPermissions(QFile::WriteOwner | QFile::ReadOwner);
458 }
459
460 if (f.size() != 0) {
461 f.open(QIODevice::ReadOnly);
462 QByteArray ba = f.read(6);
463 qDebug() << "FILE:" << f.fileName() << ba;
464 if (ba != "SQLite") {
465 throw errorEx(tr("The file '%1' is not an XCA database")
466 .arg(f.fileName()));
467 }
468 }
469 f.close();
470
471 db.setDatabaseName(descriptor);
472 db.open();
473 QSqlError e = db.lastError();
474 if (e.isValid()) {
475 db.close();
476 throw errorEx(e);
477 }
478}
479
480void database_model::openDatabase(const QString &descriptor, const Passwd &pass)
481{

Callers

nothing calls this directly

Calls 6

errorExClass · 0.85
openMethod · 0.80
sizeMethod · 0.80
closeMethod · 0.80
lastErrorMethod · 0.80
isValidMethod · 0.45

Tested by

no test coverage detected