diff options
author | Martin v. Löwis <loewis@informatik.hu-berlin.de> | 1999-12-21 18:10:24 +0000 |
---|---|---|
committer | Martin v. Löwis <loewis@gcc.gnu.org> | 1999-12-21 18:10:24 +0000 |
commit | dec0fa945c807ed495a3b74fbf98c6d30a19b4c8 (patch) | |
tree | 66a4b256b271dcd24e3041f2ae3fd51b171f71b5 /libio/filebuf.cc | |
parent | 74a7ea1231dd7c97ff90a1c39944cb6f4cd3ab68 (diff) | |
download | gcc-dec0fa945c807ed495a3b74fbf98c6d30a19b4c8.zip gcc-dec0fa945c807ed495a3b74fbf98c6d30a19b4c8.tar.gz gcc-dec0fa945c807ed495a3b74fbf98c6d30a19b4c8.tar.bz2 |
* filebuf.cc (open): Support ios::ate if _G_HAVE_IO_FILE_OPEN.
From-SVN: r31057
Diffstat (limited to 'libio/filebuf.cc')
-rw-r--r-- | libio/filebuf.cc | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/libio/filebuf.cc b/libio/filebuf.cc index 422d442..0b0fd6d 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; } |