]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/ffile.h
   1 ///////////////////////////////////////////////////////////////////////////// 
   3 // Purpose:     interface of wxFFile 
   4 // Author:      wxWidgets team 
   6 // Licence:     wxWindows license 
   7 ///////////////////////////////////////////////////////////////////////////// 
  12     Values used for both wxFile and wxFFile. 
  14     @todo make the value names uppercase 
  24     See wxFFile::GetKind(). 
  29   wxFILE_KIND_DISK
,     /**< A file supporting seeking to arbitrary offsets. */ 
  30   wxFILE_KIND_TERMINAL
, /**< A terminal. */ 
  31   wxFILE_KIND_PIPE      
/**< A pipe. */ 
  38     wxFFile implements buffered file I/O. 
  40     This is a very small class designed to minimize the overhead of using it - in fact, 
  41     there is hardly any overhead at all, but using it brings you automatic error checking 
  42     and hides differences between platforms and compilers. 
  44     It wraps inside it a @c FILE * handle used by standard C IO library (also known as @c stdio). 
  49     @see wxFFile::IsOpened 
  57         Opens a file with the given file pointer, which has already been opened. 
  60             An existing file descriptor, such as stderr. 
  65         Opens a file with the given mode. 
  66         As there is no way to return whether the operation was successful or not from 
  67         the constructor you should test the return value of IsOpened() to check that it 
  73             The mode in which to open the file using standard C strings. 
  74             Note that you should use "b" flag if you use binary files under Windows 
  75             or the results might be unexpected due to automatic newline conversion done 
  78     wxFFile(const wxString
& filename
, const wxString
& mode 
= "r"); 
  82         Destructor will close the file. 
  84         @note it is not virtual so you should @e not derive from wxFFile! 
  89         Attaches an existing file pointer to the wxFFile object. 
  91         The descriptor should be already opened and it will be closed by wxFFile object. 
  93     void Attach(FILE* fp
, const wxString
& name 
= wxEmptyString
); 
  96         Closes the file and returns @true on success. 
 101         Get back a file pointer from wxFFile object -- the caller is responsible for 
 102         closing the file if this descriptor is opened. 
 104         IsOpened() will return @false after call to Detach(). 
 109         Returns @true if the an attempt has been made to read @e past 
 112         Note that the behaviour of the file descriptor based class  wxFile is different as 
 113         wxFile::Eof() will return @true here as soon as the last byte of the file has been read. 
 115         Also note that this method may only be called for opened files and may crash if 
 116         the file is not opened. 
 118         @todo THIS METHOD MAY CRASH? DOESN'T SOUND GOOD 
 125         Returns @true if an error has occurred on this file, similar to the standard 
 126         @c ferror() function. 
 128         Please note that this method may only be called for opened files and may crash 
 129         if the file is not opened. 
 131         @todo THIS METHOD MAY CRASH? DOESN'T SOUND GOOD 
 138         Flushes the file and returns @true on success. 
 143         Returns the type of the file. 
 147     wxFileKind 
GetKind() const; 
 150         Returns @true if the file is opened. 
 152         Most of the methods of this class may only be used for an opened file. 
 154     bool IsOpened() const; 
 157         Returns the length of the file. 
 159     wxFileOffset 
Length() const; 
 162         Opens the file, returning @true if successful. 
 167             The mode in which to open the file. 
 169     bool Open(const wxString
& filename
, const wxString
& mode 
= "r"); 
 172         Reads the specified number of bytes into a buffer, returning the actual number read. 
 175             A buffer to receive the data. 
 177             The number of bytes to read. 
 179         @return The number of bytes read. 
 181     size_t Read(void* buffer
, size_t count
); 
 184         Reads the entire contents of the file into a string. 
 187             String to read data into. 
 189             Conversion object to use in Unicode build; by default supposes 
 190             that file contents is encoded in UTF-8. 
 192         @return @true if file was read successfully, @false otherwise. 
 194     bool ReadAll(wxString
* str
, const wxMBConv
& conv 
= wxConvAuto()); 
 197         Seeks to the specified position and returns @true on success. 
 202             One of wxFromStart, wxFromEnd, wxFromCurrent. 
 204     bool Seek(wxFileOffset ofs
, wxSeekMode mode 
= wxFromStart
); 
 207         Moves the file pointer to the specified number of bytes before the end of the 
 208         file and returns @true on success. 
 211             Number of bytes before the end of the file. 
 213     bool SeekEnd(wxFileOffset ofs 
= 0); 
 216         Returns the current position. 
 218     wxFileOffset 
Tell() const; 
 221         Writes the contents of the string to the file, returns @true on success. 
 223         The second argument is only meaningful in Unicode build of wxWidgets when 
 224         @a conv is used to convert @a str to multibyte representation. 
 226     bool Write(const wxString
& str
, const wxMBConv
& conv 
= wxConvAuto()); 
 229         Writes the specified number of bytes from a buffer. 
 232             A buffer containing the data. 
 234             The number of bytes to write. 
 236         @return The number of bytes written. 
 238     size_t Write(const void* buffer
, size_t count
); 
 241         Returns the file pointer associated with the file.