diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2000-06-05 22:23:47 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2000-06-05 22:23:47 +0000 |
commit | 4b8bb462dc50037b8a2d3748769841c6fb66c7bc (patch) | |
tree | 96312b17e2fd9995bb136adef1f065f367341c7b /gnu/egcs/libio/filebuf.cc | |
parent | bc01f7371c47d797fb0aaff6be8286e934d81e0a (diff) |
Synch with 2.95.3 (pre-rel)
Diffstat (limited to 'gnu/egcs/libio/filebuf.cc')
-rw-r--r-- | gnu/egcs/libio/filebuf.cc | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/gnu/egcs/libio/filebuf.cc b/gnu/egcs/libio/filebuf.cc index 422d442736e..0b0fd6d88d3 100644 --- a/gnu/egcs/libio/filebuf.cc +++ b/gnu/egcs/libio/filebuf.cc @@ -1,5 +1,5 @@ /* This is part of libio/iostream, providing -*- C++ -*- input/output. -Copyright (C) 1993, 1995 Free Software Foundation +Copyright (C) 1993, 1995, 1999 Free Software Foundation This file is part of the GNU IO Library. This library is free software; you can redistribute it and/or modify it under the @@ -112,15 +112,23 @@ filebuf* filebuf::open(const char *filename, ios::openmode mode, int prot) if (mode & (int)ios::noreplace) posix_mode |= O_EXCL; #if _G_HAVE_IO_FILE_OPEN - return (filebuf*)_IO_file_open (this, filename, posix_mode, prot, - read_write, 0); + if (!_IO_file_open (this, filename, posix_mode, prot, + read_write, 0)) + return NULL; + if (mode & ios::ate) { + if (pubseekoff(0, ios::end) == EOF) { + _IO_un_link (this); + return NULL; + } + } + return this; #else int fd = ::open(filename, posix_mode, prot); if (fd < 0) return NULL; _fileno = fd; xsetflags(read_write, _IO_NO_READS+_IO_NO_WRITES+_IO_IS_APPENDING); - if (mode & (ios::ate|ios::app)) { + if (mode & ios::ate) { if (pubseekoff(0, ios::end) == EOF) return NULL; } |