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