summaryrefslogtreecommitdiffstats
path: root/file.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-10-17 22:26:58 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-10-17 22:26:58 +0000
commitb5d57e7ef5c95c860243ea327b16542f19f45f8b (patch)
tree6a3c9690c48069c8c6019975235fab7fa37ea59a /file.c
parente9d7c50ab91e70493eeaf04bc64b85a663b5bc08 (diff)
downloadruby-b5d57e7ef5c95c860243ea327b16542f19f45f8b.tar.gz
ruby-b5d57e7ef5c95c860243ea327b16542f19f45f8b.tar.xz
ruby-b5d57e7ef5c95c860243ea327b16542f19f45f8b.zip
* file.c (rb_file_truncate): discard read buffer before truncation.
[ruby-dev:24197] git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@7057 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'file.c')
-rw-r--r--file.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/file.c b/file.c
index 36cb34a8c..69f600e11 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);
OSZAR »