diff --git a/backends/fs/chroot/chroot-fs-factory.cpp b/backends/fs/chroot/chroot-fs-factory.cpp index 7042a579941..0321b0e31a3 100644 --- a/backends/fs/chroot/chroot-fs-factory.cpp +++ b/backends/fs/chroot/chroot-fs-factory.cpp @@ -74,4 +74,14 @@ void ChRootFilesystemFactory::addVirtualDrive(const Common::String &name, const _virtualDrives[name] = path; } +Common::String ChRootFilesystemFactory::getSystemFullPath(const Common::String& path) const { + size_t driveEnd = path.findFirstOf('/'); + if (driveEnd != Common::String::npos && driveEnd > 0) { + auto it = _virtualDrives.find(path.substr(0, driveEnd)); + if (it != _virtualDrives.end()) + return it->_value + path.substr(driveEnd); + } + return _root + path; +} + #endif diff --git a/backends/fs/chroot/chroot-fs-factory.h b/backends/fs/chroot/chroot-fs-factory.h index a9ad3e1dbae..47d54bce071 100644 --- a/backends/fs/chroot/chroot-fs-factory.h +++ b/backends/fs/chroot/chroot-fs-factory.h @@ -40,6 +40,8 @@ public: void addVirtualDrive(const Common::String &name, const Common::String &path); + Common::String getSystemFullPath(const Common::String& path) const override; + private: const Common::String _root; Common::StringMap _virtualDrives; diff --git a/backends/fs/fs-factory.h b/backends/fs/fs-factory.h index 8a7feee69b3..99434401be9 100644 --- a/backends/fs/fs-factory.h +++ b/backends/fs/fs-factory.h @@ -63,6 +63,15 @@ public: * On Windows, it will be a special node which "contains" all drives (C:, D:, E:). */ virtual AbstractFSNode *makeRootFileNode() const = 0; + + /** + * Returns a path suitable for systen functions such as fopen() for the given ScummVM path, + * + * In most cases the returned path is the same as the given path, but it may be different, for + * example when the application is sandboxed and ScummVM path are relative to the saandbox + * root. + */ + virtual Common::String getSystemFullPath(const Common::String& path) const { return path; } }; #endif /*FILESYSTEM_FACTORY_H*/