aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/sdl/posix
diff options
context:
space:
mode:
authorAlyssa Milburn2016-07-29 09:59:06 +0200
committerAlyssa Milburn2016-07-29 11:45:14 +0200
commit87818fe63ac851e89513c2fe49c9646d64566b31 (patch)
treebb2bf714695600e97e84e25ee09a36642144ed80 /backends/platform/sdl/posix
parent823c2f899b480a1fa494b08e1471142129293779 (diff)
downloadscummvm-rg350-87818fe63ac851e89513c2fe49c9646d64566b31.tar.gz
scummvm-rg350-87818fe63ac851e89513c2fe49c9646d64566b31.tar.bz2
scummvm-rg350-87818fe63ac851e89513c2fe49c9646d64566b31.zip
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).
Diffstat (limited to 'backends/platform/sdl/posix')
-rw-r--r--backends/platform/sdl/posix/posix.cpp16
-rw-r--r--backends/platform/sdl/posix/posix.h2
2 files changed, 18 insertions, 0 deletions
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