X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0efe5ba76e45711cad627222905a55c7e04adf9a..878711c01c1b9ad5b97d35f379a048b8ce1bfb49:/src/common/ffile.cpp?ds=sidebyside diff --git a/src/common/ffile.cpp b/src/common/ffile.cpp index 4e1aea21ec..6b09f9876b 100644 --- a/src/common/ffile.cpp +++ b/src/common/ffile.cpp @@ -1,12 +1,12 @@ ///////////////////////////////////////////////////////////////////////////// // Name: ffile.cpp -// Purpose: wxFFile - encapsulates "FILE *" IO stream +// Purpose: wxFFile encapsulates "FILE *" IO stream // Author: Vadim Zeitlin // Modified by: // Created: 14.07.99 // RCS-ID: $Id$ // Copyright: (c) 1998 Vadim Zeitlin -// Licence: wxWindows license +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// // ============================================================================ @@ -28,7 +28,7 @@ #pragma hdrstop #endif -#if wxUSE_FILE +#if wxUSE_FFILE #ifndef WX_PRECOMP #include "wx/intl.h" @@ -45,18 +45,18 @@ // opening the file // ---------------------------------------------------------------------------- -wxFFile::wxFFile(const wxChar *filename, const char *mode) +wxFFile::wxFFile(const wxChar *filename, const wxChar *mode) { Detach(); (void)Open(filename, mode); } -bool wxFFile::Open(const wxChar *filename, const char *mode) +bool wxFFile::Open(const wxChar *filename, const wxChar *mode) { - wxASSERT_MSG( !m_fp, _T("should close or detach the old file first") ); + wxASSERT_MSG( !m_fp, wxT("should close or detach the old file first") ); - m_fp = fopen(filename, mode); + m_fp = wxFopen(filename, mode); if ( !m_fp ) { @@ -74,7 +74,7 @@ bool wxFFile::Close() { if ( IsOpened() ) { - if ( !fclose(m_fp) ) + if ( fclose(m_fp) != 0 ) { wxLogSysError(_("can't close file '%s'"), m_name.c_str()); @@ -93,8 +93,8 @@ bool wxFFile::Close() bool wxFFile::ReadAll(wxString *str) { - wxCHECK_MSG( str, FALSE, _T("invalid parameter") ); - wxCHECK_MSG( IsOpened(), FALSE, _T("can't read from closed file") ); + wxCHECK_MSG( str, FALSE, wxT("invalid parameter") ); + wxCHECK_MSG( IsOpened(), FALSE, wxT("can't read from closed file") ); clearerr(m_fp); @@ -123,8 +123,8 @@ bool wxFFile::ReadAll(wxString *str) size_t wxFFile::Read(void *pBuf, size_t nCount) { - wxCHECK_MSG( pBuf, FALSE, _T("invalid parameter") ); - wxCHECK_MSG( IsOpened(), FALSE, _T("can't read from closed file") ); + wxCHECK_MSG( pBuf, FALSE, wxT("invalid parameter") ); + wxCHECK_MSG( IsOpened(), FALSE, wxT("can't read from closed file") ); size_t nRead = fread(pBuf, 1, nCount, m_fp); if ( (nRead < nCount) && Error() ) @@ -137,8 +137,8 @@ size_t wxFFile::Read(void *pBuf, size_t nCount) size_t wxFFile::Write(const void *pBuf, size_t nCount) { - wxCHECK_MSG( pBuf, FALSE, _T("invalid parameter") ); - wxCHECK_MSG( IsOpened(), FALSE, _T("can't write to closed file") ); + wxCHECK_MSG( pBuf, FALSE, wxT("invalid parameter") ); + wxCHECK_MSG( IsOpened(), FALSE, wxT("can't write to closed file") ); size_t nWritten = fwrite(pBuf, 1, nCount, m_fp); if ( nWritten < nCount ) @@ -153,7 +153,9 @@ bool wxFFile::Flush() { if ( IsOpened() ) { - if ( !fflush(m_fp) ) + // fflush returns non-zero on error + // + if ( fflush(m_fp) ) { wxLogSysError(_("failed to flush the file '%s'"), m_name.c_str()); @@ -170,13 +172,13 @@ bool wxFFile::Flush() bool wxFFile::Seek(long ofs, wxSeekMode mode) { - wxCHECK_MSG( IsOpened(), FALSE, _T("can't seek on closed file") ); + wxCHECK_MSG( IsOpened(), FALSE, wxT("can't seek on closed file") ); int origin; switch ( mode ) { default: - wxFAIL_MSG(_T("unknown seek mode")); + wxFAIL_MSG(wxT("unknown seek mode")); // still fall through case wxFromStart: @@ -234,4 +236,4 @@ size_t wxFFile::Length() const return (size_t)-1; } -#endif // wxUSE_FILE +#endif // wxUSE_FFILE