From 04af2f5ce39da0adc94f0786a26c80fd1ea8a685 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 18 Jan 2007 22:38:21 +0000 Subject: [PATCH] added wxCONFIG_USE_SUBDIR flag to wxFileConfig (patch 1620876) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44255 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + docs/latex/wx/config.tex | 36 ++++++++++++++++++++++++------------ include/wx/confbase.h | 3 ++- src/common/fileconf.cpp | 6 ++++++ 4 files changed, 33 insertions(+), 13 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 4e21d3a8f2..765c2ab953 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -97,6 +97,7 @@ All: - Added wxCSConv::IsOk() (Manuel Martin) - Added wxDateTime::GetDateOnly() - Made wxTextFile work with unseekable files again (David Hart) +- Added wxCONFIG_USE_SUBDIR flag to wxFileConfig (Giuseppe Bilotta) wxMSW diff --git a/docs/latex/wx/config.tex b/docs/latex/wx/config.tex index 3700a8ec72..d944febb1d 100644 --- a/docs/latex/wx/config.tex +++ b/docs/latex/wx/config.tex @@ -377,18 +377,30 @@ this is not present, but required, the application name will be used instead.} \docparam{style}{Can be one of wxCONFIG\_USE\_LOCAL\_FILE and wxCONFIG\_USE\_GLOBAL\_FILE. The style interpretation depends on the config -class and is ignored by some. For wxFileConfig, these styles determine whether -a local or global config file is created or used. If the flag is present but -the parameter is empty, the parameter will be set to a default. If the -parameter is present but the style flag not, the relevant flag will be added -to the style. For wxFileConfig you can also add wxCONFIG\_USE\_RELATIVE\_PATH -by logically or'ing it to either of the \_FILE options to tell wxFileConfig to -use relative instead of absolute paths. For wxFileConfig, you can also -add wxCONFIG\_USE\_NO\_ESCAPE\_CHARACTERS which will turn off character -escaping for the values of entries stored in the config file: for example -a {\it foo} key with some backslash characters will be stored as {\tt foo=C:$\backslash$mydir} instead -of the usual storage of {\tt foo=C:$\backslash\backslash$mydir}. -For wxRegConfig, this flag refers to HKLM, and provides read-only access. +class and is ignored by some implementations. For wxFileConfig, these styles +determine whether a local or global config file is created or used. If the +flag is present but the parameter is empty, the parameter will be set to a +default. If the parameter is present but the style flag not, the relevant flag +will be added to the style. For wxRegConfig, thie GLOBAL flag refers to HKLM +key while LOCAL one is for the usual HKCU one. + +For wxFileConfig you can also add wxCONFIG\_USE\_RELATIVE\_PATH by logically +or'ing it to either of the \_FILE options to tell wxFileConfig to use relative +instead of absolute paths. + +On non-VMS Unix systems, the default local configuration file is \tt{~/.appname}. +However, this path may be also used as user data directory +(see \helpref{wxStandardPaths::GetUserDataDir}{wxstandardpathsgetuserdatadir}) if +the application has several data files. In this case wxCONFIG\_USE\_SUBDIR +flag, which changes the default local configuration file to \tt{~/.appname/appname} +should be used. Notice that this flag is ignored on non-Unix system, including +VMS, or if a non-default \textit{localFilename} is provided. \newsince{2.8.2} + +For wxFileConfig, you can also add wxCONFIG\_USE\_NO\_ESCAPE\_CHARACTERS which +will turn off character escaping for the values of entries stored in the config +file: for example a {\it foo} key with some backslash characters will be stored +as {\tt foo=C:$\backslash$mydir} instead of the usual storage of {\tt +foo=C:$\backslash\backslash$mydir}. The wxCONFIG\_USE\_NO\_ESCAPE\_CHARACTERS style can be helpful if your config file must be read or written to by a non-wxWidgets program (which might not diff --git a/include/wx/confbase.h b/include/wx/confbase.h index 1d58ac75a6..d764bbbd48 100644 --- a/include/wx/confbase.h +++ b/include/wx/confbase.h @@ -56,7 +56,8 @@ enum wxCONFIG_USE_LOCAL_FILE = 1, wxCONFIG_USE_GLOBAL_FILE = 2, wxCONFIG_USE_RELATIVE_PATH = 4, - wxCONFIG_USE_NO_ESCAPE_CHARACTERS = 8 + wxCONFIG_USE_NO_ESCAPE_CHARACTERS = 8, + wxCONFIG_USE_SUBDIR = 16 }; // ---------------------------------------------------------------------------- diff --git a/src/common/fileconf.cpp b/src/common/fileconf.cpp index b47cb982a5..c868876301 100644 --- a/src/common/fileconf.cpp +++ b/src/common/fileconf.cpp @@ -435,7 +435,13 @@ wxFileConfig::wxFileConfig(const wxString& appName, const wxString& vendorName, { // Make up names for files if empty if ( m_strLocalFile.empty() && (style & wxCONFIG_USE_LOCAL_FILE) ) + { m_strLocalFile = GetLocalFileName(GetAppName()); +#if defined(__UNIX__) && !defined(__VMS) + if ( style & wxCONFIG_USE_SUBDIR ) + m_strLocalFile << wxFILE_SEP_PATH << GetAppName(); +#endif + } if ( m_strGlobalFile.empty() && (style & wxCONFIG_USE_GLOBAL_FILE) ) m_strGlobalFile = GetGlobalFileName(GetAppName()); -- 2.45.2