libgnomevfs2-mythtv/modules/mythtv-method.c
branchtrunk
changeset 273 4a7fc19705f0
parent 190 201327c993e5
child 277 890b023c759f
     1.1 --- a/libgnomevfs2-mythtv/modules/mythtv-method.c	Mon Dec 04 22:29:33 2006 +0000
     1.2 +++ b/libgnomevfs2-mythtv/modules/mythtv-method.c	Thu Jan 18 14:52:17 2007 +0000
     1.3 @@ -27,8 +27,9 @@
     1.4  #include <libgnomevfs/gnome-vfs-module.h>
     1.5  #include <libgnomevfs/gnome-vfs-utils.h>
     1.6  
     1.7 -#include "gmyth_file_transfer.h"
     1.8 -#include "gmyth_backendinfo.h"
     1.9 +#include <gmyth_file_transfer.h>
    1.10 +#include <gmyth_backendinfo.h>
    1.11 +#include <gmyth_util.h>
    1.12  
    1.13  #define GST_MYTHTV_ID_NUM               1
    1.14  #define MYTHTV_VERSION_DEFAULT          30
    1.15 @@ -91,6 +92,13 @@
    1.16  	    NULL, NULL, NULL,
    1.17  	    gnome_vfs_uri_get_host_port (uri));
    1.18  	    
    1.19 +
    1.20 +    /* Verifies if the file exists */
    1.21 +    if (!gmyth_util_file_exists (backend_info, gnome_vfs_uri_get_path (uri))) {
    1.22 +        g_object_unref (backend_info);
    1.23 +	return GNOME_VFS_ERROR_NOT_FOUND;
    1.24 +    }
    1.25 +		    
    1.26      /* Connect to the backend */
    1.27      myth_handle->file_transfer = gmyth_file_transfer_new (backend_info);
    1.28      g_object_unref (backend_info);
    1.29 @@ -104,8 +112,6 @@
    1.30          return GNOME_VFS_ERROR_NOT_OPEN;
    1.31      }
    1.32  
    1.33 -    // TODO: Verify if file exists in the backend
    1.34 -
    1.35      myth_handle->content_size = myth_handle->file_transfer->filesize;
    1.36      
    1.37      myth_handle->buffer = g_byte_array_sized_new (MYTHTV_BUFFER_SIZE);
    1.38 @@ -147,11 +153,15 @@
    1.39          gint len = gmyth_file_transfer_read (myth_handle->file_transfer,
    1.40                tmp_buffer, MYTHTV_BUFFER_SIZE - myth_handle->buffer_remain, TRUE);
    1.41  
    1.42 -		if (len < 0) {
    1.43 +	if (len < 0) {
    1.44              g_byte_array_free (tmp_buffer, TRUE);
    1.45              g_warning ("Fail to read bytes");
    1.46 -		    return GNOME_VFS_ERROR_IO;
    1.47 -        }
    1.48 +	    return GNOME_VFS_ERROR_IO;
    1.49 +        } else if (len == 0) {
    1.50 +	    g_byte_array_free (tmp_buffer, TRUE);
    1.51 +	    g_warning ("End of file probably achieved");
    1.52 +	    return GNOME_VFS_ERROR_EOF;
    1.53 +	}
    1.54  
    1.55          myth_handle->buffer = g_byte_array_append (myth_handle->buffer,
    1.56      		tmp_buffer->data, len);