]>
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 | ||
79c3e0e1 GL |
26 | // ---------------------------------------------------------------------------- |
27 | // wxFileInputStream | |
28 | // ---------------------------------------------------------------------------- | |
29 | ||
30 | wxFileInputStream::wxFileInputStream(const wxString& fileName) | |
31 | : wxFile(fileName, read) | |
3d4c6a21 | 32 | { |
6d44bf31 | 33 | m_i_streambuf->SetBufferIO(1024); |
3d4c6a21 GL |
34 | } |
35 | ||
79c3e0e1 | 36 | wxFileInputStream::~wxFileInputStream() |
3d4c6a21 | 37 | { |
3d4c6a21 GL |
38 | } |
39 | ||
6d44bf31 | 40 | char wxFileInputStream::Peek() |
3d4c6a21 | 41 | { |
6d44bf31 | 42 | return 0; |
3d4c6a21 GL |
43 | } |
44 | ||
6d44bf31 GL |
45 | size_t wxFileInputStream::DoRead(void *buffer, size_t size) |
46 | { | |
7a4b9130 GL |
47 | size_t ret = wxFile::Read(buffer, size); |
48 | m_eof = wxFile::Eof(); | |
49 | ||
50 | return ret; | |
6d44bf31 GL |
51 | } |
52 | ||
53 | off_t wxFileInputStream::DoSeekInput(off_t pos, wxSeekMode mode) | |
3d4c6a21 | 54 | { |
79c3e0e1 GL |
55 | return wxFile::Seek(pos, mode); |
56 | } | |
57 | ||
6d44bf31 | 58 | off_t wxFileInputStream::DoTellInput() const |
79c3e0e1 GL |
59 | { |
60 | return wxFile::Tell(); | |
61 | } | |
62 | ||
63 | // ---------------------------------------------------------------------------- | |
64 | // wxFileOutputStream | |
65 | // ---------------------------------------------------------------------------- | |
66 | ||
67 | wxFileOutputStream::wxFileOutputStream(const wxString& fileName) | |
68 | : wxFile(fileName, write) | |
69 | { | |
6d44bf31 | 70 | m_o_streambuf->SetBufferIO(1024); |
3d4c6a21 GL |
71 | } |
72 | ||
79c3e0e1 | 73 | wxFileOutputStream::~wxFileOutputStream() |
3d4c6a21 | 74 | { |
6d44bf31 | 75 | Sync(); |
79c3e0e1 | 76 | } |
3d4c6a21 | 77 | |
6d44bf31 | 78 | size_t wxFileOutputStream::DoWrite(const void *buffer, size_t size) |
79c3e0e1 | 79 | { |
6d44bf31 | 80 | size_t ret = wxFile::Write(buffer, size); |
79c3e0e1 | 81 | m_bad = wxFile::Error(); |
6d44bf31 | 82 | return ret; |
79c3e0e1 | 83 | } |
3d4c6a21 | 84 | |
6d44bf31 | 85 | off_t wxFileOutputStream::DoTellOutput() const |
79c3e0e1 GL |
86 | { |
87 | return wxFile::Tell(); | |
3d4c6a21 GL |
88 | } |
89 | ||
6d44bf31 | 90 | off_t wxFileOutputStream::DoSeekOutput(off_t pos, wxSeekMode mode) |
3d4c6a21 | 91 | { |
79c3e0e1 | 92 | return wxFile::Seek(pos, mode); |
3d4c6a21 GL |
93 | } |
94 | ||
79c3e0e1 | 95 | void wxFileOutputStream::Sync() |
3d4c6a21 | 96 | { |
6d44bf31 | 97 | wxOutputStream::Sync(); |
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 | } |