1
Fork 0
mirror of https://github.com/redstrate/Novus.git synced 2025-04-23 20:47:45 +00:00
novus/common/src/filecache.cpp

31 lines
727 B
C++
Raw Normal View History

// 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) {}
2023-09-26 00:37:55 -04:00
physis_Buffer &FileCache::lookupFile(const QLatin1String &path)
{
QMutexLocker locker(&bufferMutex);
if (!cachedBuffers.contains(path)) {
2023-09-26 00:37:55 -04:00
cachedBuffers[path] = physis_gamedata_extract_file(&data, path.data());
}
return cachedBuffers[path];
}
bool FileCache::fileExists(const QLatin1String &path)
{
QMutexLocker locker(&existMutex);
if (!cachedExist.contains(path)) {
cachedExist[path] = physis_gamedata_exists(&data, path.data());
}
return cachedExist[path];
}