[vlc-devel] commit: Forcefully update file size if read data past the former end of it ( Rémi Denis-Courmont )

git version control git at videolan.org
Wed Apr 8 17:52:05 CEST 2009


vlc | branch: master | Rémi Denis-Courmont <rdenis at simphalempin.com> | Wed Apr  8 18:49:51 2009 +0300| [3b729128a6e2a0e0018c0f32bcd4ee611850b038] | committer: Rémi Denis-Courmont 

Forcefully update file size if read data past the former end of it

Maybe we could call fstat() at every read anyway? While a file is open,
the operating system is extremely likely to have its meta data cached.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3b729128a6e2a0e0018c0f32bcd4ee611850b038
---

 modules/access/file.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/modules/access/file.c b/modules/access/file.c
index cc7da19..8112c00 100644
--- a/modules/access/file.c
+++ b/modules/access/file.c
@@ -235,8 +235,8 @@ static ssize_t Read( access_t *p_access, uint8_t *p_buffer, size_t i_len )
     p_sys->i_nb_reads++;
 
 #ifdef HAVE_SYS_STAT_H
-    if( p_access->info.i_size != 0 &&
-        (p_sys->i_nb_reads % INPUT_FSTAT_NB_READS) == 0 )
+    if ((p_access->info.i_size && !(p_sys->i_nb_reads % INPUT_FSTAT_NB_READS))
+     || (p_access->info.i_pos > p_access->info.i_size))
     {
         struct stat st;
 




More information about the vlc-devel mailing list