| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- //
- // FileStream.cpp
- //
- // $Id: //poco/1.4/Foundation/src/FileStream.cpp#1 $
- //
- // Library: Foundation
- // Package: Streams
- // Module: FileStream
- //
- // Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
- // and Contributors.
- //
- // SPDX-License-Identifier: BSL-1.0
- //
- #include "Poco/FileStream.h"
- #include "Poco/Exception.h"
- #if defined(POCO_OS_FAMILY_WINDOWS)
- #include "FileStream_WIN32.cpp"
- #else
- #include "FileStream_POSIX.cpp"
- #endif
- namespace Poco {
- FileIOS::FileIOS(std::ios::openmode defaultMode):
- _defaultMode(defaultMode)
- {
- poco_ios_init(&_buf);
- }
- FileIOS::~FileIOS()
- {
- }
- void FileIOS::open(const std::string& path, std::ios::openmode mode)
- {
- clear();
- _buf.open(path, mode | _defaultMode);
- }
- void FileIOS::close()
- {
- if (!_buf.close())
- {
- setstate(ios_base::badbit);
- }
- }
- FileStreamBuf* FileIOS::rdbuf()
- {
- return &_buf;
- }
- FileInputStream::FileInputStream():
- FileIOS(std::ios::in),
- std::istream(&_buf)
- {
- }
- FileInputStream::FileInputStream(const std::string& path, std::ios::openmode mode):
- FileIOS(std::ios::in),
- std::istream(&_buf)
- {
- open(path, mode);
- }
- FileInputStream::~FileInputStream()
- {
- }
- FileOutputStream::FileOutputStream():
- FileIOS(std::ios::out),
- std::ostream(&_buf)
- {
- }
- FileOutputStream::FileOutputStream(const std::string& path, std::ios::openmode mode):
- FileIOS(std::ios::out),
- std::ostream(&_buf)
- {
- open(path, mode);
- }
- FileOutputStream::~FileOutputStream()
- {
- }
- FileStream::FileStream():
- FileIOS(std::ios::in | std::ios::out),
- std::iostream(&_buf)
- {
- }
- FileStream::FileStream(const std::string& path, std::ios::openmode mode):
- FileIOS(std::ios::in | std::ios::out),
- std::iostream(&_buf)
- {
- open(path, mode);
- }
- FileStream::~FileStream()
- {
- }
- } // namespace Poco
|