// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
+/*
+ TODO: remove all the WinCE ugliness from here, implement the wxOpen(),
+ wxSeek(), ... functions in a separate file for WinCE instead!!!
+ */
+
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
-#ifdef __GNUG__
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "file.h"
#endif
#elif defined(__WXMSW__) && defined(__WXWINCE__)
// TODO: what to include?
+#elif (defined(__OS2__))
+ #include <io.h>
#elif (defined(__UNIX__) || defined(__GNUWIN32__))
#include <unistd.h>
+ #include <time.h>
#include <sys/stat.h>
#ifdef __GNUWIN32__
- #include <windows.h>
+ #include "wx/msw/wrapwin.h"
#endif
#elif defined(__DOS__)
#if defined(__WATCOMC__)
#else
#error "Please specify the header with file functions declarations."
#endif
-#elif (defined(__WXPM__))
- #include <io.h>
#elif (defined(__WXSTUBS__))
// Have to ifdef this for different environments
#include <io.h>
#define ACCESS(access) , (access)
#endif // Salford C
-// wxWindows
+// wxWidgets
#ifndef WX_PRECOMP
#include "wx/string.h"
#include "wx/intl.h"
break;
}
+#ifdef __WINDOWS__
+ // only read/write bits for "all" are supported by this function under
+ // Windows, and VC++ 8 returns EINVAL if any other bits are used in
+ // accessMode, so clear them as they have at best no effect anyhow
+ accessMode &= wxS_IRUSR | wxS_IWUSR;
+#endif // __WINDOWS__
+
int fd = wxOpen( szFileName, flags ACCESS(accessMode));
#endif
if ( fd == -1 )
wxCHECK( (pBuf != NULL) && IsOpened(), 0 );
#ifdef __WXWINCE__
- DWORD bytesRead = 0;
+ DWORD bytesWritten = 0;
int iRc = 0;
- if (WriteFile((HANDLE) m_fd, pBuf, (DWORD) nCount, & bytesRead, NULL))
- iRc = bytesRead;
+ if (WriteFile((HANDLE) m_fd, pBuf, (DWORD) nCount, & bytesWritten, NULL))
+ iRc = bytesWritten;
else
iRc = -1;
#elif defined(__MWERKS__)
if ( chmod( (const char*) m_strTemp.fn_str(), mode) == -1 )
{
+#ifndef __OS2__
wxLogSysError(_("Failed to set temporary file permissions"));
+#endif
}
#endif // Unix
return FALSE;
}
- if ( wxRenameFile(m_strTemp, m_strName) != 0 ) {
+ if ( !wxRenameFile(m_strTemp, m_strName) ) {
wxLogSysError(_("can't commit changes to file '%s'"), m_strName.c_str());
return FALSE;
}