[wx-dev] Re: SVN:(SC) [51735] adding filename conversion for wxStat

Stefan Csomor csomor at advancedconcepts.ch
Thu Feb 14 09:20:04 PST 2008


Hi Vadim

> [I assume we're speaking about 2.8 here as everything seems correct in the
>  trunk where wxStat() takes wxString anyhow]

that's correct

> SC> The way the code WAS,
> SC> 
> SC>     if ( wxStat( GetFullPath().c_str()
> 
>  This is clearly wrong because wxConvFile is not going to be used.
> 
> SC> #ifndef wxNEED_WX_UNISTD_H
> SC>     if ( wxStat( GetFullPath().fn_str() ..
> SC> #else
> SC>     if ( wxStat( GetFullPath() ..
> SC> #endif
> 
>  Ok, I see the problem: wxStat() defined in wxNEED_WX_UNISTD_H branch
> should take "const char *" and not "const wxChar *" if wxMBFILES. This
> would allow writing just
> 
> if ( wxStat( GetFullPath().fn_str() ...
> 
> which is clearly the expected correct alternative.
> 
>  So what about just adding trivial "char *" overloads (we need to keep
> "wxChar *" (which are really "wchar_t *" in this case) ones to avoid
> breaking the ABI)? This would allow us to write the code in a natural way.

just watch out that we don't convert again in the method's body, as we do
now, which would result in applying wxConvFile twice (once in the fn_str()
and once in the wxStat's body)

> SC>     if( stat( GetFullPath().fn_str()
> 
>  This is correct too if the code is compiled only on the platforms which
> have stat() (and not _stat() or whatever).

Thanks,

Stefan







More information about the wx-dev mailing list