From 87818fe63ac851e89513c2fe49c9646d64566b31 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Fri, 29 Jul 2016 09:59:06 +0200 Subject: POSIX: Add $SNAP to search path if available. This allows ScummVM to find data files while running in a snap (e.g. from the new Ubuntu store). --- backends/platform/sdl/posix/posix.cpp | 16 ++++++++++++++++ backends/platform/sdl/posix/posix.h | 2 ++ 2 files changed, 18 insertions(+) (limited to 'backends/platform/sdl/posix') diff --git a/backends/platform/sdl/posix/posix.cpp b/backends/platform/sdl/posix/posix.cpp index e2a642b288..016a9d44f8 100644 --- a/backends/platform/sdl/posix/posix.cpp +++ b/backends/platform/sdl/posix/posix.cpp @@ -141,6 +141,22 @@ Common::String OSystem_POSIX::getDefaultConfigFileName() { return configFile; } +void OSystem_POSIX::addSysArchivesToSearchSet(Common::SearchSet &s, int priority) { + const char *snap = getenv("SNAP"); + if (snap) { + Common::String dataPath = Common::String(snap) + DATA_PATH; + Common::FSNode dataNode(dataPath); + if (dataNode.exists() && dataNode.isDirectory()) { + // This is the same priority which is used for the data path (below), + // but we insert this one first, so it will be searched first. + s.add(dataPath, new Common::FSDirectory(dataNode, 4), priority); + } + } + + // For now, we always add the data path, just in case SNAP doesn't make sense. + OSystem_SDL::addSysArchivesToSearchSet(s, priority); +} + Common::WriteStream *OSystem_POSIX::createLogFile() { // Start out by resetting _logFilePath, so that in case // of a failure, we know that no log file is open. diff --git a/backends/platform/sdl/posix/posix.h b/backends/platform/sdl/posix/posix.h index 0514d30191..050463c273 100644 --- a/backends/platform/sdl/posix/posix.h +++ b/backends/platform/sdl/posix/posix.h @@ -38,6 +38,8 @@ public: virtual void init(); virtual void initBackend(); + virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0); + protected: /** * Base string for creating the default path and filename for the -- cgit v1.2.3