2023-08-06 08:48:11 -04:00
|
|
|
// SPDX-FileCopyrightText: 2023 Joshua Goins <josh@redstrate.com>
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2023-07-09 10:54:27 -04:00
|
|
|
#pragma once
|
|
|
|
|
2023-09-25 22:03:33 -04:00
|
|
|
#include <QHash>
|
2023-07-09 10:54:27 -04:00
|
|
|
#include <QMap>
|
2023-09-26 20:20:36 -04:00
|
|
|
#include <QMutex>
|
2023-08-06 08:48:11 -04:00
|
|
|
#include <QString>
|
|
|
|
#include <physis.hpp>
|
2023-07-09 10:54:27 -04:00
|
|
|
|
|
|
|
struct GameData;
|
|
|
|
|
2023-10-12 23:44:54 -04:00
|
|
|
class FileCache
|
|
|
|
{
|
2023-07-09 10:54:27 -04:00
|
|
|
public:
|
2023-10-12 23:44:54 -04:00
|
|
|
explicit FileCache(GameData &data);
|
2023-07-09 10:54:27 -04:00
|
|
|
|
2023-10-13 15:01:23 -04:00
|
|
|
bool fileExists(const QString &path);
|
|
|
|
physis_Buffer &lookupFile(const QString &path);
|
2023-07-09 10:54:27 -04:00
|
|
|
|
|
|
|
private:
|
2023-10-13 15:01:23 -04:00
|
|
|
QMap<QString, physis_Buffer> cachedBuffers;
|
|
|
|
QHash<QString, bool> cachedExist;
|
2023-10-12 23:44:54 -04:00
|
|
|
GameData &data;
|
2023-09-26 20:20:36 -04:00
|
|
|
QMutex bufferMutex, existMutex;
|
2023-07-09 10:54:27 -04:00
|
|
|
};
|