Meaning of G_IO_STATUS_AGAIN apart from resource temporarily unavailable ?



Hi,

I red the docs on GIOChannels but I'm stuck regarding what means "resource temporarily available" in my case since I'm reading from a binary file that IS on my hard disk and the permissions are correct. The giochannel is set null encoded, I read from a file and I write the red bytes on a giochannel:

ioc_cpio = g_io_channel_new_file ( tmp , "r" , NULL );
        g_io_channel_set_encoding (ioc_cpio , NULL , NULL);
    g_io_channel_set_flags ( ioc_cpio , G_IO_FLAG_NONBLOCK , NULL );

while ( g_io_channel_read_chars ( ioc_cpio , buffer, sizeof(buffer)-1, &bytes_read, &error ) == G_IO_STATUS_NORMAL )
    {
        if ( error != NULL )
        {
            g_print ("Read Error: %s\n" , error->message);
            g_error_free ( error );
            g_io_channel_shutdown ( ioc_cpio , TRUE , NULL );
                    g_io_channel_unref ( ioc_cpio );
                    g_spawn_close_pid ( child_pid );
            g_free (tmp);
        }
        g_print ("Bytes letti: %d\t" , bytes_read);
status = g_io_channel_write_chars ( input_ioc , buffer , bytes_read , &bytes_write , &error );
        g_io_channel_flush ( input_ioc , NULL );
        g_print ("Bytes scritti: %d\n" , bytes_write);
        if (bytes_write == 0 ) g_print ("Status: %d\n" , status );
        if ( status == G_IO_STATUS_ERROR )
        {
            g_print ("Write Error: %s\n" , error->message);
            g_error_free ( error );
            g_io_channel_shutdown ( ioc_cpio,TRUE,NULL );
                    g_io_channel_unref ( ioc_cpio );
                    g_spawn_close_pid ( child_pid );
            g_free (tmp);
        }
    }
    g_io_channel_shutdown ( ioc_cpio , TRUE , NULL );
        g_io_channel_unref ( ioc_cpio );

    //tmp contains the pointer to the CPIO filename in /tmp
    //unlink (tmp);
    g_free (tmp);

Why there are no example on giochannels ? The docs are not enough for
common mortals like me and others.
--
Colossus
Xarchiver, a GTK2 only archive manager - http://xarchiver.sourceforge.net
Cpsed, a Linux OpenGL 3D scene editor - http://cpsed.sourceforge.net
Mizio, a QT proxy hunter scanner tool - http://mizio.sourceforge.net



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]