GOB: allow more path separators in "file path -> save handler" mapping

'/' and ':' are now supported in addition to Window-style '\'
This commit is contained in:
Simon Delamarre 2022-11-28 22:44:13 +01:00 committed by Eugene Sandulenko
parent bf652277aa
commit a71b1c9e94
No known key found for this signature in database
GPG Key ID: 014D387312D34F08
3 changed files with 773 additions and 759 deletions

View File

@ -33,14 +33,25 @@ SaveLoad::SaveLoad(GobEngine *vm) : _vm(vm) {
SaveLoad::~SaveLoad() {
}
const char *SaveLoad::stripPath(const char *fileName) {
const char *SaveLoad::stripPath(const char *fileName, char separator) {
const char *backSlash;
if ((backSlash = strrchr(fileName, '\\')))
if ((backSlash = strrchr(fileName, separator)))
return backSlash + 1;
return fileName;
}
Common::String SaveLoad::replacePathSeparators(const char *path, char newSeparator) {
Common::String result = path;
for (char &c : result) {
if (c != newSeparator && (c == '\\' || c == '/' || c == ':'))
c = newSeparator;
}
return result;
}
Common::List<Common::String> SaveLoad::getFilesMatchingPattern(const char *pattern) const {
warning("SaveLoad::getFilesMatchingPattern not implemented");
return Common::List<Common::String>();

View File

@ -48,7 +48,10 @@ public:
virtual ~SaveLoad();
/** "foo\bar\quux.bla" => "quux.bla". */
static const char *stripPath(const char *fileName);
static const char *stripPath(const char *fileName, char separator = '\\');
/** Changes all file separator characters (/,:,\) in path to newSeparator */
static Common::String replacePathSeparators(const char *path, char newSeparator);
/** Returns how to handle that file. */
virtual SaveMode getSaveMode(const char *fileName) const;

File diff suppressed because it is too large Load Diff