changeset 967:1aabbe15006f trunk

[svn] - Add a useful vfs_fsize() implementation to curl
author ertzing
date Fri, 20 Apr 2007 07:41:13 -0700
parents 1f78881a5f3c
children 317a7a8c002d
files ChangeLog src/curl/curl.c
diffstat 2 files changed, 38 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri Apr 20 06:51:44 2007 -0700
+++ b/ChangeLog	Fri Apr 20 07:41:13 2007 -0700
@@ -1,3 +1,12 @@
+2007-04-20 13:51:44 +0000  Ralf Ertzinger <ralf@skytale.net>
+  revision [2072]
+  
+  - Make flacng use vfs_fsize()
+  
+  trunk/src/flacng/seekable_stream_callbacks.c |   34 +++++++++------------------
+  1 file changed, 12 insertions(+), 22 deletions(-)
+
+
 2007-04-20 13:50:15 +0000  Ralf Ertzinger <ralf@skytale.net>
   revision [2070]
   
--- a/src/curl/curl.c	Fri Apr 20 06:51:44 2007 -0700
+++ b/src/curl/curl.c	Fri Apr 20 07:41:13 2007 -0700
@@ -941,7 +941,35 @@
 off_t
 curl_vfs_fsize_impl(VFSFile * file)
 {
-    return -1;
+  CurlHandle *handle = file->handle;
+
+  if (handle->length == -1)
+    {
+      if (!handle->thread)
+	{
+	  // We need a HEAD to find out the length
+	  handle->no_data = 1;
+	  if (DEBUG_CONNECTION)
+	    g_print("Request for head info\n");
+	  curl_manage_request(handle);
+	  if (DEBUG_CONNECTION)
+	    g_print("Completed\n");
+	  handle->no_data = 0;
+	}
+      else
+	{
+	  // Wait a bit?
+	}
+    }
+
+  if (handle->length <= 0)
+    {
+      if (DEBUG_SEEK)
+	g_print("Tried to get the length of a file with unknown length\n");
+      // don't know how long it is...
+      return -1;
+    }
+    return handle->length;
 }
 
 gchar *