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:
@@ -120,11 +120,13 @@ public:
|
|||||||
const wxString& vendorName = wxT(""),
|
const wxString& vendorName = wxT(""),
|
||||||
const wxString& localFilename = wxT(""),
|
const wxString& localFilename = wxT(""),
|
||||||
const wxString& globalFilename = wxT(""),
|
const wxString& globalFilename = wxT(""),
|
||||||
long style = wxCONFIG_USE_LOCAL_FILE);
|
long style = wxCONFIG_USE_LOCAL_FILE,
|
||||||
|
wxMBConv& conv = wxConvUTF8);
|
||||||
|
|
||||||
#if wxUSE_STREAMS
|
#if wxUSE_STREAMS
|
||||||
// ctor that takes an input stream.
|
// ctor that takes an input stream.
|
||||||
wxFileConfig(wxInputStream &inStream);
|
wxFileConfig(wxInputStream &inStream,
|
||||||
|
wxMBConv& conv = wxConvUTF8);
|
||||||
#endif // wxUSE_STREAMS
|
#endif // wxUSE_STREAMS
|
||||||
|
|
||||||
// dtor will save unsaved data
|
// dtor will save unsaved data
|
||||||
@@ -207,6 +209,8 @@ private:
|
|||||||
wxFileConfigGroup *m_pRootGroup, // the top (unnamed) group
|
wxFileConfigGroup *m_pRootGroup, // the top (unnamed) group
|
||||||
*m_pCurrentGroup; // the current group
|
*m_pCurrentGroup; // the current group
|
||||||
|
|
||||||
|
wxMBConv &m_conv;
|
||||||
|
|
||||||
#ifdef __UNIX__
|
#ifdef __UNIX__
|
||||||
int m_umask; // the umask to use for file creation
|
int m_umask; // the umask to use for file creation
|
||||||
#endif // __UNIX__
|
#endif // __UNIX__
|
||||||
|
@@ -389,11 +389,7 @@ void wxFileConfig::Init()
|
|||||||
{
|
{
|
||||||
wxTextFile fileGlobal(m_strGlobalFile);
|
wxTextFile fileGlobal(m_strGlobalFile);
|
||||||
|
|
||||||
#if defined(__WXGTK20__) && wxUSE_UNICODE
|
if ( fileGlobal.Open(m_conv/*ignored in ANSI build*/) )
|
||||||
if ( fileGlobal.Open( wxConvUTF8 ) )
|
|
||||||
#else
|
|
||||||
if ( fileGlobal.Open() )
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
Parse(fileGlobal, FALSE /* global */);
|
Parse(fileGlobal, FALSE /* global */);
|
||||||
SetRootPath();
|
SetRootPath();
|
||||||
@@ -408,11 +404,7 @@ void wxFileConfig::Init()
|
|||||||
if ( !m_strLocalFile.IsEmpty() && wxFile::Exists(m_strLocalFile) )
|
if ( !m_strLocalFile.IsEmpty() && wxFile::Exists(m_strLocalFile) )
|
||||||
{
|
{
|
||||||
wxTextFile fileLocal(m_strLocalFile);
|
wxTextFile fileLocal(m_strLocalFile);
|
||||||
#if defined(__WXGTK20__) && wxUSE_UNICODE
|
if ( fileLocal.Open(m_conv/*ignored in ANSI build*/) )
|
||||||
if ( fileLocal.Open( wxConvUTF8 ) )
|
|
||||||
#else
|
|
||||||
if ( fileLocal.Open() )
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
Parse(fileLocal, TRUE /* local */);
|
Parse(fileLocal, TRUE /* local */);
|
||||||
SetRootPath();
|
SetRootPath();
|
||||||
@@ -427,11 +419,12 @@ void wxFileConfig::Init()
|
|||||||
// constructor supports creation of wxFileConfig objects of any type
|
// constructor supports creation of wxFileConfig objects of any type
|
||||||
wxFileConfig::wxFileConfig(const wxString& appName, const wxString& vendorName,
|
wxFileConfig::wxFileConfig(const wxString& appName, const wxString& vendorName,
|
||||||
const wxString& strLocal, const wxString& strGlobal,
|
const wxString& strLocal, const wxString& strGlobal,
|
||||||
long style)
|
long style, wxMBConv& conv)
|
||||||
: wxConfigBase(::GetAppName(appName), vendorName,
|
: wxConfigBase(::GetAppName(appName), vendorName,
|
||||||
strLocal, strGlobal,
|
strLocal, strGlobal,
|
||||||
style),
|
style),
|
||||||
m_strLocalFile(strLocal), m_strGlobalFile(strGlobal)
|
m_strLocalFile(strLocal), m_strGlobalFile(strGlobal),
|
||||||
|
m_conv(conv)
|
||||||
{
|
{
|
||||||
// Make up names for files if empty
|
// Make up names for files if empty
|
||||||
if ( m_strLocalFile.IsEmpty() && (style & wxCONFIG_USE_LOCAL_FILE) )
|
if ( m_strLocalFile.IsEmpty() && (style & wxCONFIG_USE_LOCAL_FILE) )
|
||||||
@@ -474,7 +467,8 @@ wxFileConfig::wxFileConfig(const wxString& appName, const wxString& vendorName,
|
|||||||
|
|
||||||
#if wxUSE_STREAMS
|
#if wxUSE_STREAMS
|
||||||
|
|
||||||
wxFileConfig::wxFileConfig(wxInputStream &inStream)
|
wxFileConfig::wxFileConfig(wxInputStream &inStream, wxMBConv& conv)
|
||||||
|
: m_conv(conv)
|
||||||
{
|
{
|
||||||
// always local_file when this constructor is called (?)
|
// always local_file when this constructor is called (?)
|
||||||
SetStyle(GetStyle() | wxCONFIG_USE_LOCAL_FILE);
|
SetStyle(GetStyle() | wxCONFIG_USE_LOCAL_FILE);
|
||||||
@@ -961,12 +955,7 @@ bool wxFileConfig::Flush(bool /* bCurrentOnly */)
|
|||||||
{
|
{
|
||||||
wxString line = p->Text();
|
wxString line = p->Text();
|
||||||
line += wxTextFile::GetEOL();
|
line += wxTextFile::GetEOL();
|
||||||
#if wxUSE_UNICODE
|
if ( !file.Write(line, m_conv) )
|
||||||
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
|
|
||||||
{
|
{
|
||||||
wxLogError(_("can't write user configuration file."));
|
wxLogError(_("can't write user configuration file."));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
Reference in New Issue
Block a user