using System.Security.Permissions;
using System.Text;
using System.Runtime.InteropServices;
+using System.Threading;
namespace System {
* of icalls, do not require an increment.
*/
#pragma warning disable 169
- private const int mono_corlib_version = 94;
+ private const int mono_corlib_version = 104;
#pragma warning restore 169
[ComVisible (true)]
ProgramFiles = 0x26,
MyPictures = 0x27,
CommonProgramFiles = 0x2b,
-#if NET_4_0 || MOONLIGHT
+#if NET_4_0 || MOONLIGHT || MOBILE
MyVideos = 0x0e,
#endif
#if NET_4_0
Directory.SetCurrentDirectory (value);
}
}
+
+#if NET_4_5
+ public static int CurrentManagedThreadId {
+ get {
+ return Thread.CurrentThread.ManagedThreadId;
+ }
+ }
+#endif
/// <summary>
/// Gets or sets the exit code of this process
get;
}
+ [MethodImplAttribute (MethodImplOptions.InternalCall)]
+ extern static string GetNewLine ();
+
+ static string nl;
/// <summary>
/// Gets the standard new line value
/// </summary>
- public extern static string NewLine {
- [MethodImplAttribute (MethodImplOptions.InternalCall)]
- get;
+ public static string NewLine {
+ get {
+ if (nl != null)
+ return nl;
+
+ nl = GetNewLine ();
+ return nl;
+ }
}
//
// If value not found, add %FOO to stream,
// and use the closing % for the next iteration.
// If value found, expand it in place of %FOO%
+ int realOldOff2 = off2;
if (value == null) {
result.Append ('%');
result.Append (var);
// If value not found in current iteration, but a % was found for next iteration,
// use text from current closing % to the next %.
else
- textLen = off1 - oldOff2;
+ textLen = off1 - realOldOff2;
if(off1 >= oldOff2 || off1 == -1)
result.Append (name, oldOff2+1, textLen);
} while (off2 > -1 && off2 < len);
return GetFolderPath (folder, SpecialFolderOption.None);
}
#if NET_4_0
- [MonoTODO ("Figure out the folder path for all the new values in SpecialFolder. Use the 'option' argument.")]
public
#endif
static string GetFolderPath(SpecialFolder folder, SpecialFolderOption option)
return ReadXdgUserDir (config, home, "XDG_DESKTOP_DIR", "Desktop");
case SpecialFolder.MyMusic:
- return ReadXdgUserDir (config, home, "XDG_MUSIC_DIR", "Music");
+ if (Platform == PlatformID.MacOSX)
+ return Path.Combine (home, "Music");
+ else
+ return ReadXdgUserDir (config, home, "XDG_MUSIC_DIR", "Music");
case SpecialFolder.MyPictures:
- return ReadXdgUserDir (config, home, "XDG_PICTURES_DIR", "Pictures");
+ if (Platform == PlatformID.MacOSX)
+ return Path.Combine (home, "Pictures");
+ else
+ return ReadXdgUserDir (config, home, "XDG_PICTURES_DIR", "Pictures");
case SpecialFolder.Templates:
return ReadXdgUserDir (config, home, "XDG_TEMPLATES_DIR", "Templates");
-#if NET_4_0 || MOONLIGHT
+#if NET_4_0 || MOONLIGHT || MOBILE
case SpecialFolder.MyVideos:
return ReadXdgUserDir (config, home, "XDG_VIDEOS_DIR", "Videos");
#endif
case SpecialFolder.CommonTemplates:
return "/usr/share/templates";
case SpecialFolder.Fonts:
+ if (Platform == PlatformID.MacOSX)
+ return Path.Combine (home, "Library", "Fonts");
+
return Path.Combine (home, ".fonts");
#endif
// these simply dont exist on Linux
// The spec says if a folder doesnt exist, we
// should return ""
case SpecialFolder.Favorites:
+ if (Platform == PlatformID.MacOSX)
+ return Path.Combine (home, "Library", "Favorites");
+ else
+ return String.Empty;
+
+ case SpecialFolder.ProgramFiles:
+ if (Platform == PlatformID.MacOSX)
+ return "/Applications";
+ else
+ return String.Empty;
+
+ case SpecialFolder.InternetCache:
+ if (Platform == PlatformID.MacOSX)
+ return Path.Combine (home, "Library", "Caches");
+ else
+ return String.Empty;
+
+#if NET_4_0
+ // #2873
+ case SpecialFolder.UserProfile:
+ return home;
+#endif
+
case SpecialFolder.Programs:
case SpecialFolder.SendTo:
case SpecialFolder.StartMenu:
case SpecialFolder.Startup:
case SpecialFolder.Cookies:
case SpecialFolder.History:
- case SpecialFolder.InternetCache:
case SpecialFolder.Recent:
case SpecialFolder.CommonProgramFiles:
- case SpecialFolder.ProgramFiles:
case SpecialFolder.System:
#if NET_4_0
case SpecialFolder.NetworkShortcuts:
case SpecialFolder.CommonDesktopDirectory:
case SpecialFolder.PrinterShortcuts:
case SpecialFolder.Windows:
- case SpecialFolder.UserProfile:
case SpecialFolder.SystemX86:
case SpecialFolder.ProgramFilesX86:
case SpecialFolder.CommonProgramFilesX86:
throw new NotImplementedException ();
}
-#if NET_4_0 || MOONLIGHT
+#if NET_4_0 || MOONLIGHT || MOBILE
[SecurityCritical]
public static void FailFast (string message, Exception exception)
{
return (platform == 4 || platform == 128 || platform == 6);
}
}
+ static internal bool IsMacOS {
+ get {
+ return Environment.Platform == PlatformID.MacOSX;
+ }
+ }
}
}