From 2cb2ef977cfec135ae81e251c565b037c6208bc2 Mon Sep 17 00:00:00 2001 From: nobu Date: Sun, 17 Oct 2004 22:26:58 +0000 Subject: * file.c (rb_file_truncate): discard read buffer before truncation. [ruby-dev:24197] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7057 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- file.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'file.c') diff --git a/file.c b/file.c index 36cb34a8cc..69f600e115 100644 --- a/file.c +++ b/file.c @@ -67,6 +67,9 @@ char *strrchr _((const char*,const char)); #ifndef HAVE_LSTAT #define lstat(path,st) stat(path,st) #endif +#if !HAVE_FSEEKO && !defined(fseeko) +# define fseeko fseek +#endif VALUE rb_cFile; VALUE rb_mFileTest; @@ -2973,6 +2976,7 @@ rb_file_truncate(obj, len) } f = GetWriteFile(fptr); fflush(f); + fseeko(f, (off_t)0, SEEK_CUR); #ifdef HAVE_TRUNCATE if (ftruncate(fileno(f), NUM2OFFT(len)) < 0) rb_sys_fail(fptr->path); -- cgit v1.2.3