]> git.saurik.com Git - wxWidgets.git/blob - src/common/fstream.cpp
* New wxStream classes: wxStreamBuffer and wxObject*Stream.
[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 #define BUF_TEMP_SIZE 10000
27
28 // ----------------------------------------------------------------------------
29 // wxFileInputStream
30 // ----------------------------------------------------------------------------
31
32 wxFileInputStream::wxFileInputStream(const wxString& fileName)
33 : wxFile(fileName, read)
34 {
35 m_lastread = 0;
36 }
37
38 wxFileInputStream::~wxFileInputStream()
39 {
40 }
41
42 wxInputStream& wxFileInputStream::Read(void *buffer, size_t size)
43 {
44 m_lastread = wxFile::Read(buffer, size);
45 return *this;
46 }
47
48 off_t wxFileInputStream::SeekI(off_t pos, wxSeekMode mode)
49 {
50 return wxFile::Seek(pos, mode);
51 }
52
53 off_t wxFileInputStream::TellI() const
54 {
55 return wxFile::Tell();
56 }
57
58 // ----------------------------------------------------------------------------
59 // wxFileOutputStream
60 // ----------------------------------------------------------------------------
61
62 wxFileOutputStream::wxFileOutputStream(const wxString& fileName)
63 : wxFile(fileName, write)
64 {
65 m_lastwrite = 0;
66 }
67
68 wxFileOutputStream::~wxFileOutputStream()
69 {
70 }
71
72 wxOutputStream& wxFileOutputStream::Write(const void *buffer, size_t size)
73 {
74 m_lastwrite = wxFile::Write(buffer, size);
75 m_bad = wxFile::Error();
76 return *this;
77 }
78
79 off_t wxFileOutputStream::TellO() const
80 {
81 return wxFile::Tell();
82 }
83
84 off_t wxFileOutputStream::SeekO(off_t pos, wxSeekMode mode)
85 {
86 return wxFile::Seek(pos, mode);
87 }
88
89 void wxFileOutputStream::Sync()
90 {
91 wxFile::Flush();
92 }
93
94 // ----------------------------------------------------------------------------
95 // wxFileStream
96 // ----------------------------------------------------------------------------
97
98 wxFileStream::wxFileStream(const wxString& fileName)
99 : wxFile(fileName, read_write)
100 {
101 }
102
103 wxFileStream::~wxFileStream()
104 {
105 }