[Scummvm-cvs-logs] SF.net SVN: scummvm: [29797] scummvm/trunk

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Sun Dec 9 18:28:30 CET 2007


Revision: 29797
          http://scummvm.svn.sourceforge.net/scummvm/?rev=29797&view=rev
Author:   fingolfin
Date:     2007-12-09 09:28:29 -0800 (Sun, 09 Dec 2007)

Log Message:
-----------
Expand ~/ to the HOME env var (see also patch #1846545)

Modified Paths:
--------------
    scummvm/trunk/NEWS
    scummvm/trunk/backends/fs/posix/posix-fs.cpp

Modified: scummvm/trunk/NEWS
===================================================================
--- scummvm/trunk/NEWS	2007-12-09 15:43:08 UTC (rev 29796)
+++ scummvm/trunk/NEWS	2007-12-09 17:28:29 UTC (rev 29797)
@@ -26,6 +26,8 @@
    - 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)

Modified: scummvm/trunk/backends/fs/posix/posix-fs.cpp
===================================================================
--- scummvm/trunk/backends/fs/posix/posix-fs.cpp	2007-12-09 15:43:08 UTC (rev 29796)
+++ scummvm/trunk/backends/fs/posix/posix-fs.cpp	2007-12-09 17:28:29 UTC (rev 29797)
@@ -143,7 +143,19 @@
 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) {


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list