libgnomevfs2-mythtv/tests/main.c
author morphbr
Sat Jun 30 15:05:50 2007 +0100 (2007-06-30)
branchtrunk
changeset 765 57f3de326cd8
parent 753 8ee634511c1e
permissions -rw-r--r--
[svn r771] * Mencoder doesnt work well with "Transfer-Encoding: chunked".
* Put this method just for gmencoder
     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 }