internal static string InternalGetFolderPath (SpecialFolder folder)
{
string home = internalGetHome ();
// http://freedesktop.org/Standards/basedir-spec/basedir-spec-0.6.html
// note: skip security check for environment variables
string data = internalGetEnvironmentVariable ("XDG_DATA_HOME");
if ((data == null) || (data == String.Empty)) {
data = Path.Combine (home, ".local");
data = Path.Combine (data, "share");
}
// note: skip security check for environment variables
string config = internalGetEnvironmentVariable ("XDG_CONFIG_HOME");
if ((config == null) || (config == String.Empty)) {
config = Path.Combine (home, ".config");
}
switch (folder) {
#if NET_1_1
// MyComputer is a virtual directory
case SpecialFolder.MyComputer:
return String.Empty;
#endif
// personal == ~
case SpecialFolder.Personal:
#if MONOTOUCH
return Path.Combine (home, "Documents");
#else
return home;
#endif
// use FDO's CONFIG_HOME. This data will be synced across a network like the windows counterpart.
case SpecialFolder.ApplicationData:
#if MONOTOUCH
{
string dir = Path.Combine (Path.Combine (home, "Documents"), ".config");
if (!Directory.Exists (dir))
Directory.CreateDirectory (dir);
return dir;
}
#else
return config;
#endif
//use FDO's DATA_HOME. This is *NOT* synced
case SpecialFolder.LocalApplicationData:
#if MONOTOUCH
{
string dir = Path.Combine (home, "Documents");
if (!Directory.Exists (dir))
Directory.CreateDirectory (dir);
return dir;
}
#else
return data;
#endif
#if NET_1_1
case SpecialFolder.Desktop:
#endif
case SpecialFolder.DesktopDirectory:
return ReadXdgUserDir (config, home, "XDG_DESKTOP_DIR", "Desktop");
case SpecialFolder.MyMusic:
return ReadXdgUserDir (config, home, "XDG_MUSIC_DIR", "Music");
case SpecialFolder.MyPictures:
return ReadXdgUserDir (config, home, "XDG_PICTURES_DIR", "Pictures");
// these simply dont exist on Linux
// The spec says if a folder doesnt exist, we
// should return ""
case SpecialFolder.Favorites:
case SpecialFolder.Programs:
case SpecialFolder.SendTo:
case SpecialFolder.StartMenu:
case SpecialFolder.Startup:
case SpecialFolder.Templates:
case SpecialFolder.Cookies:
case SpecialFolder.History:
case SpecialFolder.InternetCache:
case SpecialFolder.Recent:
case SpecialFolder.CommonProgramFiles:
case SpecialFolder.ProgramFiles:
case SpecialFolder.System:
return String.Empty;
// This is where data common to all users goes
case SpecialFolder.CommonApplicationData:
return "/usr/share";
default:
throw new ArgumentException ("Invalid SpecialFolder");
}
}