]>
git.saurik.com Git - wxWidgets.git/blob - interface/ffile.h
04a8fbf9e319bc21fe703532852fa976ee4dcef2
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: documentation for wxFFile class
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
13 wxFFile implements buffered file I/O. This is a very small class designed to
14 minimize the overhead of using it - in fact, there is hardly any overhead at
15 all, but using it brings you automatic error checking and hides differences
16 between platforms and compilers. It wraps inside it a @c FILE * handle used
17 by standard C IO library (also known as @c stdio).
30 Opens a file with the given file pointer, which has already been opened.
36 The mode in which to open the file using standard C strings.
37 Note that you should use "b" flag if you use binary files under Windows
38 or the results might be unexpected due to automatic newline conversion done
42 An existing file descriptor, such as stderr.
45 wxFFile(const wxString
& filename
, const wxString
& mode
= "r");
50 Destructor will close the file.
52 NB: it is not virtual so you should @e not derive from wxFFile!
57 Attaches an existing file pointer to the wxFFile object.
59 The descriptor should be already opened and it will be closed by wxFFile
62 void Attach(FILE* fp
);
65 Closes the file and returns @true on success.
70 Get back a file pointer from wxFFile object -- the caller is responsible for
71 closing the file if this
72 descriptor is opened. IsOpened() will return @false after call to Detach().
77 Returns @true if the an attempt has been made to read @e past
80 Note that the behaviour of the file descriptor based class
81 wxFile is different as wxFile::Eof
82 will return @true here as soon as the last byte of the file has been
85 Also note that this method may only be called for opened files and may crash if
86 the file is not opened.
90 #define bool Eof() /* implementation is private */
93 Returns @true if an error has occurred on this file, similar to the standard
96 Please note that this method may only be called for opened files and may crash
97 if the file is not opened.
104 Flushes the file and returns @true on success.
109 Returns the type of the file. Possible return values are:
111 wxFileKind
GetKind();
114 Returns @true if the file is opened. Most of the methods of this class may
116 be used for an opened file.
121 Returns the length of the file.
123 wxFileOffset
Length();
126 Opens the file, returning @true if successful.
132 The mode in which to open the file.
134 bool Open(const wxString
& filename
, const wxString
& mode
= "r");
137 Reads the specified number of bytes into a buffer, returning the actual number
141 A buffer to receive the data.
144 The number of bytes to read.
146 @returns The number of bytes read.
148 size_t Read(void* buffer
, size_t count
);
153 Reads the entire contents of the file into a string.
156 String to read data into.
159 Conversion object to use in Unicode build; by default supposes
160 that file contents is encoded in UTF-8.
162 @returns @true if file was read successfully, @false otherwise.
164 bool ReadAll(wxString
* str
);
167 Seeks to the specified position and returns @true on success.
173 One of wxFromStart, wxFromEnd, wxFromCurrent.
175 bool Seek(wxFileOffset ofs
, wxSeekMode mode
= wxFromStart
);
178 Moves the file pointer to the specified number of bytes before the end of the
180 and returns @true on success.
183 Number of bytes before the end of the file.
185 bool SeekEnd(wxFileOffset ofs
= 0);
188 Returns the current position.
195 Writes the contents of the string to the file, returns @true on success.
197 The second argument is only meaningful in Unicode build of wxWidgets when
198 @e conv is used to convert @e s to multibyte representation.
200 bool Write(const wxString
& s
);
203 Returns the file pointer associated with the file.
205 #define FILE * fp() /* implementation is private */