mirror of
https://github.com/redstrate/Novus.git
synced 2025-04-24 04:57:45 +00:00
This can speed up operations quickly, as files aren't expected to be changed, and it prevents an index read.
25 lines
657 B
C++
25 lines
657 B
C++
// SPDX-FileCopyrightText: 2023 Joshua Goins <josh@redstrate.com>
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
#include "filecache.h"
|
|
|
|
#include <physis.hpp>
|
|
|
|
FileCache::FileCache(GameData& data) : data(data) {}
|
|
|
|
physis_Buffer& FileCache::lookupFile(const QString& path) {
|
|
if (!cachedBuffers.contains(path)) {
|
|
cachedBuffers[path] = physis_gamedata_extract_file(&data, path.toStdString().c_str());
|
|
}
|
|
|
|
return cachedBuffers[path];
|
|
}
|
|
|
|
bool FileCache::fileExists(const QLatin1String &path)
|
|
{
|
|
if (!cachedExist.contains(path)) {
|
|
cachedExist[path] = physis_gamedata_exists(&data, path.data());
|
|
}
|
|
|
|
return cachedExist[path];
|
|
}
|