X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/28f5082b3235a349ffc3b99eeacca5049ccd42dd..576acdf322ca427842e406bce5e84ceb4f0fbb8f:/src/common/file.cpp diff --git a/src/common/file.cpp b/src/common/file.cpp index af237f6a89..d5a136e704 100644 --- a/src/common/file.cpp +++ b/src/common/file.cpp @@ -153,18 +153,9 @@ bool wxFile::Exists(const wxChar *name) { wxStructStat st; -#if wxUSE_UNICODE && wxMBFILES - wxCharBuffer fname = wxConvFile.cWC2MB(name); - - return !wxAccess(fname, 0) && - !wxStat(wxMBSTRINGCAST fname, &st) && - (st.st_mode & S_IFREG); - -#else return !wxAccess(name, 0) && !wxStat(name, &st) && (st.st_mode & S_IFREG); -#endif } bool wxFile::Access(const wxChar *name, OpenMode mode) @@ -184,7 +175,7 @@ bool wxFile::Access(const wxChar *name, OpenMode mode) wxFAIL_MSG(wxT("bad wxFile::Access mode parameter.")); } - return wxAccess(wxFNCONV(name), how) == 0; + return wxAccess( name, how) == 0; } // ---------------------------------------------------------------------------- @@ -206,20 +197,22 @@ bool wxFile::Create(const wxChar *szFileName, bool bOverwrite, int accessMode) // if bOverwrite we create a new file or truncate the existing one, // otherwise we only create the new file and fail if it already exists #if defined(__WXMAC__) && !defined(__UNIX__) - // 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 = creat( szFileName , accessMode); + // 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 = creat( szFileName , accessMode); #else - int fd = wxOpen(wxFNCONV(szFileName), - O_BINARY | O_WRONLY | O_CREAT | - (bOverwrite ? O_TRUNC : O_EXCL) - ACCESS(accessMode)); + int fd = wxOpen( szFileName, + O_BINARY | O_WRONLY | O_CREAT | + (bOverwrite ? O_TRUNC : O_EXCL) + ACCESS(accessMode) ); #endif - if ( fd == -1 ) { + if ( fd == -1 ) + { wxLogSysError(_("can't create file '%s'"), szFileName); return FALSE; } - else { + else + { Attach(fd); return TRUE; } @@ -230,7 +223,8 @@ bool wxFile::Open(const wxChar *szFileName, OpenMode mode, int accessMode) { int flags = O_BINARY; - switch ( mode ) { + switch ( mode ) + { case read: flags |= O_RDONLY; break; @@ -257,8 +251,9 @@ bool wxFile::Open(const wxChar *szFileName, OpenMode mode, int accessMode) break; } - int fd = wxOpen(wxFNCONV(szFileName), flags ACCESS(accessMode)); - if ( fd == -1 ) { + int fd = wxOpen( szFileName, flags ACCESS(accessMode)); + if ( fd == -1 ) + { wxLogSysError(_("can't open file '%s'"), szFileName); return FALSE; } @@ -507,9 +502,9 @@ bool wxTempFile::Open(const wxString& strName) #ifdef __UNIX__ // the temp file should have the same permissions as the original one mode_t mode; - + wxStructStat st; - if ( stat(m_strName.fn_str(), &st) == 0 ) + if ( stat( (const char*) m_strName.fn_str(), &st) == 0 ) { mode = st.st_mode; } @@ -522,7 +517,7 @@ bool wxTempFile::Open(const wxString& strName) umask(mask); } - if ( chmod(m_strTemp.mb_str(), mode) == -1 ) + if ( chmod( (const char*) m_strTemp.fn_str(), mode) == -1 ) { wxLogSysError(_("Failed to set temporary file permissions")); }