ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

Common::SaveFileManager Class Reference

The SaveFileManager is serving as a factory for InSaveFile and OutSaveFile objects. More...

#include <savefile.h>

Inheritance diagram for Common::SaveFileManager:
Collaboration diagram for Common::SaveFileManager:

List of all members.

Public Member Functions

virtual ~SaveFileManager ()
virtual void clearError ()
 Clears the last set error code and string.
virtual Error getError ()
 Returns the last occurred error code.
virtual String getErrorDesc ()
 Returns the last occurred error description.
virtual String popErrorDesc ()
 Returns the last occurred error description.
virtual OutSaveFileopenForSaving (const String &name, bool compress=true)=0
 Open the savefile with the specified name in the given directory for saving.
virtual InSaveFileopenForLoading (const String &name)=0
 Open the file with the specified name in the given directory for loading.
virtual InSaveFileopenRawFile (const String &name)=0
 Open the file with the specified name in the given directory for loading.
virtual bool removeSavefile (const String &name)=0
 Removes the given savefile from the system.
virtual bool renameSavefile (const String &oldName, const String &newName)
 Renames the given savefile.
virtual bool copySavefile (const String &oldName, const String &newName)
 Copy the given savefile.
virtual StringArray listSavefiles (const String &pattern)=0
 List available savegames matching a given pattern.
virtual void updateSavefilesList (StringArray &lockedFiles)=0
 Refreshes the save files list (because some new files could've been added) and remembers the "locked" files list.

Protected Member Functions

virtual void setError (Error error, const String &errorDesc)
 Set some information about the last error which occurred .

Protected Attributes

Error _error
String _errorDesc

Detailed Description

The SaveFileManager is serving as a factory for InSaveFile and OutSaveFile objects.

Engines and other code should use SaveFiles whenever they need to store data which they need to be able to retrieve again later on -- i.e. typically save states, but also configuration files and similar things.

Savefile names represent SaveFiles. These names are case insensitive, that means a name of "Kq1.000" represents the same savefile as "kq1.000". In addition, SaveFileManager does not allow for names which contain path separators like '/' or '\'. This is because we do not support directories in SaveFileManager.

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

Definition at line 82 of file savefile.h.


Constructor & Destructor Documentation

virtual Common::SaveFileManager::~SaveFileManager (  )  [inline, virtual]

Definition at line 96 of file savefile.h.


Member Function Documentation

virtual void Common::SaveFileManager::clearError (  )  [inline, virtual]

Clears the last set error code and string.

Definition at line 101 of file savefile.h.

bool Common::SaveFileManager::copySavefile ( const String oldName,
const String newName 
) [virtual]

Copy the given savefile.

Parameters:
oldName Old name.
newName New name.
Returns:
true if no error occurred. false otherwise.

Definition at line 59 of file savefile.cpp.

virtual Error Common::SaveFileManager::getError (  )  [inline, virtual]

Returns the last occurred error code.

If none occurred, returns kNoError.

Returns:
A value indicating the type of the last error.

Definition at line 108 of file savefile.h.

virtual String Common::SaveFileManager::getErrorDesc (  )  [inline, virtual]

Returns the last occurred error description.

If none occurred, returns 0.

Returns:
A string describing the last error.

Definition at line 115 of file savefile.h.

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

List available savegames matching a given pattern.

Our pattern format is based on DOS paterns, also known as "glob" in the POSIX world. Please refer to the Common::matchString() function to learn about the precise pattern format.

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

Implemented in DefaultSaveFileManager.

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

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

Parameters:
name The name of the savefile.
Returns:
Pointer to an InSaveFile, or NULL if an error occurred.

Implemented in DefaultSaveFileManager, and RecorderSaveFileManager.

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

Open the savefile 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 if 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 won't be supported by ScummVM.

Parameters:
name The name of the savefile.
compress Toggles whether to compress the resulting save file (default) or not.
Returns:
Pointer to an OutSaveFile, or NULL if an error occurred.

Implemented in DefaultSaveFileManager.

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 raw file instead of unpacked.

Parameters:
name The name of the savefile.
Returns:
Pointer to an InSaveFile, or NULL if an error occurred.

Implemented in DefaultSaveFileManager.

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

Returns the last occurred error description.

If none occurred, returns 0. Also clears the last error state and description.

Returns:
A string describing the last error.

Definition at line 104 of file savefile.cpp.

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

Removes the given savefile from the system.

Parameters:
name The name of the savefile to be removed.
Returns:
true if no error occurred, false otherwise.

Implemented in DefaultSaveFileManager.

bool Common::SaveFileManager::renameSavefile ( const String oldName,
const String newName 
) [virtual]

Renames the given savefile.

Parameters:
oldName Old name.
newName New name.
Returns:
true if no error occurred. false otherwise.

Definition at line 97 of file savefile.cpp.

virtual void Common::SaveFileManager::setError ( Error  error,
const String errorDesc 
) [inline, protected, virtual]

Set some information about the last error which occurred .

Parameters:
error Code identifying the last error.
errorDesc String describing the last error.

Definition at line 93 of file savefile.h.

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

Refreshes the save files list (because some new files could've been added) and remembers the "locked" files list.

These files could not be used for saving or loading because they are being synced by CloudManager.

Implemented in DefaultSaveFileManager.


Member Data Documentation

Definition at line 85 of file savefile.h.

Definition at line 86 of file savefile.h.


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


Generated on Sat Sep 14 2019 05:04:06 for ResidualVM by doxygen 1.7.1
curved edge   curved edge