2004-11-01 Jeroen Zwartepoorte <jeroen@xs4all.nl>

* gnomevfs/Directory.cs: New Create and Delete methods. Free the
	FileInfo List returned by gnome_vfs_directory_list_load.
	* gnomevfs/FileInfo.cs: Copy the FileInfoNative struct so the original
	can be properly freed.
	* gnomevfs/Vfs.cs: Move MakeDirectory and RemoveDirectory to Directory.

svn path=/trunk/gtk-sharp/; revision=35535
This commit is contained in:
Jeroen Zwartepoorte 2004-11-01 21:00:09 +00:00
parent cdfc01223a
commit c551f4c479
4 changed files with 45 additions and 34 deletions

View File

@ -1,3 +1,11 @@
2004-11-01 Jeroen Zwartepoorte <jeroen@xs4all.nl>
* gnomevfs/Directory.cs: New Create and Delete methods. Free the
FileInfo List returned by gnome_vfs_directory_list_load.
* gnomevfs/FileInfo.cs: Copy the FileInfoNative struct so the original
can be properly freed.
* gnomevfs/Vfs.cs: Move MakeDirectory and RemoveDirectory to Directory.
2004-11-01 Jeroen Zwartepoorte <jeroen@xs4all.nl> 2004-11-01 Jeroen Zwartepoorte <jeroen@xs4all.nl>
* gnomevfs/Directory.cs: Bind gnome_vfs_directory_list_load as a static * gnomevfs/Directory.cs: Bind gnome_vfs_directory_list_load as a static

View File

@ -13,9 +13,6 @@ using System.Runtime.InteropServices;
namespace Gnome.Vfs { namespace Gnome.Vfs {
public class Directory { public class Directory {
[DllImport ("gnomevfs-2")]
private static extern Result gnome_vfs_directory_list_load (out IntPtr list, string uri, FileInfoOptions options);
public static FileInfo[] GetEntries (Uri uri) public static FileInfo[] GetEntries (Uri uri)
{ {
return GetEntries (uri.ToString ()); return GetEntries (uri.ToString ());
@ -31,6 +28,12 @@ namespace Gnome.Vfs {
return GetEntries (text_uri, FileInfoOptions.Default); return GetEntries (text_uri, FileInfoOptions.Default);
} }
[DllImport ("gnomevfs-2")]
private static extern Result gnome_vfs_directory_list_load (out IntPtr list, string uri, FileInfoOptions options);
[DllImport ("gnomevfs-2")]
private static extern void gnome_vfs_file_info_list_free (IntPtr list);
public static FileInfo[] GetEntries (string text_uri, FileInfoOptions options) public static FileInfo[] GetEntries (string text_uri, FileInfoOptions options)
{ {
IntPtr raw_ret; IntPtr raw_ret;
@ -41,8 +44,35 @@ namespace Gnome.Vfs {
FileInfo[] entries = new FileInfo [list.Count]; FileInfo[] entries = new FileInfo [list.Count];
for (int i = 0; i < list.Count; i++) for (int i = 0; i < list.Count; i++)
entries[i] = new FileInfo ((FileInfo.FileInfoNative) list [i]); entries[i] = new FileInfo ((FileInfo.FileInfoNative) list [i]);
gnome_vfs_file_info_list_free (raw_ret);
return entries; return entries;
} }
[DllImport ("gnomevfs-2")]
private static extern Result gnome_vfs_make_directory (string uri, uint perm);
public static Result Create (Uri uri, uint perm)
{
return Create (uri.ToString (), perm);
}
public static Result Create (string uri, uint perm)
{
return gnome_vfs_make_directory (uri, perm);
}
[DllImport ("gnomevfs-2")]
private static extern Result gnome_vfs_remove_directory (string uri);
public static Result Delete (Uri uri)
{
return Delete (uri.ToString ());
}
public static Result Delete (string uri)
{
return gnome_vfs_remove_directory (uri);
}
} }
} }

View File

@ -41,22 +41,19 @@ namespace Gnome.Vfs {
} }
private FileInfoNative info; private FileInfoNative info;
private Uri uri;
private FileInfoOptions options;
[DllImport ("gnomevfs-2")] [DllImport ("gnomevfs-2")]
extern static FileInfoNative gnome_vfs_file_info_new (); extern static FileInfoNative gnome_vfs_file_info_new ();
[DllImport ("gnomevfs-2")] [DllImport ("gnomevfs-2")]
private static extern Result gnome_vfs_get_file_info_uri (IntPtr uri, ref FileInfoNative info, FileInfoOptions options); extern static void gnome_vfs_file_info_copy (ref FileInfoNative dest, ref FileInfoNative src);
[DllImport ("gnomevfs-2")] [DllImport ("gnomevfs-2")]
extern static void gnome_vfs_file_info_unref (ref FileInfoNative info); private static extern Result gnome_vfs_get_file_info_uri (IntPtr uri, ref FileInfoNative info, FileInfoOptions options);
internal FileInfo (FileInfoNative info) internal FileInfo (FileInfoNative info)
{ {
this.info = info; gnome_vfs_file_info_copy (ref this.info, ref info);
uri = null;
} }
public FileInfo (string uri) : this (uri, FileInfoOptions.Default) {} public FileInfo (string uri) : this (uri, FileInfoOptions.Default) {}
@ -67,14 +64,12 @@ namespace Gnome.Vfs {
public FileInfo (Uri uri, FileInfoOptions options) public FileInfo (Uri uri, FileInfoOptions options)
{ {
this.uri = uri;
this.options = options;
info = gnome_vfs_file_info_new (); info = gnome_vfs_file_info_new ();
Result result = gnome_vfs_get_file_info_uri (uri.Handle, ref info, options); Result result = gnome_vfs_get_file_info_uri (uri.Handle, ref info, options);
Vfs.ThrowException (uri, result); Vfs.ThrowException (uri, result);
} }
public string Name { public string Name {
get { get {
if (info.name != IntPtr.Zero) if (info.name != IntPtr.Zero)
@ -265,12 +260,6 @@ namespace Gnome.Vfs {
} }
} }
public void Update ()
{
Result result = gnome_vfs_get_file_info_uri (uri.Handle, ref info, options);
Vfs.ThrowException (uri, result);
}
public override String ToString () public override String ToString ()
{ {
string result = "Name = " + Name + "\n" + string result = "Name = " + Name + "\n" +

View File

@ -58,22 +58,6 @@ namespace Gnome.Vfs {
return gnome_vfs_move (old_uri, new_uri, force_replace); return gnome_vfs_move (old_uri, new_uri, force_replace);
} }
[DllImport ("gnomevfs-2")]
private static extern Result gnome_vfs_make_directory (string uri, uint perm);
public static Result MakeDirectory (string uri, uint perm)
{
return gnome_vfs_make_directory (uri, perm);
}
[DllImport ("gnomevfs-2")]
private static extern Result gnome_vfs_remove_directory (string uri);
public static Result RemoveDirectory (string uri)
{
return gnome_vfs_remove_directory (uri);
}
[DllImport ("gnomevfs-2")] [DllImport ("gnomevfs-2")]
private static extern Result gnome_vfs_unlink (string uri); private static extern Result gnome_vfs_unlink (string uri);