diff -r 201327c993e5 -r d2192075f563 libgnomevfs2-mythtv/modules/mythtv-method.c --- a/libgnomevfs2-mythtv/modules/mythtv-method.c Mon Dec 04 22:29:33 2006 +0000 +++ b/libgnomevfs2-mythtv/modules/mythtv-method.c Thu Jan 18 20:51:59 2007 +0000 @@ -27,8 +27,9 @@ #include #include -#include "gmyth_file_transfer.h" -#include "gmyth_backendinfo.h" +#include +#include +#include #define GST_MYTHTV_ID_NUM 1 #define MYTHTV_VERSION_DEFAULT 30 @@ -91,6 +92,13 @@ NULL, NULL, NULL, gnome_vfs_uri_get_host_port (uri)); + + /* Verifies if the file exists */ + if (!gmyth_util_file_exists (backend_info, gnome_vfs_uri_get_path (uri))) { + g_object_unref (backend_info); + return GNOME_VFS_ERROR_NOT_FOUND; + } + /* Connect to the backend */ myth_handle->file_transfer = gmyth_file_transfer_new (backend_info); g_object_unref (backend_info); @@ -104,8 +112,6 @@ return GNOME_VFS_ERROR_NOT_OPEN; } - // TODO: Verify if file exists in the backend - myth_handle->content_size = myth_handle->file_transfer->filesize; myth_handle->buffer = g_byte_array_sized_new (MYTHTV_BUFFER_SIZE); @@ -147,11 +153,15 @@ gint len = gmyth_file_transfer_read (myth_handle->file_transfer, tmp_buffer, MYTHTV_BUFFER_SIZE - myth_handle->buffer_remain, TRUE); - if (len < 0) { + if (len < 0) { g_byte_array_free (tmp_buffer, TRUE); g_warning ("Fail to read bytes"); - return GNOME_VFS_ERROR_IO; - } + return GNOME_VFS_ERROR_IO; + } else if (len == 0) { + g_byte_array_free (tmp_buffer, TRUE); + g_warning ("End of file probably achieved"); + return GNOME_VFS_ERROR_EOF; + } myth_handle->buffer = g_byte_array_append (myth_handle->buffer, tmp_buffer->data, len);