1 //
2 // FileFactory.cs
3 //
4 // Author(s):
5 //	Stephane Delcroix  <stephane@delcroix.org>
6 //
7 // Copyright (c) 2008 Stephane Delcroix
8 //
9 // This program is free software; you can redistribute it and/or
10 // modify it under the terms of version 2 of the Lesser GNU General
11 // Public License as published by the Free Software Foundation.
12 //
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 // Lesser General Public License for more details.
17 //
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this program; if not, write to the
20 // Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 // Boston, MA 02111-1307, USA.
22 
23 using System;
24 using System.Runtime.InteropServices;
25 
26 namespace GLib
27 {
28 	public class FileFactory
29 	{
30 		[DllImport ("libgio-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
g_file_new_for_uri(string uri)31 		private static extern IntPtr g_file_new_for_uri (string uri);
32 
NewForUri(string uri)33 		public static IFile NewForUri (string uri)
34 		{
35 			return GLib.FileAdapter.GetObject (g_file_new_for_uri (uri), false) as IFile;
36 		}
37 
NewForUri(Uri uri)38 		public static IFile NewForUri (Uri uri)
39 		{
40 			return GLib.FileAdapter.GetObject (g_file_new_for_uri (uri.ToString ()), false) as IFile;
41 		}
42 
43 		[DllImport ("libgio-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
g_file_new_for_path(string path)44 		private static extern IntPtr g_file_new_for_path (string path);
45 
NewForPath(string path)46 		public static IFile NewForPath (string path)
47 		{
48 			return GLib.FileAdapter.GetObject (g_file_new_for_path (path), false) as IFile;
49 		}
50 
51 		[DllImport ("libgio-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
g_file_new_for_commandline_arg(string arg)52 		private static extern IntPtr g_file_new_for_commandline_arg (string arg);
53 
NewFromCommandlineArg(string arg)54 		public static IFile NewFromCommandlineArg (string arg)
55 		{
56 			return GLib.FileAdapter.GetObject (g_file_new_for_commandline_arg (arg), false) as IFile;
57 		}
58 	}
59 }
60