]>
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 | { | |
885ee235 | 47 | return wxFile::Read(buffer, size); |
6d44bf31 GL |
48 | } |
49 | ||
50 | off_t wxFileInputStream::DoSeekInput(off_t pos, wxSeekMode mode) | |
3d4c6a21 | 51 | { |
79c3e0e1 GL |
52 | return wxFile::Seek(pos, mode); |
53 | } | |
54 | ||
6d44bf31 | 55 | off_t wxFileInputStream::DoTellInput() const |
79c3e0e1 GL |
56 | { |
57 | return wxFile::Tell(); | |
58 | } | |
59 | ||
60 | // ---------------------------------------------------------------------------- | |
61 | // wxFileOutputStream | |
62 | // ---------------------------------------------------------------------------- | |
63 | ||
64 | wxFileOutputStream::wxFileOutputStream(const wxString& fileName) | |
65 | : wxFile(fileName, write) | |
66 | { | |
6d44bf31 | 67 | m_o_streambuf->SetBufferIO(1024); |
3d4c6a21 GL |
68 | } |
69 | ||
79c3e0e1 | 70 | wxFileOutputStream::~wxFileOutputStream() |
3d4c6a21 | 71 | { |
6d44bf31 | 72 | Sync(); |
79c3e0e1 | 73 | } |
3d4c6a21 | 74 | |
6d44bf31 | 75 | size_t wxFileOutputStream::DoWrite(const void *buffer, size_t size) |
79c3e0e1 | 76 | { |
6d44bf31 | 77 | size_t ret = wxFile::Write(buffer, size); |
79c3e0e1 | 78 | m_bad = wxFile::Error(); |
6d44bf31 | 79 | return ret; |
79c3e0e1 | 80 | } |
3d4c6a21 | 81 | |
6d44bf31 | 82 | off_t wxFileOutputStream::DoTellOutput() const |
79c3e0e1 GL |
83 | { |
84 | return wxFile::Tell(); | |
3d4c6a21 GL |
85 | } |
86 | ||
6d44bf31 | 87 | off_t wxFileOutputStream::DoSeekOutput(off_t pos, wxSeekMode mode) |
3d4c6a21 | 88 | { |
79c3e0e1 | 89 | return wxFile::Seek(pos, mode); |
3d4c6a21 GL |
90 | } |
91 | ||
79c3e0e1 | 92 | void wxFileOutputStream::Sync() |
3d4c6a21 | 93 | { |
6d44bf31 | 94 | wxOutputStream::Sync(); |
79c3e0e1 | 95 | wxFile::Flush(); |
3d4c6a21 GL |
96 | } |
97 | ||
79c3e0e1 GL |
98 | // ---------------------------------------------------------------------------- |
99 | // wxFileStream | |
100 | // ---------------------------------------------------------------------------- | |
101 | ||
102 | wxFileStream::wxFileStream(const wxString& fileName) | |
103 | : wxFile(fileName, read_write) | |
3d4c6a21 | 104 | { |
3d4c6a21 GL |
105 | } |
106 | ||
79c3e0e1 | 107 | wxFileStream::~wxFileStream() |
3d4c6a21 | 108 | { |
3d4c6a21 | 109 | } |