To use GnomeVFS, include libgnomevfs/gnome-vfs.h in your source code. Compile and link with the flags you get with pkg-config (package name gnome-vfs-2.0 ).
The gnome_program_init() function initializes GnomeVFS for you, so if you're writing a GNOME application, you need only worry about shutting down the system. However, if you don't have a GNOME program, call
gnome_vfs_init()
to set up GnomeVFS. This call returns FALSE when it cannot get GnomeVFS working.
At the end of your program, you should shut down the GnomeVFS subsystem to force all pending cache operations and free the resources:
gnome_vfs_shutdown()
For example, a GTK+ (non-GNOME) application that uses GnomeVFS might have this structure:
#include <libgnomevfs/gnome-vfs.h> #include <gtk/gtk.h> int main(int argc, char **argv) { << miscellaneous initialization >> if (!gnome_vfs_init()) { g_error("could not initialize GnomeVFS"); << ... >> } << build application >> gtk_main(); << miscellaneous shutdown >> gnome_vfs_shutdown(); return(0); }
If some other library is supposed to initialize GnomeVFS, you can check the status of GnomeVFS with
if (!gnome_vfs_initialized()) { if (!gnome_vfs_init()) { g_error("could not initialize GnomeVFS"); << ... >> } }