#include #include #include #include static void assert_message(gboolean valid, const gchar * message) { if (!valid) { g_warning(message); exit(1); } } int main(int argc, char **argv) { GnomeVFSResult result; GnomeVFSFileSize read; gchar buff[512]; GnomeVFSHandle *handle = NULL; g_assert(argc == 2); gnome_vfs_init(); g_debug("Oppening: %s", argv[1]); result = gnome_vfs_open(&handle, argv[1], GNOME_VFS_OPEN_READ); assert_message(result == GNOME_VFS_OK, gnome_vfs_result_to_string(result)); g_debug("handle %p", handle); while (result == GNOME_VFS_OK) { memset(buff, '\0', sizeof(buff)); result = gnome_vfs_read(handle, buff, sizeof(buff), &read); g_debug("read %" G_GINT64_FORMAT, read); } assert_message(result == GNOME_VFS_ERROR_EOF, gnome_vfs_result_to_string(result)); result = gnome_vfs_close(handle); assert_message(result == GNOME_VFS_OK, gnome_vfs_result_to_string(result)); g_debug("OK"); return 0; }