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