ScummVM API documentation
DefaultSaveFileManager Class Reference

#include <default-saves.h>

Inheritance diagram for DefaultSaveFileManager:
Common::SaveFileManager Common::NonCopyable KolibriOSSaveFileManager RecorderSaveFileManager WindowsSaveFileManager

Public Member Functions

 DefaultSaveFileManager (const Common::Path &defaultSavepath)
 
void updateSavefilesList (Common::StringArray &lockedFiles) override
 
Common::StringArray listSavefiles (const Common::String &pattern) override
 
Common::InSaveFileopenRawFile (const Common::String &filename) override
 
Common::InSaveFileopenForLoading (const Common::String &filename) override
 
Common::OutSaveFileopenForSaving (const Common::String &filename, bool compress=true) override
 
bool removeSavefile (const Common::String &filename) override
 
bool exists (const Common::String &filename) override
 
- Public Member Functions inherited from Common::SaveFileManager
virtual void clearError ()
 
virtual Error getError ()
 
virtual String getErrorDesc ()
 
virtual String popErrorDesc ()
 
virtual bool renameSavefile (const String &oldName, const String &newName, bool compress=true)
 
virtual bool copySavefile (const String &oldName, const String &newName, bool compress=true)
 

Static Public Member Functions

static Common::Path concatWithSavesPath (Common::String name)
 

Protected Types

typedef Common::HashMap< Common::String, Common::FSNode, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualToSaveFileCache
 

Protected Member Functions

virtual Common::Path getSavePath () const
 
virtual void checkPath (const Common::FSNode &dir)
 
virtual Common::ErrorCode removeFile (const Common::FSNode &fileNode)
 
void assureCached (const Common::Path &savePathName)
 
- Protected Member Functions inherited from Common::SaveFileManager
virtual void setError (Error error, const String &errorDesc)
 

Protected Attributes

SaveFileCache _saveFileCache
 
Common::StringArray _lockedFiles
 
- Protected Attributes inherited from Common::SaveFileManager
Error _error
 
String _errorDesc
 

Detailed Description

Provides a default savefile manager implementation for common platforms.

Member Function Documentation

◆ updateSavefilesList()

void DefaultSaveFileManager::updateSavefilesList ( Common::StringArray lockedFiles)
overridevirtual

Refresh the save files list (because some new files might have been added) and remember the "locked" files list. These files cannot be used for saving or loading because they are being synced by CloudManager.

Implements Common::SaveFileManager.

◆ listSavefiles()

Common::StringArray DefaultSaveFileManager::listSavefiles ( const Common::String pattern)
overridevirtual

List available save files matching a given pattern.

The pattern format is based on DOS patterns, also known as "glob" in the POSIX world. Refer to the Common::matchString() function for information about the precise pattern format.

Parameters
patternPattern to match. Wildcards like * or ? are allowed.
Returns
List of strings for all present file names.
See also
Common::matchString()

Implements Common::SaveFileManager.

◆ openRawFile()

Common::InSaveFile* DefaultSaveFileManager::openRawFile ( const Common::String name)
overridevirtual

Open the file with the specified name in the given directory for loading. In contrast to openForLoading(), it returns a raw file instead of unpacked.

Parameters
nameName of the save file.
Returns
Pointer to an InSaveFile, or NULL if an error occurred.

Implements Common::SaveFileManager.

◆ openForLoading()

Common::InSaveFile* DefaultSaveFileManager::openForLoading ( const Common::String name)
overridevirtual

Open the file with the specified name in the given directory for loading.

Parameters
nameName of the save file.
Returns
Pointer to an InSaveFile, or NULL if an error occurred.

Implements Common::SaveFileManager.

◆ openForSaving()

Common::OutSaveFile* DefaultSaveFileManager::openForSaving ( const Common::String name,
bool  compress = true 
)
overridevirtual

Open the save file with the specified name in the given directory for saving.

Saved games are compressed by default, and engines are expected to always write compressed saves.

A notable exception is when uncompressed files are needed for compatibility with games not supported by ScummVM, such as character exports from the Quest for Glory series. QfG5 is a 3D game and will not be supported by ScummVM.

Parameters
nameName of the save file.
compressWhether to compress the resulting save file (default) or not.
Returns
Pointer to an OutSaveFile, or NULL if an error occurred.

Implements Common::SaveFileManager.

◆ removeSavefile()

bool DefaultSaveFileManager::removeSavefile ( const Common::String name)
overridevirtual

Remove the given save file from the system.

Parameters
nameName of the save file to be removed.
Returns
True if no error occurred, false otherwise.

Implements Common::SaveFileManager.

◆ exists()

bool DefaultSaveFileManager::exists ( const Common::String name)
overridevirtual

Checks if the savefile exists.

Parameters
nameName of the save file.
Returns
true if the file exists. false otherwise.

Implements Common::SaveFileManager.

◆ getSavePath()

virtual Common::Path DefaultSaveFileManager::getSavePath ( ) const
protectedvirtual

Get the path to the savegame directory. Should only be used internally since some platforms might implement savefiles in a completely different way.

◆ checkPath()

virtual void DefaultSaveFileManager::checkPath ( const Common::FSNode dir)
protectedvirtual

Checks the given path for read access, existence, etc. Sets the internal error and error message accordingly.

◆ removeFile()

virtual Common::ErrorCode DefaultSaveFileManager::removeFile ( const Common::FSNode fileNode)
protectedvirtual

Removes the given file. This is called from removeSavefile() with the full file path.

Reimplemented in WindowsSaveFileManager.

◆ assureCached()

void DefaultSaveFileManager::assureCached ( const Common::Path savePathName)
protected

Assure that the given save path is cached.

Parameters
savePathNameString representation of save path to cache.

Member Data Documentation

◆ _saveFileCache

SaveFileCache DefaultSaveFileManager::_saveFileCache
protected

Cache of all the save files in the currently cached directory.

Modify with caution because we only re-cache when the save path changed! This needs to be updated inside at least openForSaving and removeSavefile.

◆ _lockedFiles

Common::StringArray DefaultSaveFileManager::_lockedFiles
protected

List of "locked" files. These cannot be used for saving/loading because CloudManager is downloading those.


The documentation for this class was generated from the following file: