[hyena] SafeUri: Replace #if WIN32 with runtime checks
- From: Gabriel Burt <gburt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [hyena] SafeUri: Replace #if WIN32 with runtime checks
- Date: Thu, 28 Apr 2011 16:38:20 +0000 (UTC)
commit 92c69dd8617a329b39a180a6a8c5040097fc9f9c
Author: Gabriel Burt <gabriel burt gmail com>
Date: Wed Apr 27 15:50:41 2011 -0500
SafeUri: Replace #if WIN32 with runtime checks
Hyena.Data.Sqlite/Hyena.Data.Sqlite.csproj | 2 +-
Hyena.Gui/Hyena.Gui.csproj | 2 +-
Hyena/Hyena.csproj | 2 +-
Hyena/Hyena/SafeUri.cs | 22 +++++++++-------------
4 files changed, 12 insertions(+), 16 deletions(-)
---
diff --git a/Hyena.Data.Sqlite/Hyena.Data.Sqlite.csproj b/Hyena.Data.Sqlite/Hyena.Data.Sqlite.csproj
index 626f659..6178684 100644
--- a/Hyena.Data.Sqlite/Hyena.Data.Sqlite.csproj
+++ b/Hyena.Data.Sqlite/Hyena.Data.Sqlite.csproj
@@ -41,7 +41,7 @@
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'SubmoduleWindows|AnyCPU' ">
<OutputPath>..\..\..\bin\bin</OutputPath>
- <DefineConstants>NET_2_0,WIN32</DefineConstants>
+ <DefineConstants>NET_2_0</DefineConstants>
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
diff --git a/Hyena.Gui/Hyena.Gui.csproj b/Hyena.Gui/Hyena.Gui.csproj
index e505058..aaeae83 100644
--- a/Hyena.Gui/Hyena.Gui.csproj
+++ b/Hyena.Gui/Hyena.Gui.csproj
@@ -42,7 +42,7 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'SubmoduleWindows|AnyCPU' ">
- <DefineConstants>NET_2_0,WIN32</DefineConstants>
+ <DefineConstants>NET_2_0</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<OutputPath>..\..\..\bin\bin</OutputPath>
<PlatformTarget>x86</PlatformTarget>
diff --git a/Hyena/Hyena.csproj b/Hyena/Hyena.csproj
index 2f5ca08..9121ecc 100644
--- a/Hyena/Hyena.csproj
+++ b/Hyena/Hyena.csproj
@@ -39,7 +39,7 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'SubmoduleWindows|AnyCPU' ">
- <DefineConstants>NET_2_0,WIN32</DefineConstants>
+ <DefineConstants>NET_2_0</DefineConstants>
<OutputPath>..\..\..\bin\bin</OutputPath>
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
diff --git a/Hyena/Hyena/SafeUri.cs b/Hyena/Hyena/SafeUri.cs
index c63ef5f..04535e3 100644
--- a/Hyena/Hyena/SafeUri.cs
+++ b/Hyena/Hyena/SafeUri.cs
@@ -75,11 +75,10 @@ namespace Hyena
// TODO: replace with managed conversion to avoid marshalling
IntPtr path_ptr = GLib.Marshaller.StringToPtrGStrdup (localPath);
-#if WIN32
- IntPtr uri_ptr = g_filename_to_uri_utf8 (path_ptr, IntPtr.Zero, IntPtr.Zero);
-#else
- IntPtr uri_ptr = g_filename_to_uri (path_ptr, IntPtr.Zero, IntPtr.Zero);
-#endif
+ IntPtr uri_ptr = PlatformDetection.IsWindows
+ ? g_filename_to_uri_utf8 (path_ptr, IntPtr.Zero, IntPtr.Zero)
+ : g_filename_to_uri (path_ptr, IntPtr.Zero, IntPtr.Zero);
+
GLib.Marshaller.Free (path_ptr);
if (uri_ptr == IntPtr.Zero) {
@@ -96,11 +95,10 @@ namespace Hyena
{
// TODO: replace with managed conversion to avoid marshalling
IntPtr uri_ptr = GLib.Marshaller.StringToPtrGStrdup (uri);
-#if WIN32
- IntPtr path_ptr = g_filename_from_uri_utf8 (uri_ptr, IntPtr.Zero, IntPtr.Zero);
-#else
- IntPtr path_ptr = g_filename_from_uri (uri_ptr, IntPtr.Zero, IntPtr.Zero);
-#endif
+
+ IntPtr path_ptr = PlatformDetection.IsWindows
+ ? g_filename_from_uri_utf8 (uri_ptr, IntPtr.Zero, IntPtr.Zero)
+ : g_filename_from_uri (uri_ptr, IntPtr.Zero, IntPtr.Zero);
GLib.Marshaller.Free (uri_ptr);
@@ -192,18 +190,16 @@ namespace Hyena
get { return Scheme == System.Uri.UriSchemeFile; }
}
-#if WIN32
[DllImport ("libglib-2.0-0.dll")]
private static extern IntPtr g_filename_to_uri_utf8 (IntPtr filename, IntPtr hostname, IntPtr error);
[DllImport ("libglib-2.0-0.dll")]
private static extern IntPtr g_filename_from_uri_utf8 (IntPtr uri, IntPtr hostname, IntPtr error);
-#else
+
[DllImport ("libglib-2.0-0.dll")]
private static extern IntPtr g_filename_to_uri (IntPtr filename, IntPtr hostname, IntPtr error);
[DllImport ("libglib-2.0-0.dll")]
private static extern IntPtr g_filename_from_uri (IntPtr uri, IntPtr hostname, IntPtr error);
-#endif
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]