mirror of
https://github.com/scummvm/scummvm.git
synced 2026-06-20 05:45:29 +00:00
CLOUD: Make OutSaveFile start saves sync
It had to become a proxy class in order to do that. finalize() starts the saves sync.
This commit is contained in:
@@ -56,7 +56,7 @@ Common::OutSaveFile *GBAMPSaveFileManager::openForSaving(const Common::String &f
|
||||
Common::WriteStream *stream = DS::DSFileStream::makeFromPath(fileSpec, true);
|
||||
// Use a write buffer
|
||||
stream = Common::wrapBufferedWriteStream(stream, SAVE_BUFFER_SIZE);
|
||||
return stream;
|
||||
return new OutSaveFile(stream);
|
||||
}
|
||||
|
||||
Common::InSaveFile *GBAMPSaveFileManager::openForLoading(const Common::String &filename) {
|
||||
|
||||
@@ -106,7 +106,7 @@ public:
|
||||
virtual Common::OutSaveFile *openForSaving(const Common::String &filename, bool compress = true) {
|
||||
OutFRAMSave *s = new OutFRAMSave(filename.c_str());
|
||||
if (!s->err()) {
|
||||
return compress ? Common::wrapCompressedWriteStream(s) : s;
|
||||
return new OutSaveFile(compress ? Common::wrapCompressedWriteStream(s) : s);
|
||||
} else {
|
||||
delete s;
|
||||
return 0;
|
||||
|
||||
@@ -108,7 +108,7 @@ public:
|
||||
virtual Common::OutSaveFile *openForSaving(const Common::String &filename, bool compress = true) {
|
||||
OutPAKSave *s = new OutPAKSave(filename.c_str());
|
||||
if (!s->err()) {
|
||||
return compress ? Common::wrapCompressedWriteStream(s) : s;
|
||||
return new OutSaveFile(compress ? Common::wrapCompressedWriteStream(s) : s);
|
||||
} else {
|
||||
delete s;
|
||||
return NULL;
|
||||
|
||||
@@ -192,7 +192,7 @@ Common::OutSaveFile *Ps2SaveFileManager::openForSaving(const Common::String &fil
|
||||
}
|
||||
|
||||
_screen->wantAnim(false);
|
||||
return compress ? Common::wrapCompressedWriteStream(sf) : sf;
|
||||
return new OutSaveFile(compress ? Common::wrapCompressedWriteStream(sf) : sf);
|
||||
}
|
||||
|
||||
bool Ps2SaveFileManager::removeSavefile(const Common::String &filename) {
|
||||
|
||||
@@ -156,7 +156,7 @@ Common::OutSaveFile *DefaultSaveFileManager::openForSaving(const Common::String
|
||||
|
||||
// Open the file for saving.
|
||||
Common::WriteStream *const sf = fileNode.createWriteStream();
|
||||
Common::OutSaveFile *const result = compress ? Common::wrapCompressedWriteStream(sf) : sf;
|
||||
Common::OutSaveFile *const result = new Common::OutSaveFile(compress ? Common::wrapCompressedWriteStream(sf) : sf);
|
||||
|
||||
// Add file to cache now that it exists.
|
||||
_saveFileCache[filename] = Common::FSNode(fileNode.getPath());
|
||||
|
||||
@@ -23,9 +23,33 @@
|
||||
#include "common/util.h"
|
||||
#include "common/savefile.h"
|
||||
#include "common/str.h"
|
||||
#ifdef USE_CLOUD
|
||||
#include "backends/cloud/cloudmanager.h"
|
||||
#endif
|
||||
|
||||
namespace Common {
|
||||
|
||||
OutSaveFile::OutSaveFile(WriteStream *w): _wrapped(w) {}
|
||||
|
||||
OutSaveFile::~OutSaveFile() {}
|
||||
|
||||
bool OutSaveFile::err() const { return _wrapped->err(); }
|
||||
|
||||
void OutSaveFile::clearErr() { _wrapped->clearErr(); }
|
||||
|
||||
void OutSaveFile::finalize() {
|
||||
_wrapped->finalize();
|
||||
#ifdef USE_CLOUD
|
||||
CloudMan.syncSaves();
|
||||
#endif
|
||||
}
|
||||
|
||||
bool OutSaveFile::flush() { return _wrapped->flush(); }
|
||||
|
||||
uint32 OutSaveFile::write(const void *dataPtr, uint32 dataSize) {
|
||||
return _wrapped->write(dataPtr, dataSize);
|
||||
}
|
||||
|
||||
bool SaveFileManager::copySavefile(const String &oldFilename, const String &newFilename) {
|
||||
InSaveFile *inFile = 0;
|
||||
OutSaveFile *outFile = 0;
|
||||
|
||||
+14
-1
@@ -28,6 +28,7 @@
|
||||
#include "common/stream.h"
|
||||
#include "common/str-array.h"
|
||||
#include "common/error.h"
|
||||
#include "common/ptr.h"
|
||||
|
||||
namespace Common {
|
||||
|
||||
@@ -44,8 +45,20 @@ typedef SeekableReadStream InSaveFile;
|
||||
* That typically means "save games", but also includes things like the
|
||||
* IQ points in Indy3.
|
||||
*/
|
||||
typedef WriteStream OutSaveFile;
|
||||
class OutSaveFile: public WriteStream {
|
||||
protected:
|
||||
ScopedPtr<WriteStream> _wrapped;
|
||||
|
||||
public:
|
||||
OutSaveFile(WriteStream *w);
|
||||
virtual ~OutSaveFile();
|
||||
|
||||
virtual bool err() const;
|
||||
virtual void clearErr();
|
||||
virtual void finalize();
|
||||
virtual bool flush();
|
||||
virtual uint32 write(const void *dataPtr, uint32 dataSize);
|
||||
};
|
||||
|
||||
/**
|
||||
* The SaveFileManager is serving as a factory for InSaveFile
|
||||
|
||||
@@ -328,7 +328,7 @@ Common::Error EoBCoreEngine::saveGameStateIntern(int slot, const char *saveName,
|
||||
fileName = getSavegameFilename(slot);
|
||||
}
|
||||
|
||||
Common::OutSaveFile *out = openSaveForWriting(fileName, saveName, thumbnail);
|
||||
Common::OutSaveFile *out = new Common::OutSaveFile(openSaveForWriting(fileName, saveName, thumbnail));
|
||||
if (!out)
|
||||
return _saveFileMan->getError();
|
||||
|
||||
@@ -995,7 +995,7 @@ bool EoBCoreEngine::saveAsOriginalSaveFile(int slot) {
|
||||
return false;
|
||||
|
||||
Common::FSNode nf = nd.getChild(_flags.gameID == GI_EOB1 ? "EOBDATA.SAV" : Common::String::format("EOBDATA%d.SAV", slot));
|
||||
Common::WriteStream *out = nf.createWriteStream();
|
||||
Common::OutSaveFile *out = new Common::OutSaveFile(nf.createWriteStream());
|
||||
|
||||
if (_flags.gameID == GI_EOB2) {
|
||||
static const char tempStr[20] = "SCUMMVM EXPORT ";
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Kyra {
|
||||
Common::Error KyraEngine_HoF::saveGameStateIntern(int slot, const char *saveName, const Graphics::Surface *thumb) {
|
||||
const char *fileName = getSavegameFilename(slot);
|
||||
|
||||
Common::OutSaveFile *out = openSaveForWriting(fileName, saveName, thumb);
|
||||
Common::OutSaveFile *out = new Common::OutSaveFile(openSaveForWriting(fileName, saveName, thumb));
|
||||
if (!out)
|
||||
return _saveFileMan->getError();
|
||||
|
||||
|
||||
@@ -241,7 +241,7 @@ Common::Error KyraEngine_LoK::saveGameStateIntern(int slot, const char *saveName
|
||||
if (shouldQuit())
|
||||
return Common::kNoError;
|
||||
|
||||
Common::OutSaveFile *out = openSaveForWriting(fileName, saveName, thumb);
|
||||
Common::OutSaveFile *out = new Common::OutSaveFile(openSaveForWriting(fileName, saveName, thumb));
|
||||
if (!out)
|
||||
return _saveFileMan->getError();
|
||||
|
||||
|
||||
@@ -335,7 +335,7 @@ Common::Error LoLEngine::loadGameState(int slot) {
|
||||
Common::Error LoLEngine::saveGameStateIntern(int slot, const char *saveName, const Graphics::Surface *thumbnail) {
|
||||
const char *fileName = getSavegameFilename(slot);
|
||||
|
||||
Common::OutSaveFile *out = openSaveForWriting(fileName, saveName, thumbnail);
|
||||
Common::OutSaveFile *out = new Common::OutSaveFile(openSaveForWriting(fileName, saveName, thumbnail));
|
||||
if (!out)
|
||||
return _saveFileMan->getError();
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace Kyra {
|
||||
Common::Error KyraEngine_MR::saveGameStateIntern(int slot, const char *saveName, const Graphics::Surface *thumb) {
|
||||
const char *fileName = getSavegameFilename(slot);
|
||||
|
||||
Common::OutSaveFile *out = openSaveForWriting(fileName, saveName, thumb);
|
||||
Common::OutSaveFile *out = new Common::OutSaveFile(openSaveForWriting(fileName, saveName, thumb));
|
||||
if (!out)
|
||||
return _saveFileMan->getError();
|
||||
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user