diff src/stdio/stdio.c @ 965:f1642ee1115c trunk

[svn] - Implement vfs_fsize() for stdio - Implement dummys for curl/mms/smb
author ertzing
date Fri, 20 Apr 2007 06:50:15 -0700
parents 1d81ea250dce
children 183d03932c9e
line wrap: on
line diff
--- a/src/stdio/stdio.c	Wed Apr 18 07:38:58 2007 -0700
+++ b/src/stdio/stdio.c	Fri Apr 20 06:50:15 2007 -0700
@@ -230,6 +230,23 @@
     return ftruncate(fileno(handle), size);
 }
 
+off_t
+stdio_vfs_fsize_impl(VFSFile * file)
+{
+    FILE *handle;
+    struct stat s;
+
+    if (file == NULL)
+        return -1;
+
+    handle = (FILE *) file->handle;
+
+    if (-1 == fstat(fileno(handle), &s))
+        return -1;
+
+    return s.st_size;
+}
+
 VFSConstructor file_const = {
 	"file://",
 	stdio_vfs_fopen_impl,
@@ -242,7 +259,8 @@
 	stdio_vfs_rewind_impl,
 	stdio_vfs_ftell_impl,
 	stdio_vfs_feof_impl,
-	stdio_vfs_truncate_impl
+	stdio_vfs_truncate_impl,
+	stdio_vfs_fsize_impl
 };
 
 VFSConstructor default_const = {
@@ -257,7 +275,8 @@
 	stdio_vfs_rewind_impl,
 	stdio_vfs_ftell_impl,
 	stdio_vfs_feof_impl,
-	stdio_vfs_truncate_impl
+	stdio_vfs_truncate_impl,
+	stdio_vfs_fsize_impl
 };
 
 static void init(void)