]>
Commit | Line | Data |
---|---|---|
3d4c6a21 GL |
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 | ||
79c3e0e1 GL |
16 | // For compilers that support precompilation, includes "wx.h". |
17 | #include "wx/wxprec.h" | |
3d4c6a21 GL |
18 | #include <stdio.h> |
19 | #include <wx/stream.h> | |
20 | #include <wx/fstream.h> | |
21 | ||
79c3e0e1 GL |
22 | #ifdef __BORLANDC__ |
23 | #pragma hdrstop | |
24 | #endif | |
25 | ||
26 | ||
3d4c6a21 GL |
27 | #define BUF_TEMP_SIZE 10000 |
28 | ||
29 | #if !USE_SHARED_LIBRARY | |
79c3e0e1 GL |
30 | IMPLEMENT_CLASS(wxFileInputStream, wxInputStream) |
31 | IMPLEMENT_CLASS(wxFileOutputStream, wxOutputStream) | |
32 | IMPLEMENT_CLASS2(wxFileStream, wxInputStream, wxOutputStream) | |
3d4c6a21 GL |
33 | #endif |
34 | ||
79c3e0e1 GL |
35 | // ---------------------------------------------------------------------------- |
36 | // wxFileInputStream | |
37 | // ---------------------------------------------------------------------------- | |
38 | ||
39 | wxFileInputStream::wxFileInputStream(const wxString& fileName) | |
40 | : wxFile(fileName, read) | |
3d4c6a21 | 41 | { |
79c3e0e1 | 42 | m_lastread = 0; |
3d4c6a21 GL |
43 | } |
44 | ||
79c3e0e1 | 45 | wxFileInputStream::~wxFileInputStream() |
3d4c6a21 | 46 | { |
3d4c6a21 GL |
47 | } |
48 | ||
79c3e0e1 | 49 | wxInputStream& wxFileInputStream::Read(void *buffer, size_t size) |
3d4c6a21 | 50 | { |
79c3e0e1 | 51 | m_lastread = wxFile::Read(buffer, size); |
3d4c6a21 GL |
52 | return *this; |
53 | } | |
54 | ||
79c3e0e1 | 55 | off_t wxFileInputStream::SeekI(off_t pos, wxSeekMode mode) |
3d4c6a21 | 56 | { |
79c3e0e1 GL |
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; | |
3d4c6a21 GL |
73 | } |
74 | ||
79c3e0e1 | 75 | wxFileOutputStream::~wxFileOutputStream() |
3d4c6a21 | 76 | { |
79c3e0e1 | 77 | } |
3d4c6a21 | 78 | |
79c3e0e1 GL |
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 | } | |
3d4c6a21 | 85 | |
79c3e0e1 GL |
86 | off_t wxFileOutputStream::TellO() const |
87 | { | |
88 | return wxFile::Tell(); | |
3d4c6a21 GL |
89 | } |
90 | ||
79c3e0e1 | 91 | off_t wxFileOutputStream::SeekO(off_t pos, wxSeekMode mode) |
3d4c6a21 | 92 | { |
79c3e0e1 | 93 | return wxFile::Seek(pos, mode); |
3d4c6a21 GL |
94 | } |
95 | ||
79c3e0e1 | 96 | void wxFileOutputStream::Sync() |
3d4c6a21 | 97 | { |
79c3e0e1 | 98 | wxFile::Flush(); |
3d4c6a21 GL |
99 | } |
100 | ||
79c3e0e1 GL |
101 | // ---------------------------------------------------------------------------- |
102 | // wxFileStream | |
103 | // ---------------------------------------------------------------------------- | |
104 | ||
105 | wxFileStream::wxFileStream(const wxString& fileName) | |
106 | : wxFile(fileName, read_write) | |
3d4c6a21 | 107 | { |
3d4c6a21 GL |
108 | } |
109 | ||
79c3e0e1 | 110 | wxFileStream::~wxFileStream() |
3d4c6a21 | 111 | { |
3d4c6a21 | 112 | } |