summaryrefslogtreecommitdiff
path: root/ACE/protocols/ace/INet/FTP_IOStream.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ACE/protocols/ace/INet/FTP_IOStream.cpp')
-rw-r--r--ACE/protocols/ace/INet/FTP_IOStream.cpp107
1 files changed, 107 insertions, 0 deletions
diff --git a/ACE/protocols/ace/INet/FTP_IOStream.cpp b/ACE/protocols/ace/INet/FTP_IOStream.cpp
new file mode 100644
index 00000000000..3d6406f584f
--- /dev/null
+++ b/ACE/protocols/ace/INet/FTP_IOStream.cpp
@@ -0,0 +1,107 @@
+// $Id$
+
+#include "ace/INet/FTP_IOStream.h"
+#include "ace/INet/IOS_util.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/INet/FTP_IOStream.inl"
+#endif
+
+#include "ace/Truncate.h"
+
+
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+namespace ACE
+{
+ namespace FTP
+ {
+
+ StreamBuffer::StreamBuffer (std::iostream * stream)
+ : ACE::IOS::BufferedStreamBuffer (BUFFER_SIZE,
+ std::ios::in | std::ios::out),
+ stream_ (stream)
+ {
+ }
+
+ StreamBuffer::~StreamBuffer ()
+ {
+ }
+
+ std::iostream* StreamBuffer::set_stream (std::iostream * stream)
+ {
+ std::iostream * old_stream = this->stream_;
+ this->stream_ = stream;
+ this->reset_buffers ();
+ return old_stream;
+ }
+
+ int StreamBuffer::read_from_stream (char* buffer, std::streamsize length)
+ {
+ if (this->stream_ == 0) return -1;
+ this->stream_->read (buffer, length);
+ return ACE_Utils::truncate_cast<int> (this->stream_->gcount ());
+ }
+
+ int StreamBuffer::write_to_stream (const char* buffer, std::streamsize length)
+ {
+ if (this->stream_ == 0) return -1;
+ this->stream_->write (buffer, length);
+ return this->stream_->good () ? ACE_Utils::truncate_cast<int> (length) : -1;
+ }
+
+ int StreamBuffer::sync ()
+ {
+ if (this->stream_ == 0) return -1;
+ if (ACE::IOS::BufferedStreamBuffer::sync () == -1)
+ return -1;
+ return this->stream_->sync ();
+ }
+
+ IOS::IOS (std::iostream * stream)
+ : streambuf_ (stream)
+ {
+ ace_ios_init (&this->streambuf_);
+ }
+
+ IOS::~IOS ()
+ {
+ try
+ {
+ this->streambuf_.sync();
+ }
+ catch (...)
+ {
+ }
+ }
+
+ std::iostream* IOS::set_stream (std::iostream* stream)
+ {
+ std::iostream* old_stream = this->rdbuf ()->set_stream (stream);
+ this->clear ();
+ return old_stream;
+ }
+
+ OStream::OStream(std::iostream * stream)
+ : IOS (stream), std::ostream (&streambuf_)
+ {
+ }
+
+ OStream::~OStream()
+ {
+ }
+
+ IStream::IStream(std::iostream * stream)
+ : IOS (stream), std::istream (&streambuf_)
+ {
+ }
+
+ IStream::~IStream()
+ {
+ }
+
+ }
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL