documentation patch



Hi @all,

because Christian ask me to send my path for review to the maillinglist,
I'll do this now. You can also have a look at bugzilla id: 318753 :-)

Regards,

waffel
Index: about.sgml
===================================================================
RCS file: /cvs/gnome/gnome-vfs/doc/about.sgml,v
retrieving revision 1.8
diff -u -r1.8 about.sgml
--- about.sgml	15 May 2004 17:15:34 -0000	1.8
+++ about.sgml	13 Oct 2005 12:07:06 -0000
@@ -106,9 +106,19 @@
       <para>
 	Now lets write a simple program to copy a fixed number of bytes from one file and append
 	it to another file.
+  </para>
+  <para>To use this program you need to supply a GnomeVFS URI as the input and 
+  output filenames.  If you like to use local files, such an URI would look like 
+  <function>file:///path/to/your/file</function>.
+  </para>
+  <para>The URI for local files must be given as an absolute path. You have to 
+  check in your program if the supplied path argument is absolute or relative. 
+  If you recieved a relative path like <function>./myFile</function> you need to 
+  make it absolute. The second example shows you how this can be achieved.
       </para>
       <para>
-	<programlisting>
+  <informalexample>
+	<programlisting language="C">
 <![CDATA[
 #include <libgnomevfs/gnome-vfs.h>
 #include <gnome.h>
@@ -171,6 +181,50 @@
 
 ]]>
 	</programlisting>
+  </informalexample>
+</para>
+<para>
+Now lets have a look at the idea how to create an absolute path from a relative
+path.
+<informalexample>
+<programlisting language="C">
+<![CDATA[
+/* using input uri as string from commandline */
+char* input_uri_string = argv[1];
+/* make uri absolute from relative */
+if(gnome_vfs_uri_is_local(input_uri)) {
+  /* if the uri exists we can open it.. no need for more tests */
+  if(gnome_vfs_uri_exists(input_uri))
+  {
+  
+  /* do somthing with the uri */ 
+  
+  } else {
+    /* uri is not absolute */
+    
+    /* we still need to find out if it is a valid path */
+    char *dirname =  gnome_vfs_uri_extract_dirname(input_uri);
+    if ( (dirname[0]=='.') || (strlen(dirname) == 1 && (dirname[0]=='/')) )
+    {
+      /* there should be default a function to get the full path from a relative one  */
+      char *cur_dir_tmp = g_get_current_dir();
+      char *path = NULL;
+      /* gnome_vfs needs a trailing '/' in the base path */
+      char *cur_dir = g_strdup_printf("%s/", cur_dir_tmp);
+      g_free(cur_dir_tmp);
+      path =  gnome_vfs_uri_make_full_from_relative(cur_dir,input_uri_string);
+      /* create URI from the new absolute path */
+      absolute_uri = gnome_vfs_uri_new(path);
+      g_free(path);
+      g_free(input_uri_strig);
+      g_free(cur_dir);
+    }
+    g_free(dirname);
+  }
+}
+]]>
+</programlisting>
+</informalexample>
 </para>
     </sect2>
     <sect2>


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