]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/common/fstream.cpp
speed optimizations: some functions now use wxString::Alloc, wxTextFile::Read
[wxWidgets.git] / src / common / fstream.cpp
... / ...
CommitLineData
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
16// For compilers that support precompilation, includes "wx.h".
17#include "wx/wxprec.h"
18#include <stdio.h>
19#include <wx/stream.h>
20#include <wx/fstream.h>
21
22#ifdef __BORLANDC__
23#pragma hdrstop
24#endif
25
26
27#define BUF_TEMP_SIZE 10000
28
29#if !USE_SHARED_LIBRARY
30IMPLEMENT_CLASS(wxFileInputStream, wxInputStream)
31IMPLEMENT_CLASS(wxFileOutputStream, wxOutputStream)
32IMPLEMENT_CLASS2(wxFileStream, wxInputStream, wxOutputStream)
33#endif
34
35// ----------------------------------------------------------------------------
36// wxFileInputStream
37// ----------------------------------------------------------------------------
38
39wxFileInputStream::wxFileInputStream(const wxString& fileName)
40 : wxFile(fileName, read)
41{
42 m_lastread = 0;
43}
44
45wxFileInputStream::~wxFileInputStream()
46{
47}
48
49wxInputStream& wxFileInputStream::Read(void *buffer, size_t size)
50{
51 m_lastread = wxFile::Read(buffer, size);
52 return *this;
53}
54
55off_t wxFileInputStream::SeekI(off_t pos, wxSeekMode mode)
56{
57 return wxFile::Seek(pos, mode);
58}
59
60off_t wxFileInputStream::TellI() const
61{
62 return wxFile::Tell();
63}
64
65// ----------------------------------------------------------------------------
66// wxFileOutputStream
67// ----------------------------------------------------------------------------
68
69wxFileOutputStream::wxFileOutputStream(const wxString& fileName)
70 : wxFile(fileName, write)
71{
72 m_lastwrite = 0;
73}
74
75wxFileOutputStream::~wxFileOutputStream()
76{
77}
78
79wxOutputStream& wxFileOutputStream::Write(const void *buffer, size_t size)
80{
81 m_lastwrite = wxFile::Write(buffer, size);
82 m_bad = wxFile::Error();
83 return *this;
84}
85
86off_t wxFileOutputStream::TellO() const
87{
88 return wxFile::Tell();
89}
90
91off_t wxFileOutputStream::SeekO(off_t pos, wxSeekMode mode)
92{
93 return wxFile::Seek(pos, mode);
94}
95
96void wxFileOutputStream::Sync()
97{
98 wxFile::Flush();
99}
100
101// ----------------------------------------------------------------------------
102// wxFileStream
103// ----------------------------------------------------------------------------
104
105wxFileStream::wxFileStream(const wxString& fileName)
106 : wxFile(fileName, read_write)
107{
108}
109
110wxFileStream::~wxFileStream()
111{
112}