]>
Commit | Line | Data |
---|---|---|
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 | |
30 | IMPLEMENT_CLASS(wxFileInputStream, wxInputStream) | |
31 | IMPLEMENT_CLASS(wxFileOutputStream, wxOutputStream) | |
32 | IMPLEMENT_CLASS2(wxFileStream, wxInputStream, wxOutputStream) | |
33 | #endif | |
34 | ||
35 | // ---------------------------------------------------------------------------- | |
36 | // wxFileInputStream | |
37 | // ---------------------------------------------------------------------------- | |
38 | ||
39 | wxFileInputStream::wxFileInputStream(const wxString& fileName) | |
40 | : wxFile(fileName, read) | |
41 | { | |
42 | m_lastread = 0; | |
43 | } | |
44 | ||
45 | wxFileInputStream::~wxFileInputStream() | |
46 | { | |
47 | } | |
48 | ||
49 | wxInputStream& wxFileInputStream::Read(void *buffer, size_t size) | |
50 | { | |
51 | m_lastread = wxFile::Read(buffer, size); | |
52 | return *this; | |
53 | } | |
54 | ||
55 | off_t wxFileInputStream::SeekI(off_t pos, wxSeekMode mode) | |
56 | { | |
57 | return wxFile::Seek(pos, mode); | |
58 | } | |
59 | ||
60 | off_t wxFileInputStream::TellI() const | |
61 | { | |
62 | return wxFile::Tell(); | |
63 | } | |
64 | ||
65 | // ---------------------------------------------------------------------------- | |
66 | // wxFileOutputStream | |
67 | // ---------------------------------------------------------------------------- | |
68 | ||
69 | wxFileOutputStream::wxFileOutputStream(const wxString& fileName) | |
70 | : wxFile(fileName, write) | |
71 | { | |
72 | m_lastwrite = 0; | |
73 | } | |
74 | ||
75 | wxFileOutputStream::~wxFileOutputStream() | |
76 | { | |
77 | } | |
78 | ||
79 | wxOutputStream& 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 | ||
86 | off_t wxFileOutputStream::TellO() const | |
87 | { | |
88 | return wxFile::Tell(); | |
89 | } | |
90 | ||
91 | off_t wxFileOutputStream::SeekO(off_t pos, wxSeekMode mode) | |
92 | { | |
93 | return wxFile::Seek(pos, mode); | |
94 | } | |
95 | ||
96 | void wxFileOutputStream::Sync() | |
97 | { | |
98 | wxFile::Flush(); | |
99 | } | |
100 | ||
101 | // ---------------------------------------------------------------------------- | |
102 | // wxFileStream | |
103 | // ---------------------------------------------------------------------------- | |
104 | ||
105 | wxFileStream::wxFileStream(const wxString& fileName) | |
106 | : wxFile(fileName, read_write) | |
107 | { | |
108 | } | |
109 | ||
110 | wxFileStream::~wxFileStream() | |
111 | { | |
112 | } |