2007-08-06 Aaron Bockover <abockover@novell.com>
authorAaron Bockover <abockover@novell.com>
Mon, 6 Aug 2007 21:16:01 +0000 (21:16 -0000)
committerAaron Bockover <abockover@novell.com>
Mon, 6 Aug 2007 21:16:01 +0000 (21:16 -0000)
    * Environment.cs (ReadXdgUserDir): Support the changes to the
    xdg-user-dirs spec that allow /home/aaron to start the path; also allows
    for quotes surrounding the path (Patch ported from Banshee,
    BGO #461596)

svn path=/trunk/mcs/; revision=83557

mcs/class/corlib/System/ChangeLog
mcs/class/corlib/System/Environment.cs

index 5b87bde0d7b7e8b67ee7e87a5aa3e3e135a07560..81cc245a30f62403d2fe99eb45e6b77944c7b6db 100644 (file)
@@ -1,3 +1,10 @@
+2007-08-06  Aaron Bockover  <abockover@novell.com>
+
+       * Environment.cs (ReadXdgUserDir): Support the changes to the
+       xdg-user-dirs spec that allow $HOME to start the path; also allows
+       for quotes surrounding the path (Patch ported from Banshee,
+       BGO #461596)
+
 2007-07-28  Miguel de Icaza  <miguel@novell.com>
 
        * MulticastDelegate.cs (Equals): do not cast to avoid exceptions,
index edbb85aa11268cb16fbc0435f48868eaaf2570d0..3efee9ccfc38d132fa308ef6d7ae04c132a0e347 100644 (file)
@@ -457,9 +457,19 @@ namespace System {
                                        while ((line = reader.ReadLine ()) != null) {
                                                line = line.Trim ();
                                                int delim_index = line.IndexOf ('=');
-                                               if (delim_index > 8 && line.Substring (0, delim_index) == key) {
-                                                       return Path.Combine (home_dir, line.Substring (delim_index + 1));
-                                               }
+                        if(delim_index > 8 && line.Substring (0, delim_index) == key) {
+                            string path = line.Substring (delim_index + 1).Trim ('"');
+                            bool relative = false;
+
+                            if (path.StartsWith ("$HOME/")) {
+                                relative = true;
+                                path = path.Substring (6);
+                            } else if (!path.StartsWith ("/")) {
+                                relative = true;
+                            }
+
+                            return relative ? Path.Combine (home_dir, path) : path;
+                        }
                                        }
                                }
                        } catch (FileNotFoundException) {