]> git.saurik.com Git - wxWidgets.git/blame - src/common/fstream.cpp
Fixed a few compile things
[wxWidgets.git] / src / common / fstream.cpp
CommitLineData
3d4c6a21
GL
1/////////////////////////////////////////////////////////////////////////////
2// Name: fstream.cpp
3// Purpose: "File stream" classes
4// Author: Julian Smart
5// Modified by:
6// Created: 11/07/98
7// RCS-ID: $Id$
8// Copyright: (c) Guilhem Lavaux
9// Licence: wxWindows license
10/////////////////////////////////////////////////////////////////////////////
11
12#ifdef __GNUG__
13#pragma implementation "fstream.h"
14#endif
15
79c3e0e1
GL
16// For compilers that support precompilation, includes "wx.h".
17#include "wx/wxprec.h"
3d4c6a21
GL
18#include <stdio.h>
19#include <wx/stream.h>
20#include <wx/fstream.h>
21
79c3e0e1
GL
22#ifdef __BORLANDC__
23#pragma hdrstop
24#endif
25
79c3e0e1
GL
26// ----------------------------------------------------------------------------
27// wxFileInputStream
28// ----------------------------------------------------------------------------
29
30wxFileInputStream::wxFileInputStream(const wxString& fileName)
31 : wxFile(fileName, read)
3d4c6a21 32{
6d44bf31 33 m_i_streambuf->SetBufferIO(1024);
3d4c6a21
GL
34}
35
79c3e0e1 36wxFileInputStream::~wxFileInputStream()
3d4c6a21 37{
3d4c6a21
GL
38}
39
6d44bf31 40char wxFileInputStream::Peek()
3d4c6a21 41{
6d44bf31 42 return 0;
3d4c6a21
GL
43}
44
6d44bf31
GL
45size_t wxFileInputStream::DoRead(void *buffer, size_t size)
46{
885ee235 47 return wxFile::Read(buffer, size);
6d44bf31
GL
48}
49
50off_t wxFileInputStream::DoSeekInput(off_t pos, wxSeekMode mode)
3d4c6a21 51{
79c3e0e1
GL
52 return wxFile::Seek(pos, mode);
53}
54
6d44bf31 55off_t wxFileInputStream::DoTellInput() const
79c3e0e1
GL
56{
57 return wxFile::Tell();
58}
59
60// ----------------------------------------------------------------------------
61// wxFileOutputStream
62// ----------------------------------------------------------------------------
63
64wxFileOutputStream::wxFileOutputStream(const wxString& fileName)
65 : wxFile(fileName, write)
66{
6d44bf31 67 m_o_streambuf->SetBufferIO(1024);
3d4c6a21
GL
68}
69
79c3e0e1 70wxFileOutputStream::~wxFileOutputStream()
3d4c6a21 71{
6d44bf31 72 Sync();
79c3e0e1 73}
3d4c6a21 74
6d44bf31 75size_t wxFileOutputStream::DoWrite(const void *buffer, size_t size)
79c3e0e1 76{
6d44bf31 77 size_t ret = wxFile::Write(buffer, size);
79c3e0e1 78 m_bad = wxFile::Error();
6d44bf31 79 return ret;
79c3e0e1 80}
3d4c6a21 81
6d44bf31 82off_t wxFileOutputStream::DoTellOutput() const
79c3e0e1
GL
83{
84 return wxFile::Tell();
3d4c6a21
GL
85}
86
6d44bf31 87off_t wxFileOutputStream::DoSeekOutput(off_t pos, wxSeekMode mode)
3d4c6a21 88{
79c3e0e1 89 return wxFile::Seek(pos, mode);
3d4c6a21
GL
90}
91
79c3e0e1 92void wxFileOutputStream::Sync()
3d4c6a21 93{
6d44bf31 94 wxOutputStream::Sync();
79c3e0e1 95 wxFile::Flush();
3d4c6a21
GL
96}
97
79c3e0e1
GL
98// ----------------------------------------------------------------------------
99// wxFileStream
100// ----------------------------------------------------------------------------
101
102wxFileStream::wxFileStream(const wxString& fileName)
103 : wxFile(fileName, read_write)
3d4c6a21 104{
3d4c6a21
GL
105}
106
79c3e0e1 107wxFileStream::~wxFileStream()
3d4c6a21 108{
3d4c6a21 109}