mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-06 01:45:38 +08:00
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:
@@ -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())
|
||||
|
||||
@@ -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()); }
|
||||
};
|
||||
|
||||
/*!
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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()); }
|
||||
};
|
||||
|
||||
/*!
|
||||
|
||||
Reference in New Issue
Block a user