]> git.saurik.com Git - wxWidgets.git/blame - src/common/fstream.cpp
Some manual updates; in MDI sample, child frames now have default size/position ...
[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
3d4c6a21
GL
26#define BUF_TEMP_SIZE 10000
27
79c3e0e1
GL
28// ----------------------------------------------------------------------------
29// wxFileInputStream
30// ----------------------------------------------------------------------------
31
32wxFileInputStream::wxFileInputStream(const wxString& fileName)
33 : wxFile(fileName, read)
3d4c6a21 34{
6d44bf31 35 m_i_streambuf->SetBufferIO(1024);
3d4c6a21
GL
36}
37
79c3e0e1 38wxFileInputStream::~wxFileInputStream()
3d4c6a21 39{
3d4c6a21
GL
40}
41
6d44bf31 42char wxFileInputStream::Peek()
3d4c6a21 43{
6d44bf31 44 return 0;
3d4c6a21
GL
45}
46
6d44bf31
GL
47size_t wxFileInputStream::DoRead(void *buffer, size_t size)
48{
49 return wxFile::Read(buffer, size);
50}
51
52off_t wxFileInputStream::DoSeekInput(off_t pos, wxSeekMode mode)
3d4c6a21 53{
79c3e0e1
GL
54 return wxFile::Seek(pos, mode);
55}
56
6d44bf31 57off_t wxFileInputStream::DoTellInput() const
79c3e0e1
GL
58{
59 return wxFile::Tell();
60}
61
62// ----------------------------------------------------------------------------
63// wxFileOutputStream
64// ----------------------------------------------------------------------------
65
66wxFileOutputStream::wxFileOutputStream(const wxString& fileName)
67 : wxFile(fileName, write)
68{
6d44bf31 69 m_o_streambuf->SetBufferIO(1024);
3d4c6a21
GL
70}
71
79c3e0e1 72wxFileOutputStream::~wxFileOutputStream()
3d4c6a21 73{
6d44bf31 74 Sync();
79c3e0e1 75}
3d4c6a21 76
6d44bf31 77size_t wxFileOutputStream::DoWrite(const void *buffer, size_t size)
79c3e0e1 78{
6d44bf31 79 size_t ret = wxFile::Write(buffer, size);
79c3e0e1 80 m_bad = wxFile::Error();
6d44bf31 81 return ret;
79c3e0e1 82}
3d4c6a21 83
6d44bf31 84off_t wxFileOutputStream::DoTellOutput() const
79c3e0e1
GL
85{
86 return wxFile::Tell();
3d4c6a21
GL
87}
88
6d44bf31 89off_t wxFileOutputStream::DoSeekOutput(off_t pos, wxSeekMode mode)
3d4c6a21 90{
79c3e0e1 91 return wxFile::Seek(pos, mode);
3d4c6a21
GL
92}
93
79c3e0e1 94void wxFileOutputStream::Sync()
3d4c6a21 95{
6d44bf31 96 wxOutputStream::Sync();
79c3e0e1 97 wxFile::Flush();
3d4c6a21
GL
98}
99
79c3e0e1
GL
100// ----------------------------------------------------------------------------
101// wxFileStream
102// ----------------------------------------------------------------------------
103
104wxFileStream::wxFileStream(const wxString& fileName)
105 : wxFile(fileName, read_write)
3d4c6a21 106{
3d4c6a21
GL
107}
108
79c3e0e1 109wxFileStream::~wxFileStream()
3d4c6a21 110{
3d4c6a21 111}