Re: Cong VFS

"nshmyrev" <[email protected]>
Newsgroups gmane.editors.conglomerate.devel
Message-ID <[email protected]>
>Forgot to attach the the changes I've made so far.
>
>On Wed, 2004-10-20 at 11:06 +0100, Jeff Martin wrote:
>> I've been fiddling again trying to get conglomerate to work with webdav.
>> In theory this should just work but, it don't.
>> 
>> In cong-vfs.c there's a couple of lines which convert relative uri to to
>> absolute by adding file:// to the front. This however knackers things
>> starting http://. So I took these lines out. Relative uri still work
>> fine so I'm not quite sure why these lines where there (may be an old
>> bug work around?) 

Thanks a lot. It seems like a garbage from old code. This code needs even more cleaning. I 
think, we should document internal usage of URI, and doesn't operate on filenames. The attached
 patch cleans something, but there should be more changes towards clean structure of that part of code.

>> 
>> The problem I have now is gnome_vfs_read  returning zero bytes read in
>> cong_vfs_read_bytes. I've run a packet sniff and the document is begin
>> returned fine from the web server, but never makes it out of
>> gnome_vfs_read.
>> 
>> Can anyone shed some light on things?

Seems like gnome-vfs-error, what is the returned result of gnome_vfs_read?
a.diff (application/octet-stream, 3.1 KB)
Index: cong-vfs.c
===================================================================
RCS file: /cvs/gnome/conglomerate/src/cong-vfs.c,v
retrieving revision 1.6
diff -u -r1.6 cong-vfs.c
--- cong-vfs.c	25 Jun 2004 00:33:03 -0000	1.6
+++ cong-vfs.c	20 Oct 2004 14:55:13 -0000
@@ -54,20 +54,19 @@
 	return vfs_result;
 }
 
-/* 
-   A routine that tries to syncronously load a file into a buffer in memory (surely this exists already somewhere?)
-*/
 /**
  * cong_vfs_new_buffer_from_file:
- * @filename:
+ * @uri_string: string represening VFS uri
  * @buffer:
  * @size:
  *
- * TODO: Write me
+ * A routine that tries to syncronously load a file into a buffer in memory (surely this exists already somewhere?)
+ * (I believe that CVS gnome-vfs has a routine gnome_vfs_read_entire_file that does this)
+ *
  * Returns:
  */
 GnomeVFSResult
-cong_vfs_new_buffer_from_file (const char* filename, 
+cong_vfs_new_buffer_from_file (const char* uri_string, 
 			       char** buffer, 
 			       GnomeVFSFileSize* size)
 {
@@ -78,20 +77,7 @@
 	g_return_val_if_fail(buffer,GNOME_VFS_ERROR_BAD_PARAMETERS);
 	g_return_val_if_fail(size,GNOME_VFS_ERROR_BAD_PARAMETERS);
 
-	/* it seems that GnomeVFS works with absolute paths, so
-	   if the filename is not absolute, build it.
-	   GnomeVFS URIs are absolute. */
-	   
-	if (!g_path_is_absolute (filename) && !(g_str_has_prefix (filename, "file:"))) {
-
-		gchar *absolute_path = g_strconcat (g_get_current_dir(), GNOME_VFS_URI_PATH_STR, filename, NULL);
-    		uri = gnome_vfs_uri_new (absolute_path);
-		g_free (absolute_path);
-
-	} else {
-
-		uri = gnome_vfs_uri_new (filename);
-	}
+	uri = gnome_vfs_uri_new (string_uri);
 
 	vfs_result = cong_vfs_new_buffer_from_uri(uri, buffer, size);
 
@@ -253,7 +239,6 @@
 #else
 	/* Load using GnomeVFS: */
 	{
-		GnomeVFSURI* vfs_uri = gnome_vfs_uri_new (string_uri);
 		char* buffer;
 		GnomeVFSFileSize size;
 		GnomeVFSResult vfs_result = cong_vfs_new_buffer_from_file (string_uri, 
@@ -266,8 +251,6 @@
 			cong_error_dialog_run(GTK_DIALOG(dialog));
 			gtk_widget_destroy(GTK_WIDGET(dialog));
 
-			gnome_vfs_uri_unref (vfs_uri);
-			
 			return NULL;
 		}
 		
@@ -279,8 +262,6 @@
 						string_uri, 
 						parent_window);
 		g_free(buffer);
-
-		gnome_vfs_uri_unref (vfs_uri);
 
 		return xml_doc;
 	}
Index: cong-vfs.h
===================================================================
RCS file: /cvs/gnome/conglomerate/src/cong-vfs.h,v
retrieving revision 1.3
diff -u -r1.3 cong-vfs.h
--- cong-vfs.h	25 Jun 2004 00:33:03 -0000	1.3
+++ cong-vfs.h	20 Oct 2004 14:57:01 -0000
@@ -29,21 +29,8 @@
 
 G_BEGIN_DECLS
 
-/* Handy utility functions: */
-
-/**
- * cong_vfs_new_buffer_from_file
- * @filename:
- * @buffer:
- * @size:
- * 
- * A routine that tries to syncronously load a file into a buffer in memory (surely this exists already somewhere?)
- * (I believe that CVS gnome-vfs has a routine gnome_vfs_read_entire_file that does this)
- * 
- * Returns:
- */
 GnomeVFSResult
-cong_vfs_new_buffer_from_file (const char* filename, 
+cong_vfs_new_buffer_from_file (const char* string_uri, 
 			       char** buffer, 
 			       GnomeVFSFileSize* size);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.