cache frame indexes to disk
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user