[Mono-bugs] [Bug 50532][Min] New - Environment.SpecialFolders paths

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Thu, 5 Feb 2004 10:26:17 -0500 (EST)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by spouliot@videotron.ca.

http://bugzilla.ximian.com/show_bug.cgi?id=50532

--- shadow/50532	2004-02-05 10:26:17.000000000 -0500
+++ shadow/50532.tmp.24898	2004-02-05 10:26:17.000000000 -0500
@@ -0,0 +1,258 @@
+Bug#: 50532
+Product: Mono/Class Libraries
+Version: unspecified
+OS: unknown
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: Unknown
+Priority: Minor
+Component: CORLIB
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: jluke@cfl.rr.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Environment.SpecialFolders paths
+
+Please fill in this template when reporting a bug, unless you know what you
+are doing.
+Description of Problem:
+
+Environment.GetFolderPath (Environment.SpecialFolder) should return values
+consistent with http://pdx.freedesktop.org/Standards/basedir-spec and have
+sane values for those that do not match up well. Currently we return the
+users home directly or nothing for many of these values.
+
+------- Additional Comments From jluke@cfl.rr.com  2003-11-03 19:54 -------
+Created an attachment (id=5855)
+test program
+
+
+------- Additional Comments From jluke@cfl.rr.com  2003-11-03 19:54 -------
+Created an attachment (id=5856)
+mono's current output
+
+
+------- Additional Comments From jluke@cfl.rr.com  2003-11-03 19:56 -------
+Created an attachment (id=5857)
+patch for Environment.SpecialFolder.ApplicationData
+
+
+------- Additional Comments From dick@ximian.com  2003-11-04 07:48 -------
+Mono isn't limited to desktop environments.  The ".local/share" part
+should not be unconditionally returned.
+
+
+------- Additional Comments From jluke@cfl.rr.com  2003-11-04 16:09 -------
+I know it isn't limited to desktop environments, but I am unaware of
+any other specification that deals with the paths of generic
+directories.  I would be perfectly happy using a more accurate one, if
+it exists.  In the absence of one, I see no harm in following this one.
+
+"The ".local/share" part should not be unconditionally returned."
+By this do you mean that it should create the directory if it does not
+exist before returning the path?  I'm not sure that helps, because the
+user of this method will still need to try/catch before performing any
+actions with it anyways.  But I can change it to do so if this is what
+you mean.
+
+------- Additional Comments From dick@ximian.com  2003-11-04 18:20 -------
+Returning a directory that doesn't exist would be bad, yes.
+
+But the part about unconditionally returning the freedesktop fallback
+is that in !desktop situations I think $HOME would be a better choice.
+
+
+------- Additional Comments From miguel@ximian.com  2003-11-04 18:27 -------
+Well, FreeDesktop happens to have come up with the idea, but I dont
+think the idea is limited to desktop systems.  It is just a convention
+to stop the clutter in $HOME.
+
+I think we should apply this.  The only question is of course, making
+sure that the directory exists, but I think thta can be handled by the
+caller.
+
+Miguel
+
+------- Additional Comments From bmaurer@users.sf.net  2003-11-05 09:34 -------
+Well, in MS the contract is that the folder that is returned *always* 
+exists. IMHO we should keep the contract on Mono. How much of a pref 
+issue would checking be? We could do something like:
+
+static bool checkedAppDataExist = false;
+
+static string GetAppDataFolder () {
+    string folder;
+    // get the string in folder
+    if (!checkedAppDataExist && !Directory.Exists (folder) {
+        // create folder
+    }
+    checkedAppDataExist = true;
+}
+
+Let's also make sure each and every SpecialFolder returns a nice 
+path, I remember we had problems with this in Monodoc.
+
+------- Additional Comments From jluke@cfl.rr.com  2003-12-05 20:00 -------
+Created an attachment (id=6128)
+updated patch
+
+
+------- Additional Comments From jluke@cfl.rr.com  2003-12-05 20:02 -------
+updated patch to return $HOME by default, and create the directory
+if it does not exist.  It would be nice if we could return something
+other than $HOME for more of these, but I'm not sure.
+
+------- Additional Comments From spouliot@videotron.ca  2004-02-05 10:26 -------
+This patch won't work under Windows because HOME isn't defined by
+default (except in cygwin). Note that current code doesn't work either
+(because Path.Combine doesn't like the null it receive for HOME).
+
+The following code should get a home directory on both Linux and Windows.
+
+private static string GetHomeDirectory () 
+{
+	// will work in Linux / cygwin
+	string path = Environment.GetEnvironmentVariable ("HOME");
+	// but not on Windows
+	if ((path == null) || (path == String.Empty)) {
+		path = Environment.GetEnvironmentVariable ("USERPROFILE");
+		if ((path == null) || (path == String.Empty)) {
+			// NOTE: No Path.Combine required here (normal)
+			path += Environment.GetEnvironmentVariable ("HOMEDRIVE");
+			path += Environment.GetEnvironmentVariable ("HOMEPATH");
+		}
+	}
+	return path;
+}
+
+
+Also applications running on Windows, either on Mono or MS runtime,
+will expect to receive the same path - so we'll have some
+globalization issues to deal with.
+
+Here's the return values for GetFolderPath on WinXP SP 1 (English) and
+how they relate to the available environment variables.
+
+
+ApplicationData
+C:\Documents and Settings\spouliot\Application Data
+%APPDATA%
+
+CommonApplicationData
+C:\Documents and Settings\All Users\Application Data
+%ALLUSERSPROFILE%\"Application Data"
+
+CommonProgramFiles
+C:\Program Files\Common Files
+%CommonProgramFiles%
+
+Cookies
+C:\Documents and Settings\spouliot\Cookies
+%HOMEDRIVE%%HOMEPATH%\Cookies
+or
+%USERPROFILE%\Cookies
+
+Desktop
+C:\Documents and Settings\spouliot\Desktop
+%HOMEDRIVE%%HOMEPATH%\Desktop
+or
+%USERPROFILE%\Desktop
+
+DesktopDirectory
+C:\Documents and Settings\spouliot\Desktop
+%HOMEDRIVE%%HOMEPATH%\Desktop
+or
+%USERPROFILE%\Desktop
+
+Favorites
+C:\Documents and Settings\spouliot\Favorites
+%HOMEDRIVE%%HOMEPATH%\Favorites
+or
+%USERPROFILE%\Favorites
+
+History
+C:\Documents and Settings\spouliot\Local Settings\History
+%HOMEDRIVE%%HOMEPATH%\Local Settings\History
+or
+%USERPROFILE%\Local Settings\History
+
+InternetCache
+C:\Documents and Settings\spouliot\Local Settings\Temporary Internet Files
+%HOMEDRIVE%%HOMEPATH%\Local Settings\Temporary Internet Files
+or
+%USERPROFILE%\Local Settings\Temporary Internet Files
+
+LocalApplicationData
+C:\Documents and Settings\spouliot\Local Settings\Application Data
+%HOMEDRIVE%%HOMEPATH%\Local Settings\Application Data
+or
+%USERPROFILE%\Local Settings\Application Data
+
+MyComputer
+
+
+MyMusic
+C:\Documents and Settings\spouliot\My Documents\My Music
+%HOMEDRIVE%%HOMEPATH%\My Documents\My Music
+or
+%USERPROFILE%\My Documents\My Music
+
+MyPictures
+C:\Documents and Settings\spouliot\My Documents\My Pictures
+%HOMEDRIVE%%HOMEPATH%\My Documents\My Pictures
+or
+%USERPROFILE%\My Documents\My Pictures
+
+Personal
+C:\Documents and Settings\spouliot\My Documents
+%HOMEDRIVE%%HOMEPATH%\My Documents
+or
+%USERPROFILE%\My Documents
+
+ProgramFiles
+C:\Program Files
+%ProgramFiles%
+
+Programs
+C:\Documents and Settings\spouliot\Start Menu\Programs
+%HOMEDRIVE%%HOMEPATH%\Start Menu\Programs
+or
+%USERPROFILE%\Start Menu\Programs
+
+Recent
+C:\Documents and Settings\spouliot\Recent
+%HOMEDRIVE%%HOMEPATH%\Recent
+or
+%USERPROFILE%\Recent
+
+SendTo
+C:\Documents and Settings\spouliot\SendTo
+%HOMEDRIVE%%HOMEPATH%\SendTo
+or
+%USERPROFILE%\SendTo
+
+StartMenu
+C:\Documents and Settings\spouliot\Start Menu
+%HOMEDRIVE%%HOMEPATH%\Start Menu
+or
+%USERPROFILE%\Start Menu
+
+Startup
+C:\Documents and Settings\spouliot\Start Menu\Programs\Startup
+%HOMEDRIVE%%HOMEPATH%\Start Menu\Programs\Startup
+or
+%USERPROFILE%\Start Menu\Programs\Startup
+
+System
+C:\WINDOWS\System32
+%SystemRoot%\System32
+
+Templates
+C:\Documents and Settings\spouliot\Templates
+%HOMEDRIVE%%HOMEPATH%\Templates
+or
+%USERPROFILE%\Templates
+