]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/common/sckstrm.cpp
Fix wxFileSystem::FileNameToURL() for Unicode file names.
[wxWidgets.git] / src / common / sckstrm.cpp
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: src/common/sckstrm.cpp
3// Purpose: wxSocket*Stream
4// Author: Guilhem Lavaux
5// Modified by:
6// Created: 17/07/97
7// RCS-ID: $Id$
8// Copyright: (c)
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12// For compilers that support precompilation, includes "wx.h".
13#include "wx/wxprec.h"
14
15#ifdef __BORLANDC__
16 #pragma hdrstop
17#endif
18
19#if wxUSE_SOCKETS && wxUSE_STREAMS
20
21#include "wx/sckstrm.h"
22
23#ifndef WX_PRECOMP
24 #include "wx/stream.h"
25#endif
26
27#include "wx/socket.h"
28
29// ---------------------------------------------------------------------------
30// wxSocketOutputStream
31// ---------------------------------------------------------------------------
32
33wxSocketOutputStream::wxSocketOutputStream(wxSocketBase& s)
34 : m_o_socket(&s)
35{
36}
37
38wxSocketOutputStream::~wxSocketOutputStream()
39{
40}
41
42size_t wxSocketOutputStream::OnSysWrite(const void *buffer, size_t size)
43{
44 const size_t ret = m_o_socket->Write(buffer, size).LastCount();
45 m_lasterror = m_o_socket->Error()
46 ? m_o_socket->IsClosed() ? wxSTREAM_EOF
47 : wxSTREAM_WRITE_ERROR
48 : wxSTREAM_NO_ERROR;
49 return ret;
50}
51
52// ---------------------------------------------------------------------------
53// wxSocketInputStream
54// ---------------------------------------------------------------------------
55
56wxSocketInputStream::wxSocketInputStream(wxSocketBase& s)
57 : m_i_socket(&s)
58{
59}
60
61wxSocketInputStream::~wxSocketInputStream()
62{
63}
64
65size_t wxSocketInputStream::OnSysRead(void *buffer, size_t size)
66{
67 const size_t ret = m_i_socket->Read(buffer, size).LastCount();
68 m_lasterror = m_i_socket->Error()
69 ? m_i_socket->IsClosed() ? wxSTREAM_EOF
70 : wxSTREAM_READ_ERROR
71 : wxSTREAM_NO_ERROR;
72 return ret;
73}
74
75// ---------------------------------------------------------------------------
76// wxSocketStream
77// ---------------------------------------------------------------------------
78
79wxSocketStream::wxSocketStream(wxSocketBase& s)
80 : wxSocketInputStream(s), wxSocketOutputStream(s)
81{
82}
83
84wxSocketStream::~wxSocketStream()
85{
86}
87
88#endif // wxUSE_STREAMS && wxUSE_SOCKETS