#ifdef __WXWINCE__
// FIXME: use CreateFile with 0 access to query the file
- return TRUE;
+ return true;
#else
return wxAccess(name, how) == 0;
#endif
wxFile::wxFile(const wxChar *szFileName, OpenMode mode)
{
m_fd = fd_invalid;
- m_error = FALSE;
+ m_error = false;
Open(szFileName, mode);
}
// otherwise we only create the new file and fail if it already exists
#if defined(__WXMAC__) && !defined(__UNIX__) && !wxUSE_UNICODE
// Dominic Mazzoni [dmazzoni+@cs.cmu.edu] reports that open is still broken on the mac, so we replace
- // int fd = open(wxUnix2MacFilename( szFileName ), O_CREAT | (bOverwrite ? O_TRUNC : O_EXCL), access);
+ // int fd = open( szFileName , O_CREAT | (bOverwrite ? O_TRUNC : O_EXCL), access);
int fd = creat( szFileName , accessMode);
#else
#ifdef __WXWINCE__
if ( fd == -1 )
{
wxLogSysError(_("can't create file '%s'"), szFileName);
- return FALSE;
+ return false;
}
else
{
Attach(fd);
- return TRUE;
+ return true;
}
}
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 )
{
wxLogSysError(_("can't open file '%s'"), szFileName);
- return FALSE;
+ return false;
}
else {
Attach(fd);
- return TRUE;
+ return true;
}
}
{
wxLogSysError(_("can't close file descriptor %d"), m_fd);
m_fd = fd_invalid;
- return FALSE;
+ return false;
}
else
m_fd = fd_invalid;
}
- return TRUE;
+ return true;
}
// ----------------------------------------------------------------------------
#endif
if ( iRc == -1 ) {
wxLogSysError(_("can't write to file descriptor %d"), m_fd);
- m_error = TRUE;
+ m_error = true;
return 0;
}
else
if ( wxFsync(m_fd) == -1 )
{
wxLogSysError(_("can't flush file descriptor %d"), m_fd);
- return FALSE;
+ return false;
}
#else // no fsync
// just do nothing
#endif // fsync
}
- return TRUE;
+ return true;
}
// ----------------------------------------------------------------------------
DWORD off0 = SetFilePointer((HANDLE) m_fd, 0, 0, FILE_CURRENT);
DWORD off1 = SetFilePointer((HANDLE) m_fd, 0, 0, FILE_END);
if (off0 == off1)
- return TRUE;
+ return true;
else
{
SetFilePointer((HANDLE) m_fd, off0, 0, FILE_BEGIN);
- return FALSE;
+ return false;
}
#else
int iRc;
break;
case 0:
- return FALSE;
+ return false;
case -1:
wxLogSysError(_("can't determine if the end of file is reached on descriptor %d"), m_fd);
wxFAIL_MSG(_("invalid eof() return value."));
}
- return TRUE;
+ return true;
#endif
}
if ( m_strTemp.empty() )
{
// CreateTempFileName() failed
- return FALSE;
+ return false;
}
#ifdef __UNIX__
// the temp file should have the same permissions as the original one
mode_t mode;
-
+
wxStructStat st;
if ( stat( (const char*) m_strName.fn_str(), &st) == 0 )
{
}
#endif // Unix
- return TRUE;
+ return true;
}
// ----------------------------------------------------------------------------
if ( wxFile::Exists(m_strName) && wxRemove(m_strName) != 0 ) {
wxLogSysError(_("can't remove file '%s'"), m_strName.c_str());
- return FALSE;
+ return false;
}
if ( !wxRenameFile(m_strTemp, m_strName) ) {
wxLogSysError(_("can't commit changes to file '%s'"), m_strName.c_str());
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
void wxTempFile::Discard()