From: Martin v. Löwis Date: Tue, 21 Dec 1999 18:13:32 +0000 (+0000) Subject: filebuf.cc (open): Support ios::ate if _G_HAVE_IO_FILE_OPEN. X-Git-Tag: prereleases/gcc-2.95.3-test1~103 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=872e37c8c41bfbc36fe21291a5375c21eb41978c;p=thirdparty%2Fgcc.git filebuf.cc (open): Support ios::ate if _G_HAVE_IO_FILE_OPEN. * filebuf.cc (open): Support ios::ate if _G_HAVE_IO_FILE_OPEN. Remove seek for ios::app if not. From-SVN: r31058 --- diff --git a/libio/ChangeLog b/libio/ChangeLog index 6785f414edca..8151dc26ee35 100644 --- a/libio/ChangeLog +++ b/libio/ChangeLog @@ -1,3 +1,8 @@ +1999-12-21 Martin v. Löwis + + * filebuf.cc (open): Support ios::ate if _G_HAVE_IO_FILE_OPEN. + Remove seek for ios::app if not. + 1999-12-14 Martin v. Löwis * strstream.h (strstreambuf::streambuf): Rename parameters to diff --git a/libio/filebuf.cc b/libio/filebuf.cc index 422d442736e0..0b0fd6d88d3a 100644 --- a/libio/filebuf.cc +++ b/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; }