From 766fc092881a3095587161c1a6c48f636a91de04 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Wed, 9 Dec 2009 07:38:22 +0000 Subject: [PATCH] avoiding string conversions on 1st param of wxStat, as the latter is having a param of wxString now always and does the conversion internally git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62834 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/filefn.cpp | 2 +- src/common/filename.cpp | 17 +++++------------ src/common/utilscmn.cpp | 2 +- src/generic/filectrlg.cpp | 6 ------ src/unix/dir.cpp | 2 +- 5 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/common/filefn.cpp b/src/common/filefn.cpp index eb7c74a968..2b3314abce 100644 --- a/src/common/filefn.cpp +++ b/src/common/filefn.cpp @@ -1079,7 +1079,7 @@ wxCopyFile (const wxString& file1, const wxString& file2, bool overwrite) wxStructStat fbuf; // get permissions of file1 - if ( wxStat( file1.c_str(), &fbuf) != 0 ) + if ( wxStat( file1, &fbuf) != 0 ) { // the file probably doesn't exist or we haven't the rights to read // from it anyhow diff --git a/src/common/filename.cpp b/src/common/filename.cpp index ce4e9f2d31..917c89de0f 100644 --- a/src/common/filename.cpp +++ b/src/common/filename.cpp @@ -621,16 +621,13 @@ bool wxFileName::FileExists( const wxString &filePath ) #define S_ISREG(mode) ((mode) & S_IFREG) #endif wxStructStat st; -#ifndef wxNEED_WX_UNISTD_H - return (wxStat( filePath.fn_str() , &st) == 0 && S_ISREG(st.st_mode)) + + return (wxStat( filePath, &st) == 0 && S_ISREG(st.st_mode)) #ifdef __OS2__ || (errno == EACCES) // if access is denied something with that name // exists and is opened in exclusive mode. #endif ; -#else - return wxStat( filePath , &st) == 0 && S_ISREG(st.st_mode); -#endif #endif // __WIN32__/!__WIN32__ } @@ -688,10 +685,10 @@ bool wxFileName::DirExists( const wxString &dirPath ) wxStructStat st; #ifndef __VISAGECPP__ - return wxStat(strPath.c_str(), &st) == 0 && ((st.st_mode & S_IFMT) == S_IFDIR); + return wxStat(strPath, &st) == 0 && ((st.st_mode & S_IFMT) == S_IFDIR); #else // S_IFMT not supported in VA compilers.. st_mode is a 2byte value only - return wxStat(strPath.c_str(), &st) == 0 && (st.st_mode == S_IFDIR); + return wxStat(strPath, &st) == 0 && (st.st_mode == S_IFDIR); #endif #endif // __WIN32__/!__WIN32__ @@ -2587,7 +2584,7 @@ bool wxFileName::GetTimes(wxDateTime *dtAccess, #elif defined(__UNIX_LIKE__) || defined(__WXMAC__) || defined(__OS2__) || (defined(__DOS__) && defined(__WATCOMC__)) // no need to test for IsDir() here wxStructStat stBuf; - if ( wxStat( GetFullPath().c_str(), &stBuf) == 0 ) + if ( wxStat( GetFullPath(), &stBuf) == 0 ) { if ( dtAccess ) dtAccess->Set(stBuf.st_atime); @@ -2641,11 +2638,7 @@ wxULongLong wxFileName::GetSize(const wxString &filename) return wxULongLong(lpFileSizeHigh, ret); #else // ! __WIN32__ wxStructStat st; -#ifndef wxNEED_WX_UNISTD_H - if (wxStat( filename.fn_str() , &st) != 0) -#else if (wxStat( filename, &st) != 0) -#endif return wxInvalidSize; return wxULongLong(st.st_size); #endif diff --git a/src/common/utilscmn.cpp b/src/common/utilscmn.cpp index ad0c64ef16..ecac6df476 100644 --- a/src/common/utilscmn.cpp +++ b/src/common/utilscmn.cpp @@ -943,7 +943,7 @@ bool wxSetDetectableAutoRepeat( bool WXUNUSED(flag) ) bool wxDoLaunchDefaultBrowser(const wxString& url, const wxString& scheme, int flags); #elif defined(__WXX11__) || defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXCOCOA__) || \ - (defined(__WXMAC__) && !defined(__WXOSX_IPHONE__)) + (defined(__WXOSX__) ) // implemented in a port-specific utils source file: bool wxDoLaunchDefaultBrowser(const wxString& url, int flags); diff --git a/src/generic/filectrlg.cpp b/src/generic/filectrlg.cpp index 172eda6d2f..3ab54d312b 100644 --- a/src/generic/filectrlg.cpp +++ b/src/generic/filectrlg.cpp @@ -226,13 +226,7 @@ void wxFileData::ReadData() lstat( m_filePath.fn_str(), &buff ); m_type |= S_ISLNK(buff.st_mode) ? is_link : 0; #else // no lstat() - // only translate to file charset if we don't go by our - // wxStat implementation -#ifndef wxNEED_WX_UNISTD_H - wxStat( m_filePath.fn_str() , &buff ); -#else wxStat( m_filePath, &buff ); -#endif #endif m_type |= (buff.st_mode & S_IFDIR) != 0 ? is_dir : 0; diff --git a/src/unix/dir.cpp b/src/unix/dir.cpp index 31270d04a5..5a0554edf4 100644 --- a/src/unix/dir.cpp +++ b/src/unix/dir.cpp @@ -304,7 +304,7 @@ bool wxDir::HasSubDirs(const wxString& spec) const // caller will learn it soon enough when it calls GetFirst(wxDIR) // anyhow wxStructStat stBuf; - if ( wxStat(M_DIR->GetName().c_str(), &stBuf) == 0 ) + if ( wxStat(M_DIR->GetName(), &stBuf) == 0 ) { switch ( stBuf.st_nlink ) { -- 2.45.2