]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/ffile.tex
new wxWindow::FindWindowByXXX() methods replacing the old global functions
[wxWidgets.git] / docs / latex / wx / ffile.tex
CommitLineData
f3845e88
VZ
1%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2%% Name: ffile.tex
3%% Purpose: wxFFile documentation
4%% Author: Vadim Zeitlin
5%% Modified by:
6%% Created: 14.01.02 (extracted from file.tex)
7%% RCS-ID: $Id$
8%% Copyright: (c) Vadim Zeitlin
9%% License: wxWindows license
10%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11
12\section{\class{wxFFile}}\label{wxffile}
13
14wxFFile implements buffered file I/O. This is a very small class designed to
15minimize the overhead of using it - in fact, there is hardly any overhead at
16all, but using it brings you automatic error checking and hides differences
17between platforms and compilers. It wraps inside it a {\tt FILE *} handle used
18by standard C IO library (also known as {\tt stdio}).
19
20\wxheading{Derived from}
21
22None.
23
24\wxheading{Include files}
25
26<wx/ffile.h>
27
28\twocolwidtha{7cm}
29\begin{twocollist}\itemsep=0pt%
30\twocolitem{{\bf wxFromStart}}{Count offset from the start of the file}
31\twocolitem{{\bf wxFromCurrent}}{Count offset from the current position of the file pointer}
32\twocolitem{{\bf wxFromEnd}}{Count offset from the end of the file (backwards)}
33\end{twocollist}
34
35\latexignore{\rtfignore{\wxheading{Members}}}
36
37\membersection{wxFFile::wxFFile}\label{wxffileconstr}
38
39\func{}{wxFFile}{\void}
40
41Default constructor.
42
43\func{}{wxFFile}{\param{const char*}{ filename}, \param{const char*}{ mode = "r"}}
44
45Opens a file with the given mode. As there is no way to return whether the
46operation was successful or not from the constructor you should test the
47return value of \helpref{IsOpened}{wxffileisopened} to check that it didn't
48fail.
49
50\func{}{wxFFile}{\param{FILE*}{ fp}}
51
52Opens a file with the given file pointer, which has already been opened.
53
54\wxheading{Parameters}
55
56\docparam{filename}{The filename.}
57
58\docparam{mode}{The mode in which to open the file using standard C strings.
59Note that you should use {\tt "b"} flag if you use binary files under Windows
60or the results might be unexpected due to automatic newline conversion done
61for the text files.}
62
63\docparam{fp}{An existing file descriptor, such as stderr.}
64
65\membersection{wxFFile::\destruct{wxFFile}}
66
67\func{}{\destruct{wxFFile}}{\void}
68
69Destructor will close the file.
70
71NB: it is not virtual so you should {\it not} derive from wxFFile!
72
73\membersection{wxFFile::Attach}\label{wxffileattach}
74
75\func{void}{Attach}{\param{FILE*}{ fp}}
76
77Attaches an existing file pointer to the wxFFile object.
78
79The descriptor should be already opened and it will be closed by wxFFile
80object.
81
82\membersection{wxFFile::Close}\label{wxffileclose}
83
84\func{bool}{Close}{\void}
85
86Closes the file and returns TRUE on success.
87
88\membersection{wxFFile::Detach}\label{wxffiledetach}
89
90\func{void}{Detach}{\void}
91
92Get back a file pointer from wxFFile object - the caller is responsible for closing the file if this
93descriptor is opened. \helpref{IsOpened()}{wxffileisopened} will return FALSE after call to Detach().
94
95\membersection{wxFFile::fp}\label{wxffilefp}
96
97\constfunc{FILE *}{fp}{\void}
98
99Returns the file pointer associated with the file.
100
101\membersection{wxFFile::Eof}\label{wxffileeof}
102
103\constfunc{bool}{Eof}{\void}
104
105Returns TRUE if the an attempt has been made to read {\it past}
106the end of the file.
107
108Note that the behaviour of the file descriptor based class
109\helpref{wxFile}{wxfile} is different as \helpref{wxFile::Eof}{wxfileeof}
110will return TRUE here as soon as the last byte of the file has been
111read.
112
113\membersection{wxFFile::Flush}\label{wxffileflush}
114
115\func{bool}{Flush}{\void}
116
117Flushes the file and returns TRUE on success.
118
119\membersection{wxFFile::IsOpened}\label{wxffileisopened}
120
121\constfunc{bool}{IsOpened}{\void}
122
123Returns TRUE if the file has been opened.
124
125\membersection{wxFFile::Length}\label{wxffilelength}
126
127\constfunc{size\_t}{Length}{\void}
128
129Returns the length of the file.
130
131\membersection{wxFFile::Open}\label{wxffileopen}
132
133\func{bool}{Open}{\param{const char*}{ filename}, \param{const char*}{ mode = "r"}}
134
135Opens the file, returning TRUE if successful.
136
137\wxheading{Parameters}
138
139\docparam{filename}{The filename.}
140
141\docparam{mode}{The mode in which to open the file.}
142
143\membersection{wxFFile::Read}\label{wxffileread}
144
145\func{size\_t}{Read}{\param{void*}{ buffer}, \param{off\_t}{ count}}
146
147Reads the specified number of bytes into a buffer, returning the actual number read.
148
149\wxheading{Parameters}
150
151\docparam{buffer}{A buffer to receive the data.}
152
153\docparam{count}{The number of bytes to read.}
154
155\wxheading{Return value}
156
157The number of bytes read.
158
159\membersection{wxFFile::Seek}\label{wxffileseek}
160
161\func{bool}{Seek}{\param{long }{ofs}, \param{wxSeekMode }{mode = wxFromStart}}
162
163Seeks to the specified position and returs TRUE on success.
164
165\wxheading{Parameters}
166
167\docparam{ofs}{Offset to seek to.}
168
169\docparam{mode}{One of {\bf wxFromStart}, {\bf wxFromEnd}, {\bf wxFromCurrent}.}
170
171\membersection{wxFFile::SeekEnd}\label{wxffileseekend}
172
173\func{bool}{SeekEnd}{\param{long }{ofs = 0}}
174
175Moves the file pointer to the specified number of bytes before the end of the file
176and returns TRUE on success.
177
178\wxheading{Parameters}
179
180\docparam{ofs}{Number of bytes before the end of the file.}
181
182\membersection{wxFFile::Tell}\label{wxffiletell}
183
184\constfunc{size\_t}{Tell}{\void}
185
186Returns the current position.
187
188\membersection{wxFFile::Write}\label{wxffilewrite}
189
190\func{size\_t}{Write}{\param{const void*}{ buffer}, \param{size\_t}{ count}}
191
192Writes the specified number of bytes from a buffer.
193
194\wxheading{Parameters}
195
196\docparam{buffer}{A buffer containing the data.}
197
198\docparam{count}{The number of bytes to write.}
199
200\wxheading{Return value}
201
202Number of bytes written.
203
204\membersection{wxFFile::Write}\label{wxffilewrites}
205
7af3ca16 206\func{bool}{Write}{\param{const wxString\& }{s}, \param{wxMBConv\&}{ conv = wxConvLibc}}
f3845e88
VZ
207
208Writes the contents of the string to the file, returns TRUE on success.
209
210The second argument is only meaningful in Unicode build of wxWindows when
211{\it conv} is used to convert {\it s} to multibyte representation.
212
213