[gnomemm] gnome-vfsmm patch



I fixed gnome-vfsmm so that my little program works with it. The problem was that gnome_vfs_file_info_new was not called on some FileInfo objects. I also fixed Gnome::Vfs::Uri so that it throws the correct exceptions on failure.

I have not looked much at the c++-wrappers before, so I might have done something wrong. Is it safe to just do a gnome_vfs_file_info_new and then Glib::Wrap it afterwards? This will not lead to leaks?

                                                  Per Kristian
Index: libgnomevfs/libgnomevfsmm/handle.cc
===================================================================
RCS file: /cvs/gnome/gnomemm/gnome-vfsmm/libgnomevfs/libgnomevfsmm/handle.cc,v
retrieving revision 1.1
diff -u -u -r1.1 handle.cc
--- libgnomevfs/libgnomevfsmm/handle.cc	23 Mar 2003 13:10:54 -0000	1.1
+++ libgnomevfs/libgnomevfsmm/handle.cc	27 Apr 2003 13:15:32 -0000
@@ -107,7 +107,7 @@
 //static:
 Glib::RefPtr<FileInfo> Handle::get_file_info(const Glib::ustring& text_uri, GnomeVFSFileInfoOptions options) throw(exception)
 {
-  GnomeVFSFileInfo* file_info = 0;
+  GnomeVFSFileInfo* file_info = gnome_vfs_file_info_new();
   GnomeVFSResult result = gnome_vfs_get_file_info(text_uri.c_str(), file_info, options);
   handle_result(result);
   return Glib::wrap(file_info);
@@ -115,7 +115,7 @@
 
 Glib::RefPtr<FileInfo> Handle::get_file_info(GnomeVFSFileInfoOptions options) const throw(exception)
 {
-  GnomeVFSFileInfo* file_info = 0;
+  GnomeVFSFileInfo* file_info = gnome_vfs_file_info_new();
   GnomeVFSResult result = gnome_vfs_get_file_info_from_handle(const_cast<GnomeVFSHandle*>(gobj()), file_info, options);
   handle_result(result);
   return Glib::wrap(file_info);
Index: libgnomevfs/src/uri.ccg
===================================================================
RCS file: /cvs/gnome/gnomemm/gnome-vfsmm/libgnomevfs/src/uri.ccg,v
retrieving revision 1.2
diff -u -u -r1.2 uri.ccg
--- libgnomevfs/src/uri.ccg	23 Mar 2003 13:10:55 -0000	1.2
+++ libgnomevfs/src/uri.ccg	27 Apr 2003 13:15:32 -0000
@@ -54,48 +54,55 @@
 Glib::RefPtr<Uri> Uri::create(const Glib::ustring& uri)
 {
   // See the comment at the top of this file, if you want to know why the cast works.
+  
   return Glib::RefPtr<Uri>(reinterpret_cast<Uri*>(gnome_vfs_uri_new(uri.c_str())));
 }
 
 Glib::RefPtr<FileInfo> Uri::get_file_info(GnomeVFSFileInfoOptions options) const throw(exception)
 {
-  //TODO: All these methods needs to handle the result and throw exceptions, like in handle.cc. murrayc.
-  GnomeVFSFileInfo* file_info = 0;
+  GnomeVFSFileInfo* file_info = gnome_vfs_file_info_new();
   GnomeVFSResult result = gnome_vfs_get_file_info_uri(const_cast<GnomeVFSURI*>(gobj()), file_info, options);
+  handle_result(result);
   return Glib::wrap(file_info);
 }
 
 void Uri::truncate(GnomeVFSFileSize length) throw(exception)
 {
   GnomeVFSResult result = gnome_vfs_truncate_uri(gobj(), length);
+  handle_result(result);
 }
 
 
 void Uri::make_directory(guint perm) throw(exception)
 {
   GnomeVFSResult result = gnome_vfs_make_directory_for_uri(gobj(), perm);
+  handle_result(result);
 }
 
 
 void Uri::remove_directory() throw(exception)
 {
   GnomeVFSResult result = gnome_vfs_remove_directory_from_uri(gobj());
+  handle_result(result);
 }
 
 
 void Uri::unlink() throw(exception)
 {
   GnomeVFSResult result = gnome_vfs_unlink_from_uri(gobj());
+  handle_result(result);
 }
 
 void Uri::create_symbolic_link(const Glib::ustring& target_reference) throw(exception)
 {
   GnomeVFSResult result = gnome_vfs_create_symbolic_link(gobj(), target_reference.c_str());
+  handle_result(result);
 }
 
 void Uri::move(const Glib::RefPtr<const Uri>& new_uri, bool force_replace) throw(exception)
 {
   GnomeVFSResult result = gnome_vfs_move_uri(gobj(), const_cast<GnomeVFSURI*>(new_uri->gobj()), force_replace);
+  handle_result(result);
 }
 
 bool Uri::check_same_fs(const Glib::RefPtr<const Uri>& target_uri) const throw(exception)
@@ -113,9 +120,14 @@
 void Uri::set_file_info(const Glib::RefPtr<const FileInfo>& info, GnomeVFSSetFileInfoMask mask) throw(exception)
 {
   GnomeVFSResult result = gnome_vfs_set_file_info_uri(gobj(), const_cast<GnomeVFSFileInfo*>(info->gobj()), mask);
+  handle_result(result);
 }
 
-
+void Uri::handle_result(GnomeVFSResult result) throw(exception) 
+{
+  if(result != GNOME_VFS_OK)
+    throw(exception(result));
+}
 
 } //namespace Vfs
 
Index: libgnomevfs/src/uri.hg
===================================================================
RCS file: /cvs/gnome/gnomemm/gnome-vfsmm/libgnomevfs/src/uri.hg,v
retrieving revision 1.3
diff -u -u -r1.3 uri.hg
--- libgnomevfs/src/uri.hg	29 Mar 2003 10:11:13 -0000	1.3
+++ libgnomevfs/src/uri.hg	27 Apr 2003 13:15:32 -0000
@@ -120,6 +120,8 @@
   bool check_same_fs(const Glib::RefPtr<const Uri>& target_uri) const throw(exception);
   bool uri_exists() const throw(exception);
   void set_file_info(const Glib::RefPtr<const FileInfo>& info, GnomeVFSSetFileInfoMask mask) throw(exception);
+protected:
+  static void handle_result(GnomeVFSResult result) throw(exception);
 };
 
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]