aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2007-12-09 17:28:29 +0000
committerMax Horn2007-12-09 17:28:29 +0000
commit66a1c085c0bf09f9e42cc68e7514ecf1197f62c8 (patch)
treee91979e720890ea5a1718b7d8d89875d5b09c82a
parentc84d9c1588ec3c7531dd4c0146369e6b35e5c059 (diff)
downloadscummvm-rg350-66a1c085c0bf09f9e42cc68e7514ecf1197f62c8.tar.gz
scummvm-rg350-66a1c085c0bf09f9e42cc68e7514ecf1197f62c8.tar.bz2
scummvm-rg350-66a1c085c0bf09f9e42cc68e7514ecf1197f62c8.zip
Expand ~/ to the HOME env var (see also patch #1846545)
svn-id: r29797
-rw-r--r--NEWS2
-rw-r--r--backends/fs/posix/posix-fs.cpp14
2 files changed, 15 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index 7087a31afd..a26ebfb523 100644
--- a/NEWS
+++ b/NEWS
@@ -26,6 +26,8 @@ For a more comprehensive changelog for the latest experimental SVN code, see:
- Improved detection of new game variants and localized versions.
- Completely reworked internal access to files. (GSoC Task)
- Added option to delete games from the list with Del key.
+ - Added support for "~/" prefix being substituted by $HOME in paths
+ on POSIX systems (Linux, Mac OS X etc.).
AGI:
- Added support for AGI256 and AGI256-2 hacks (GSoC Task)
diff --git a/backends/fs/posix/posix-fs.cpp b/backends/fs/posix/posix-fs.cpp
index 8d455b99e3..436e0908dd 100644
--- a/backends/fs/posix/posix-fs.cpp
+++ b/backends/fs/posix/posix-fs.cpp
@@ -143,7 +143,19 @@ POSIXFilesystemNode::POSIXFilesystemNode() {
POSIXFilesystemNode::POSIXFilesystemNode(const String &p, bool verify) {
assert(p.size() > 0);
- _path = p;
+ // Expand "~/" to the value of the HOME env variable
+ if (p.hasPrefix("~/")) {
+ const char *home = getenv("HOME");
+ if (home != NULL && strlen(home) < MAXPATHLEN) {
+ _path = home;
+ // Skip over the tilda. We know that p contains at least
+ // two chars, so this is safe:
+ _path += p.c_str() + 1;
+ }
+ } else {
+ _path = p;
+ }
+
_displayName = lastPathComponent(_path);
if (verify) {