wxFileConfig in Unicode fixes
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@19289 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
8829fa8200
commit
67de05a11c
@ -120,11 +120,13 @@ public:
|
||||
const wxString& vendorName = wxT(""),
|
||||
const wxString& localFilename = wxT(""),
|
||||
const wxString& globalFilename = wxT(""),
|
||||
long style = wxCONFIG_USE_LOCAL_FILE);
|
||||
long style = wxCONFIG_USE_LOCAL_FILE,
|
||||
wxMBConv& conv = wxConvUTF8);
|
||||
|
||||
#if wxUSE_STREAMS
|
||||
// ctor that takes an input stream.
|
||||
wxFileConfig(wxInputStream &inStream);
|
||||
wxFileConfig(wxInputStream &inStream,
|
||||
wxMBConv& conv = wxConvUTF8);
|
||||
#endif // wxUSE_STREAMS
|
||||
|
||||
// dtor will save unsaved data
|
||||
@ -207,6 +209,8 @@ private:
|
||||
wxFileConfigGroup *m_pRootGroup, // the top (unnamed) group
|
||||
*m_pCurrentGroup; // the current group
|
||||
|
||||
wxMBConv &m_conv;
|
||||
|
||||
#ifdef __UNIX__
|
||||
int m_umask; // the umask to use for file creation
|
||||
#endif // __UNIX__
|
||||
|
@ -389,11 +389,7 @@ void wxFileConfig::Init()
|
||||
{
|
||||
wxTextFile fileGlobal(m_strGlobalFile);
|
||||
|
||||
#if defined(__WXGTK20__) && wxUSE_UNICODE
|
||||
if ( fileGlobal.Open( wxConvUTF8 ) )
|
||||
#else
|
||||
if ( fileGlobal.Open() )
|
||||
#endif
|
||||
if ( fileGlobal.Open(m_conv/*ignored in ANSI build*/) )
|
||||
{
|
||||
Parse(fileGlobal, FALSE /* global */);
|
||||
SetRootPath();
|
||||
@ -408,11 +404,7 @@ void wxFileConfig::Init()
|
||||
if ( !m_strLocalFile.IsEmpty() && wxFile::Exists(m_strLocalFile) )
|
||||
{
|
||||
wxTextFile fileLocal(m_strLocalFile);
|
||||
#if defined(__WXGTK20__) && wxUSE_UNICODE
|
||||
if ( fileLocal.Open( wxConvUTF8 ) )
|
||||
#else
|
||||
if ( fileLocal.Open() )
|
||||
#endif
|
||||
if ( fileLocal.Open(m_conv/*ignored in ANSI build*/) )
|
||||
{
|
||||
Parse(fileLocal, TRUE /* local */);
|
||||
SetRootPath();
|
||||
@ -427,11 +419,12 @@ void wxFileConfig::Init()
|
||||
// constructor supports creation of wxFileConfig objects of any type
|
||||
wxFileConfig::wxFileConfig(const wxString& appName, const wxString& vendorName,
|
||||
const wxString& strLocal, const wxString& strGlobal,
|
||||
long style)
|
||||
long style, wxMBConv& conv)
|
||||
: wxConfigBase(::GetAppName(appName), vendorName,
|
||||
strLocal, strGlobal,
|
||||
style),
|
||||
m_strLocalFile(strLocal), m_strGlobalFile(strGlobal)
|
||||
m_strLocalFile(strLocal), m_strGlobalFile(strGlobal),
|
||||
m_conv(conv)
|
||||
{
|
||||
// Make up names for files if empty
|
||||
if ( m_strLocalFile.IsEmpty() && (style & wxCONFIG_USE_LOCAL_FILE) )
|
||||
@ -474,7 +467,8 @@ wxFileConfig::wxFileConfig(const wxString& appName, const wxString& vendorName,
|
||||
|
||||
#if wxUSE_STREAMS
|
||||
|
||||
wxFileConfig::wxFileConfig(wxInputStream &inStream)
|
||||
wxFileConfig::wxFileConfig(wxInputStream &inStream, wxMBConv& conv)
|
||||
: m_conv(conv)
|
||||
{
|
||||
// always local_file when this constructor is called (?)
|
||||
SetStyle(GetStyle() | wxCONFIG_USE_LOCAL_FILE);
|
||||
@ -961,12 +955,7 @@ bool wxFileConfig::Flush(bool /* bCurrentOnly */)
|
||||
{
|
||||
wxString line = p->Text();
|
||||
line += wxTextFile::GetEOL();
|
||||
#if wxUSE_UNICODE
|
||||
wxCharBuffer buf = wxConvLocal.cWX2MB( line );
|
||||
if ( !file.Write( (const char*)buf, strlen( (const char*) buf ) ) )
|
||||
#else
|
||||
if ( !file.Write( line.c_str(), line.Len() ) )
|
||||
#endif
|
||||
if ( !file.Write(line, m_conv) )
|
||||
{
|
||||
wxLogError(_("can't write user configuration file."));
|
||||
return FALSE;
|
||||
|
Loading…
Reference in New Issue
Block a user