From eca8a5a23a25bd5d13db45b643e146e82f9a9be9 Mon Sep 17 00:00:00 2001 From: akr Date: Mon, 6 Dec 2004 08:40:30 +0000 Subject: * rubyio.h, intern.h, io.c, file.c, process.c, ext/socket/socket.c, ext/pty/pty.c, ext/io/wait/wait.c, ext/openssl/ossl_ssl.c: Use own buffering mechanism instead of stdio. * io.c, ext/stringio/stringio.c, test/ruby/ut_eof.rb: EOF flag removed. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@7473 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- file.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) (limited to 'file.c') diff --git a/file.c b/file.c index b185d0cd5..2555e7032 100644 --- a/file.c +++ b/file.c @@ -639,7 +639,7 @@ rb_stat(file, st) OpenFile *fptr; GetOpenFile(tmp, fptr); - return fstat(fileno(fptr->f), st); + return fstat(fptr->fd, st); } FilePathValue(file); return stat(StringValueCStr(file), st); @@ -693,7 +693,7 @@ rb_io_stat(obj) struct stat st; GetOpenFile(obj, fptr); - if (fstat(fileno(fptr->f), &st) == -1) { + if (fstat(fptr->fd, &st) == -1) { rb_sys_fail(fptr->path); } return stat_new(&st); @@ -1531,7 +1531,7 @@ rb_file_atime(obj) struct stat st; GetOpenFile(obj, fptr); - if (fstat(fileno(fptr->f), &st) == -1) { + if (fstat(fptr->fd, &st) == -1) { rb_sys_fail(fptr->path); } return rb_time_new(st.st_atime, 0); @@ -1576,7 +1576,7 @@ rb_file_mtime(obj) struct stat st; GetOpenFile(obj, fptr); - if (fstat(fileno(fptr->f), &st) == -1) { + if (fstat(fptr->fd, &st) == -1) { rb_sys_fail(fptr->path); } return rb_time_new(st.st_mtime, 0); @@ -1624,7 +1624,7 @@ rb_file_ctime(obj) struct stat st; GetOpenFile(obj, fptr); - if (fstat(fileno(fptr->f), &st) == -1) { + if (fstat(fptr->fd, &st) == -1) { rb_sys_fail(fptr->path); } return rb_time_new(st.st_ctime, 0); @@ -1695,7 +1695,7 @@ rb_file_chmod(obj, vmode) GetOpenFile(obj, fptr); #ifdef HAVE_FCHMOD - if (fchmod(fileno(fptr->f), mode) == -1) + if (fchmod(fptr->fd, mode) == -1) rb_sys_fail(fptr->path); #else if (!fptr->path) return Qnil; @@ -1840,7 +1840,7 @@ rb_file_chown(obj, owner, group) if (chown(fptr->path, o, g) == -1) rb_sys_fail(fptr->path); #else - if (fchown(fileno(fptr->f), o, g) == -1) + if (fchown(fptr->fd, o, g) == -1) rb_sys_fail(fptr->path); #endif @@ -2973,7 +2973,6 @@ rb_file_truncate(obj, len) VALUE obj, len; { OpenFile *fptr; - FILE *f; off_t pos; rb_secure(2); @@ -2982,15 +2981,13 @@ rb_file_truncate(obj, len) if (!(fptr->mode & FMODE_WRITABLE)) { rb_raise(rb_eIOError, "not opened for writing"); } - f = GetWriteFile(fptr); - fflush(f); - fseeko(f, (off_t)0, SEEK_CUR); + rb_io_flush(obj); #ifdef HAVE_TRUNCATE - if (ftruncate(fileno(f), pos) < 0) + if (ftruncate(fptr->fd, pos) < 0) rb_sys_fail(fptr->path); #else # ifdef HAVE_CHSIZE - if (chsize(fileno(f), pos) < 0) + if (chsize(fptr->fd, pos) < 0) rb_sys_fail(fptr->path); # else rb_notimplement(); @@ -3084,10 +3081,10 @@ rb_file_flock(obj, operation) GetOpenFile(obj, fptr); if (fptr->mode & FMODE_WRITABLE) { - fflush(GetWriteFile(fptr)); + rb_io_flush(obj); } retry: - if (flock(fileno(fptr->f), op) < 0) { + if (flock(fptr->fd, op) < 0) { switch (errno) { case EAGAIN: case EACCES: -- cgit