refs #494 Get the filename used for serializing a specific cached value, or list of all files used by whole cache.

This commit is contained in:
Mathew Sutcliffe
2015-10-22 02:02:28 +01:00
parent 8a3cb5f661
commit 0ca4797bcf
7 changed files with 72 additions and 0 deletions

View File

@@ -46,6 +46,16 @@ namespace BlackCore
return dir;
}
QString CDataCache::filenameForKey(const QString &key)
{
return persistentStore() + "/" + CValueCache::filenameForKey(key);
}
QStringList CDataCache::enumerateStore() const
{
return enumerateFiles(persistentStore());
}
QString lockFileError(const QLockFile &lock)
{
switch (lock.error())

View File

@@ -34,6 +34,12 @@ namespace BlackCore
//! The directory where core data are stored.
static const QString &persistentStore();
//! Return the filename where the value with the given key may be stored.
static QString filenameForKey(const QString &key);
//! Return all files where data may be stored.
QStringList enumerateStore() const;
private:
CDataCache();
@@ -75,6 +81,9 @@ namespace BlackCore
//! Reset the data to its default value.
void setDefault() { this->set(Trait::defaultValue()); }
//! Return the file that is used for persistence for this value.
QString getFilename() const { return CDataCache::filenameForKey(this->getKey()); }
};
/*!

View File

@@ -39,4 +39,14 @@ namespace BlackCore
return loadFromFiles(persistentStore());
}
QString CSettingsCache::filenameForKey(const QString &key)
{
return persistentStore() + "/" + CValueCache::filenameForKey(key);
}
QStringList CSettingsCache::enumerateStore() const
{
return enumerateFiles(persistentStore());
}
}

View File

@@ -36,6 +36,12 @@ namespace BlackCore
//! Load core settings from disk.
BlackMisc::CStatusMessage loadFromStore();
//! Return the filename where the value with the given key may be stored.
static QString filenameForKey(const QString &key);
//! Return all files where settings may be stored.
QStringList enumerateStore() const;
private:
CSettingsCache();
};
@@ -63,6 +69,9 @@ namespace BlackCore
//! Reset the setting to its default value.
void setDefault() { this->set(Trait::defaultValue()); }
//! Return the file that is used for persistence for this value.
QString getFilename() const { return CSettingsCache::filenameForKey(this->getKey()); }
};
/*!