2007-05-30 21:56:52 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
2006-06-24 10:08:43 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2014-02-18 02:34:18 +01:00
|
|
|
*
|
2006-06-24 10:08:43 +00:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2014-02-18 02:34:18 +01:00
|
|
|
*
|
2006-06-24 10:08:43 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2007-03-16 23:07:08 +00:00
|
|
|
#if !defined(BACKEND_SAVES_DEFAULT_H) && !defined(DISABLE_DEFAULT_SAVEFILEMANAGER)
|
2006-06-24 10:08:43 +00:00
|
|
|
#define BACKEND_SAVES_DEFAULT_H
|
|
|
|
|
2008-11-03 10:45:59 +00:00
|
|
|
#include "common/scummsys.h"
|
2006-06-24 10:08:43 +00:00
|
|
|
#include "common/savefile.h"
|
2007-07-12 17:58:15 +00:00
|
|
|
#include "common/str.h"
|
2008-09-02 13:05:43 +00:00
|
|
|
#include "common/fs.h"
|
2016-06-18 19:35:57 +06:00
|
|
|
#include "common/hash-str.h"
|
|
|
|
#include <limits.h>
|
2006-06-24 10:08:43 +00:00
|
|
|
|
2007-12-28 07:37:04 +00:00
|
|
|
/**
|
|
|
|
* Provides a default savefile manager implementation for common platforms.
|
|
|
|
*/
|
2006-06-24 10:08:43 +00:00
|
|
|
class DefaultSaveFileManager : public Common::SaveFileManager {
|
|
|
|
public:
|
2008-08-04 17:17:37 +00:00
|
|
|
DefaultSaveFileManager();
|
2008-08-04 19:38:28 +00:00
|
|
|
DefaultSaveFileManager(const Common::String &defaultSavepath);
|
2008-08-04 17:17:37 +00:00
|
|
|
|
2016-06-05 22:26:51 +06:00
|
|
|
virtual void updateSavefilesList(Common::StringArray &lockedFiles);
|
2010-03-18 15:44:59 +00:00
|
|
|
virtual Common::StringArray listSavefiles(const Common::String &pattern);
|
2016-05-30 20:28:09 +06:00
|
|
|
virtual Common::InSaveFile *openRawFile(const Common::String &filename);
|
2009-05-29 14:38:22 +00:00
|
|
|
virtual Common::InSaveFile *openForLoading(const Common::String &filename);
|
2012-05-21 21:21:48 +03:00
|
|
|
virtual Common::OutSaveFile *openForSaving(const Common::String &filename, bool compress = true);
|
2009-05-29 14:38:22 +00:00
|
|
|
virtual bool removeSavefile(const Common::String &filename);
|
2007-12-28 07:37:04 +00:00
|
|
|
|
2016-07-05 15:05:30 +06:00
|
|
|
#ifdef USE_LIBCURL
|
2016-06-18 19:35:57 +06:00
|
|
|
|
|
|
|
static const uint32 INVALID_TIMESTAMP = UINT_MAX;
|
|
|
|
static const char *TIMESTAMPS_FILENAME;
|
|
|
|
|
|
|
|
static Common::HashMap<Common::String, uint32> loadTimestamps();
|
|
|
|
static void saveTimestamps(Common::HashMap<Common::String, uint32> ×tamps);
|
|
|
|
#endif
|
|
|
|
|
2019-04-02 16:53:56 +01:00
|
|
|
static Common::String concatWithSavesPath(Common::String name);
|
|
|
|
|
2007-12-28 07:37:04 +00:00
|
|
|
protected:
|
|
|
|
/**
|
|
|
|
* Get the path to the savegame directory.
|
|
|
|
* Should only be used internally since some platforms
|
|
|
|
* might implement savefiles in a completely different way.
|
|
|
|
*/
|
2007-12-28 21:12:30 +00:00
|
|
|
virtual Common::String getSavePath() const;
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2007-12-28 07:37:04 +00:00
|
|
|
/**
|
|
|
|
* Checks the given path for read access, existence, etc.
|
|
|
|
* Sets the internal error and error message accordingly.
|
|
|
|
*/
|
2008-11-03 10:45:59 +00:00
|
|
|
virtual void checkPath(const Common::FSNode &dir);
|
2016-02-25 18:33:33 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Assure that the given save path is cached.
|
|
|
|
*
|
|
|
|
* @param savePathName String representation of save path to cache.
|
|
|
|
*/
|
|
|
|
void assureCached(const Common::String &savePathName);
|
|
|
|
|
|
|
|
typedef Common::HashMap<Common::String, Common::FSNode, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> SaveFileCache;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
SaveFileCache _saveFileCache;
|
|
|
|
|
2016-06-05 22:26:51 +06:00
|
|
|
/**
|
|
|
|
* List of "locked" files. These cannot be used for saving/loading
|
|
|
|
* because CloudManager is downloading those.
|
|
|
|
*/
|
|
|
|
Common::StringArray _lockedFiles;
|
|
|
|
|
2016-02-25 18:33:33 +01:00
|
|
|
private:
|
|
|
|
/**
|
|
|
|
* The currently cached directory.
|
|
|
|
*/
|
|
|
|
Common::String _cachedDirectory;
|
2006-06-24 10:08:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|