Logo Search packages:      
Sourcecode: akonadi version File versions  Download package

QString DataStore::storagePath (  )  const

We need the following path for the database directory: $XDG_DATA_HOME/akonadi/db/akonadi/

Definition at line 212 of file datastore.cpp.

References driverName(), Akonadi::Tracer::error(), Akonadi::XdgBaseDirs::homePath(), Akonadi::XdgBaseDirs::saveDir(), and Akonadi::Tracer::self().

Referenced by DataStore().

{
  /**
   * We need the following path for the database directory:
   *   $XDG_DATA_HOME/akonadi/db/akonadi/
   */
  QString akonadiHomeDir = XdgBaseDirs::saveDir( "data", QLatin1String( "akonadi" ) );
  if ( akonadiHomeDir.isEmpty() ) {
    Tracer::self()->error( "DataStore::storagePath",
                           QString::fromLatin1( "Unable to create directory '%1/akonadi'" ).arg( XdgBaseDirs::homePath( "data" ) ) );
  }

  akonadiHomeDir += QLatin1Char( '/' );

  if ( driverName() == QLatin1String( "QSQLITE" ) ) {
    const QString akonadiPath = akonadiHomeDir + QLatin1String("akonadi.db");
    if ( !QFile::exists( akonadiPath ) ) {
      QFile file( akonadiPath );
      if ( !file.open( QIODevice::WriteOnly ) ) {
        Tracer::self()->error( "DataStore::storagePath", QString::fromLatin1( "Unable to create file '%1'" ).arg( akonadiPath ) );
      } else {
        file.close();
      }
    }
    return akonadiPath;
  }
  if ( driverName() == QLatin1String( "QMYSQL_EMBEDDED" ) ) {
    const QString dbDataDir = akonadiHomeDir + QLatin1String( "db" ) + QDir::separator();
    if ( !QDir( dbDataDir ).exists() ) {
      QDir dir;
      if ( !dir.mkdir( dbDataDir ) )
        Tracer::self()->error( "DataStore::storagePath",
                              QString::fromLatin1( "Unable to create directory '%1'" ).arg( dbDataDir ) );
    }

    const QString dbDir = dbDataDir + QLatin1String("akonadi");

    if ( !QDir( dbDir ).exists() ) {
      QDir dir;
      if ( !dir.mkdir( dbDir ) )
        Tracer::self()->error( "DataStore::storagePath",
                              QString::fromLatin1( "Unable to create directory '%1'" ).arg( dbDir ) );
    }
    return dbDataDir;
  }

  return QString();
}


Generated by  Doxygen 1.6.0   Back to index