X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/526954c5968baa29218c994ec48e476ae2bd4b9f..e733c4ce1e24cf7e4b0b0d8362fc59aaa7a7641c:/interface/wx/file.h diff --git a/interface/wx/file.h b/interface/wx/file.h index a33d0d675e..31ea6bdd4f 100644 --- a/interface/wx/file.h +++ b/interface/wx/file.h @@ -2,7 +2,6 @@ // Name: file.h // Purpose: interface of wxTempFile, wxFile // Author: wxWidgets team -// RCS-ID: $Id$ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -173,12 +172,12 @@ public: or test if it can be opened for writing with Access(). */ write, - /** Open file for reading and writing; can not be used with Access() */ + /** Open file for reading and writing; cannot be used with Access() */ read_write, /** Open file for appending: the file is opened for writing, but the old contents of the file are not erased and the file pointer is initially placed at the end - of the file; can not be used with Access(). + of the file; cannot be used with Access(). This is the same as OpenMode::write if the file doesn't exist. */ @@ -231,6 +230,32 @@ public: */ ~wxFile(); + /** + Returns the error code for the last unsuccessful operation. + + The error code is system-dependent and corresponds to the value of the + standard @c errno variable when the last error occurred. + + Notice that only simple accessors such as IsOpened() and Eof() (and + this method itself) don't modify the last error value, all other + methods can potentially change it if an error occurs, including the + const ones such as Tell() or Length(). + + @since 2.9.2 + + @see ClearLastError() + */ + int GetLastError() const; + + /** + Resets the error code. + + GetLastError() will return 0 until the next error occurs. + + @since 2.9.2 + */ + void ClearLastError(); + /** This function verifies if we may access the given file in specified mode. Only values of @c wxFile::read or @c wxFile::write really make sense here. @@ -270,8 +295,11 @@ public: Get back a file descriptor from wxFile object - the caller is responsible for closing the file if this descriptor is opened. IsOpened() will return @false after call to Detach(). + + @return The file descriptor (this is new since wxWidgets 3.0.0, in the + previous versions this method didn't return anything). */ - void Detach(); + int Detach(); /** Returns @true if the end of the file has been reached. @@ -346,6 +374,23 @@ public: */ ssize_t Read(void* buffer, size_t count); + /** + Reads the entire contents of the file into a string. + + @param str + Non-@NULL pointer to a string to read data into. + @param conv + Conversion object to use in Unicode build; by default supposes + that file contents is encoded in UTF-8 but falls back to the + current locale encoding (or Latin-1 if it is UTF-8 too) if it is + not. + + @return @true if file was read successfully, @false otherwise. + + @since 2.9.5 + */ + bool ReadAll(wxString* str, const wxMBConv& conv = wxConvAuto()); + /** Seeks to the specified position.