cache frame indexes to disk

This commit is contained in:
itsmattkc
2019-08-07 12:14:48 +10:00
parent 1138600f37
commit 410c1ff06c
5 changed files with 139 additions and 19 deletions
+2
View File
@@ -18,6 +18,8 @@ set(OLIVE_SOURCES
${OLIVE_SOURCES}
common/channellayout.h
common/clamp.h
common/filefunctions.h
common/filefunctions.cpp
common/lerp.h
common/rational.h
common/rational.cpp
+43
View File
@@ -0,0 +1,43 @@
#include "filefunctions.h"
#include <QCryptographicHash>
#include <QDateTime>
#include <QDir>
#include <QFileInfo>
#include <QStandardPaths>
QString GetUniqueFileIdentifier(const QString &filename)
{
QFileInfo info(filename);
if (!info.exists()) {
return QString();
}
QCryptographicHash hash(QCryptographicHash::Sha1);
hash.addData(info.absoluteFilePath().toUtf8());
hash.addData(info.lastModified().toString().toUtf8());
QByteArray result = hash.result();
return QString(result.toHex());
}
QString GetMediaIndexLocation()
{
QDir local_appdata_dir(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation));
QDir media_index_dir = local_appdata_dir.filePath("mediaindex");
// Attempt to ensure this folder exists
media_index_dir.mkpath("mediaindex");
return media_index_dir.absolutePath();
}
QString GetMediaIndexFilename(const QString &filename)
{
return QDir(GetMediaIndexLocation()).filePath(filename);
}
+12
View File
@@ -0,0 +1,12 @@
#ifndef FILEFUNCTIONS_H
#define FILEFUNCTIONS_H
#include <QString>
QString GetUniqueFileIdentifier(const QString& filename);
QString GetMediaIndexLocation();
QString GetMediaIndexFilename(const QString& filename);
#endif // FILEFUNCTIONS_H