mirror of
https://github.com/libretro/scummvm.git
synced 2025-04-03 15:21:40 +00:00
COMMON: Allow memcaching archive to bypass caching part and return a stream
It's useful for patchers if they can easily create a stream in some cases but not others.
This commit is contained in:
parent
c33ce058f8
commit
6476e55aab
@ -107,7 +107,10 @@ SeekableReadStream *MemcachingCaseInsensitiveArchive::createReadStreamForMember(
|
||||
String translated = translatePath(path);
|
||||
bool isNew = false;
|
||||
if (!_cache.contains(translated)) {
|
||||
_cache[translated] = readContentsForPath(translated);
|
||||
SharedArchiveContents readResult = readContentsForPath(translated);
|
||||
if (readResult._bypass)
|
||||
return readResult._bypass;
|
||||
_cache[translated] = readResult;
|
||||
isNew = true;
|
||||
}
|
||||
|
||||
@ -121,7 +124,10 @@ SeekableReadStream *MemcachingCaseInsensitiveArchive::createReadStreamForMember(
|
||||
// Check whether the entry is still valid as WeakPtr might have expired.
|
||||
if (!entry->makeStrong()) {
|
||||
// If it's expired, recreate the entry.
|
||||
_cache[translated] = readContentsForPath(translated);
|
||||
SharedArchiveContents readResult = readContentsForPath(translated);
|
||||
if (readResult._bypass)
|
||||
return readResult._bypass;
|
||||
_cache[translated] = readResult;
|
||||
entry = &_cache[translated];
|
||||
isNew = true;
|
||||
}
|
||||
|
@ -169,10 +169,15 @@ class SharedArchiveContents {
|
||||
public:
|
||||
SharedArchiveContents(byte *contents, uint32 contentSize) :
|
||||
_strongRef(contents, ArrayDeleter<byte>()), _weakRef(_strongRef),
|
||||
_contentSize(contentSize), _missingFile(false) {}
|
||||
SharedArchiveContents() : _strongRef(nullptr), _weakRef(nullptr), _contentSize(0), _missingFile(true) {}
|
||||
_contentSize(contentSize), _missingFile(false), _bypass(nullptr) {}
|
||||
SharedArchiveContents() : _strongRef(nullptr), _weakRef(nullptr), _contentSize(0), _missingFile(true), _bypass(nullptr) {}
|
||||
static SharedArchiveContents bypass(SeekableReadStream *stream) {
|
||||
return SharedArchiveContents(stream);
|
||||
}
|
||||
|
||||
private:
|
||||
SharedArchiveContents(SeekableReadStream *stream) : _strongRef(nullptr), _weakRef(nullptr), _contentSize(0), _missingFile(false), _bypass(stream) {}
|
||||
|
||||
bool isFileMissing() const { return _missingFile; }
|
||||
SharedPtr<byte> getContents() const { return _strongRef; }
|
||||
uint32 getSize() const { return _contentSize; }
|
||||
@ -197,6 +202,7 @@ private:
|
||||
WeakPtr<byte> _weakRef;
|
||||
uint32 _contentSize;
|
||||
bool _missingFile;
|
||||
SeekableReadStream *_bypass;
|
||||
|
||||
friend class MemcachingCaseInsensitiveArchive;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user