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