libgnomevfs2-mythtv/tests/main.c
author ali@juiblex.co.uk
Sun Dec 13 22:42:34 2009 +0000 (2009-12-13)
branchtrunk
changeset 948 0399d9ea8b7b
parent 753 8ee634511c1e
permissions -rw-r--r--
Don't require higher levels to bookkeep query state
     1 #include <stdlib.h>
     2 #include <string.h>
     3 #include <libgnomevfs/gnome-vfs.h>
     4 #include <glib.h>
     5 
     6 static void
     7 assert_message(gboolean valid, const gchar * message)
     8 {
     9     if (!valid) {
    10         g_warning(message);
    11         exit(1);
    12     }
    13 }
    14 
    15 int
    16 main(int argc, char **argv)
    17 {
    18     GnomeVFSResult  result;
    19     GnomeVFSFileSize read;
    20     gchar           buff[512];
    21     GnomeVFSHandle *handle = NULL;
    22 
    23 
    24     g_assert(argc == 2);
    25 
    26     gnome_vfs_init();
    27 
    28     g_debug("Oppening: %s", argv[1]);
    29 
    30     result = gnome_vfs_open(&handle, argv[1], GNOME_VFS_OPEN_READ);
    31     assert_message(result == GNOME_VFS_OK,
    32                    gnome_vfs_result_to_string(result));
    33 
    34     g_debug("handle %p", handle);
    35 
    36     while (result == GNOME_VFS_OK) {
    37         memset(buff, '\0', sizeof(buff));
    38         result = gnome_vfs_read(handle, buff, sizeof(buff), &read);
    39         g_debug("read %" G_GINT64_FORMAT, read);
    40     }
    41 
    42     assert_message(result == GNOME_VFS_ERROR_EOF,
    43                    gnome_vfs_result_to_string(result));
    44 
    45     result = gnome_vfs_close(handle);
    46     assert_message(result == GNOME_VFS_OK,
    47                    gnome_vfs_result_to_string(result));
    48 
    49     g_debug("OK");
    50     return 0;
    51 }