X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/87b6002d7c48dea4ebd53bbf60996d1a87a0a5c6..0d1f53ca16a9a794a7660561a5c5b4632f8675e0:/src/common/file.cpp diff --git a/src/common/file.cpp b/src/common/file.cpp index cf35fd1486..d6926e9cc6 100644 --- a/src/common/file.cpp +++ b/src/common/file.cpp @@ -202,7 +202,7 @@ bool wxFile::Access(const wxChar *name, OpenMode mode) #ifdef __WXWINCE__ // FIXME: use CreateFile with 0 access to query the file - return TRUE; + return true; #else return wxAccess(name, how) == 0; #endif @@ -216,7 +216,7 @@ bool wxFile::Access(const wxChar *name, OpenMode mode) wxFile::wxFile(const wxChar *szFileName, OpenMode mode) { m_fd = fd_invalid; - m_error = FALSE; + m_error = false; Open(szFileName, mode); } @@ -228,7 +228,7 @@ bool wxFile::Create(const wxChar *szFileName, bool bOverwrite, int accessMode) // 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__ @@ -250,12 +250,12 @@ bool wxFile::Create(const wxChar *szFileName, bool bOverwrite, int accessMode) if ( fd == -1 ) { wxLogSysError(_("can't create file '%s'"), szFileName); - return FALSE; + return false; } else { Attach(fd); - return TRUE; + return true; } } @@ -345,16 +345,23 @@ bool wxFile::Open(const wxChar *szFileName, OpenMode mode, int accessMode) 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; } } @@ -370,13 +377,13 @@ bool wxFile::Close() { 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; } // ---------------------------------------------------------------------------- @@ -431,7 +438,7 @@ size_t wxFile::Write(const void *pBuf, size_t nCount) #endif if ( iRc == -1 ) { wxLogSysError(_("can't write to file descriptor %d"), m_fd); - m_error = TRUE; + m_error = true; return 0; } else @@ -448,14 +455,14 @@ bool wxFile::Flush() 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; } // ---------------------------------------------------------------------------- @@ -599,11 +606,11 @@ bool wxFile::Eof() const 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; @@ -625,7 +632,7 @@ bool wxFile::Eof() const 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); @@ -635,7 +642,7 @@ bool wxFile::Eof() const wxFAIL_MSG(_("invalid eof() return value.")); } - return TRUE; + return true; #endif } @@ -674,13 +681,13 @@ bool wxTempFile::Open(const wxString& strName) 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 ) { @@ -703,7 +710,7 @@ bool wxTempFile::Open(const wxString& strName) } #endif // Unix - return TRUE; + return true; } // ---------------------------------------------------------------------------- @@ -722,15 +729,15 @@ bool wxTempFile::Commit() 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()