libgnomevfs2-mythtv/tests/main.c
author renatofilho
Thu Jun 14 18:22:32 2007 +0100 (2007-06-14)
branchtrunk
changeset 753 8ee634511c1e
parent 645 17877d6e44e2
child 754 cb885ee44618
permissions -rw-r--r--
[svn r759] fixed indent using GNU Style
     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 	{
    11 	  g_warning(message);
    12 	  exit(1);
    13 	}
    14 }
    15 
    16 int
    17 main(int argc, char **argv)
    18 {
    19   GnomeVFSResult result;
    20   GnomeVFSFileSize read;
    21   gchar buff[512];
    22   GnomeVFSHandle *handle = NULL;
    23 
    24 
    25   g_assert(argc == 2);
    26 
    27   gnome_vfs_init();
    28 
    29   g_debug("Oppening: %s", argv[1]);
    30 
    31   result = gnome_vfs_open(&handle, argv[1], GNOME_VFS_OPEN_READ);
    32   assert_message(result == GNOME_VFS_OK, gnome_vfs_result_to_string(result));
    33 
    34   g_debug("handle %p", handle);
    35 
    36   while (result == GNOME_VFS_OK)
    37 	{
    38 	  memset(buff, '\0', sizeof(buff));
    39 	  result = gnome_vfs_read(handle, buff, sizeof(buff), &read);
    40 	  g_debug("read %" G_GINT64_FORMAT, read);
    41 	}
    42 
    43   assert_message(result == GNOME_VFS_ERROR_EOF,
    44 				 gnome_vfs_result_to_string(result));
    45 
    46   result = gnome_vfs_close(handle);
    47   assert_message(result == GNOME_VFS_OK, gnome_vfs_result_to_string(result));
    48 
    49   g_debug("OK");
    50   return 0;
    51 }