GtkSharp/gnomevfs/Uri.custom
Mike Kestner 463618c958 2005-06-08 Mike Kestner <mkestner@novell.com>
* generator/SimpleBase.cs : off-by-one in namespace join.
	* glib/ListBase.cs : support IntPtr element_type.
	* gnomevfs/FileInfo.cs : make it ManualGen friendly.
	* gnomevfs/*.cs : rework for FileInfo api changes.
	* gnomevfs/Gnomevfs.metadata : make FileInfo a manual symbol.
	* gnomevfs/Uri.custom : rework for FileInfo api changes.
	* gnome/Makefile.am : add gnomevfs dependency to pick up some more api
	symbols.
	* gnome/gnome-sharp-2.0.pc.in : advertise the vfs dep.
	[Fixes #71060]

svn path=/trunk/gtk-sharp/; revision=45702
2005-06-09 14:27:48 +00:00

133 lines
3.8 KiB
Plaintext

// Uri.custom - Uri class customizations.
//
// Authors: Jeroen Zwartepoorte <jeroen@xs4all.nl>
//
// Copyright (c) 2004 Jeroen Zwartepoorte
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
public MimeType MimeType {
get {
return new MimeType (this);
}
}
[DllImport("gnomevfs-2")]
static extern Result gnome_vfs_get_volume_free_space (IntPtr raw, out long size);
public long VolumeFreeSpace {
get {
long size = 0L;
Result result = gnome_vfs_get_volume_free_space (Handle, out size);
Vfs.ThrowException (this, result);
return size;
}
}
public FileInfo GetFileInfo ()
{
return GetFileInfo (FileInfoOptions.Default);
}
public FileInfo GetFileInfo (FileInfoOptions options)
{
return new FileInfo (this, options);
}
[DllImport("gnomevfs-2")]
static extern Result gnome_vfs_set_file_info_uri (IntPtr raw, IntPtr info, SetFileInfoMask mask);
public Result SetFileInfo (FileInfo info, SetFileInfoMask mask)
{
return gnome_vfs_set_file_info_uri (Handle, info.Handle, mask);
}
[DllImport("gnomevfs-2")]
static extern bool gnome_vfs_uri_equal(IntPtr raw, IntPtr b);
public override bool Equals (object o) {
if (o is Uri) {
Uri uri = o as Uri;
return gnome_vfs_uri_equal (Handle, uri.Handle);
} else {
return false;
}
}
[DllImport("gnomevfs-2")]
static extern uint gnome_vfs_uri_hash(IntPtr p);
public override int GetHashCode () {
return checked ((int)gnome_vfs_uri_hash (Handle));
}
public override string ToString ()
{
return ToString (UriHideOptions.None);
}
[DllImport ("gnomevfs-2")]
private static extern Result gnome_vfs_truncate_uri (IntPtr raw, ulong length);
public Result Truncate (ulong length)
{
return gnome_vfs_truncate_uri (Handle, length);
}
[DllImport ("gnomevfs-2")]
private static extern Result gnome_vfs_unlink_from_uri (IntPtr raw);
public Result Unlink ()
{
return gnome_vfs_unlink_from_uri (Handle);
}
[DllImport("gnomevfs-2")]
static extern IntPtr gnome_vfs_get_local_path_from_uri (IntPtr uri);
public static string GetLocalPathFromUri (string uri)
{
IntPtr native = GLib.Marshaller.StringToPtrGStrdup (uri);
IntPtr result = gnome_vfs_get_local_path_from_uri (native);
GLib.Marshaller.Free (native);
return GLib.Marshaller.PtrToStringGFree (result);
}
[DllImport("gnomevfs-2")]
static extern IntPtr gnome_vfs_get_uri_from_local_path (IntPtr path);
public static string GetUriFromLocalPath (string path)
{
IntPtr native = GLib.Marshaller.StringToPtrGStrdup (path);
IntPtr result = gnome_vfs_get_uri_from_local_path (native);
GLib.Marshaller.Free (native);
return GLib.Marshaller.PtrToStringGFree (result);
}
[DllImport("gnomevfs-2")]
static extern IntPtr gnome_vfs_uri_list_parse(IntPtr uri_list);
public static Uri[] ParseList (string uri_list) {
IntPtr native = GLib.Marshaller.StringToPtrGStrdup (uri_list);
IntPtr raw_ret = gnome_vfs_uri_list_parse(native);
GLib.Marshaller.Free (native);
GLib.List list = new GLib.List(raw_ret);
Uri[] uris = new Uri [list.Count];
for (int i = 0; i < list.Count; i++)
uris[i] = list[i] as Uri;
list.Dispose ();
return uris;
}