ScummVM API documentation
Common::SaveFileManager Class Referenceabstract

#include <savefile.h>

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

Public Member Functions

virtual void clearError ()
 
virtual Error getError ()
 
virtual String getErrorDesc ()
 
virtual String popErrorDesc ()
 
virtual OutSaveFileopenForSaving (const String &name, bool compress=true)=0
 
virtual InSaveFileopenForLoading (const String &name)=0
 
virtual InSaveFileopenRawFile (const String &name)=0
 
virtual bool removeSavefile (const String &name)=0
 
virtual bool renameSavefile (const String &oldName, const String &newName, bool compress=true)
 
virtual bool copySavefile (const String &oldName, const String &newName, bool compress=true)
 
virtual StringArray listSavefiles (const String &pattern)=0
 
virtual void updateSavefilesList (StringArray &lockedFiles)=0
 
virtual bool exists (const String &name)=0
 

Protected Member Functions

virtual void setError (Error error, const String &errorDesc)
 

Protected Attributes

Error _error
 
String _errorDesc
 

Detailed Description

The SaveFileManager serves as a factory for InSaveFile and OutSaveFile objects.

Engines and other code should use SaveFiles whenever they need to store data that they need to retrieve again later on – i.e. typically save states, but also configuration files and similar objects.

Save file names represent SaveFiles. These names are case insensitive. That means a name of "Kq1.000" represents the same save file as "kq1.000". In addition, SaveFileManager does not allow for names that contain path separators like '/' or '\'. This is because directories are not supported in SaveFileManager.

While not declared as a singleton, it is effectively used as such, with OSystem::getSavefileManager returning a pointer to single SaveFileManager instances to be used.

Member Function Documentation

◆ setError()

virtual void Common::SaveFileManager::setError ( Error  error,
const String errorDesc 
)
inlineprotectedvirtual

Set some information about the last error that occurred.

Parameters
errorCode identifying the last error.
errorDescString describing the last error.

◆ clearError()

virtual void Common::SaveFileManager::clearError ( )
inlinevirtual

Clear the last set error code and string.

◆ getError()

virtual Error Common::SaveFileManager::getError ( )
inlinevirtual

Return the last occurred error code. If none occurred, return kNoError.

Returns
A value indicating the type of the last error.

◆ getErrorDesc()

virtual String Common::SaveFileManager::getErrorDesc ( )
inlinevirtual

Return the last occurred error description. If none occurred, return 0.

Returns
A string describing the last error.

◆ popErrorDesc()

virtual String Common::SaveFileManager::popErrorDesc ( )
virtual

Return the last occurred error description. If none occurred, return 0. Also, clear the last error state and description.

Returns
A string describing the last error.

◆ openForSaving()

virtual OutSaveFile* Common::SaveFileManager::openForSaving ( const String name,
bool  compress = true 
)
pure virtual

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.

Implemented in PAKSaveManager, FRAMSaveManager, and DefaultSaveFileManager.

◆ openForLoading()

virtual InSaveFile* Common::SaveFileManager::openForLoading ( const String name)
pure virtual

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.

Implemented in PAKSaveManager, FRAMSaveManager, and DefaultSaveFileManager.

◆ openRawFile()

virtual InSaveFile* Common::SaveFileManager::openRawFile ( const String name)
pure virtual

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.

Implemented in PAKSaveManager, FRAMSaveManager, and DefaultSaveFileManager.

◆ removeSavefile()

virtual bool Common::SaveFileManager::removeSavefile ( const String name)
pure virtual

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.

Implemented in PAKSaveManager, FRAMSaveManager, and DefaultSaveFileManager.

◆ renameSavefile()

virtual bool Common::SaveFileManager::renameSavefile ( const String oldName,
const String newName,
bool  compress = true 
)
virtual

Rename the given save file.

Parameters
oldNameOld name.
newNameNew name.
compressWhether to compress the resulting save file (default) or not.
Returns
True if no error occurred, false otherwise.

◆ copySavefile()

virtual bool Common::SaveFileManager::copySavefile ( const String oldName,
const String newName,
bool  compress = true 
)
virtual

Copy the given save file.

Parameters
oldNameOld name.
newNameNew name.
compressWhether to compress the resulting save file (default) or not.
Returns
true if no error occurred. false otherwise.

◆ listSavefiles()

virtual StringArray Common::SaveFileManager::listSavefiles ( const String pattern)
pure virtual

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()

Implemented in PAKSaveManager, FRAMSaveManager, and DefaultSaveFileManager.

◆ updateSavefilesList()

virtual void Common::SaveFileManager::updateSavefilesList ( StringArray lockedFiles)
pure virtual

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.

Implemented in PAKSaveManager, FRAMSaveManager, and DefaultSaveFileManager.

◆ exists()

virtual bool Common::SaveFileManager::exists ( const String name)
pure virtual

Checks if the savefile exists.

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

Implemented in PAKSaveManager, FRAMSaveManager, and DefaultSaveFileManager.

Member Data Documentation

◆ _error

Error Common::SaveFileManager::_error
protected

Error code.

◆ _errorDesc

String Common::SaveFileManager::_errorDesc
protected

Description of an error.


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