summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-12-06 08:40:30 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-12-06 08:40:30 +0000
commit04f36c2bba797225f0ab8f2bd83de86e1203ac47 (patch)
tree92055143e8d1ef22277637802fff499dd1e06d09 /file.c
parent35091fdda5bb3aa55d49c1c6bf20964a7a920bee (diff)
* 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: svn+ssh://ci.ruby-lang.org/ruby/trunk@7473 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'file.c')
-rw-r--r--file.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/file.c b/file.c
index b185d0cd59..2555e7032e 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: