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
This commit is contained in:
Vadim Zeitlin
2007-01-18 22:38:21 +00:00
parent 49f29fbe2c
commit 04af2f5ce3
4 changed files with 33 additions and 13 deletions

View File

@@ -97,6 +97,7 @@ All:
- Added wxCSConv::IsOk() (Manuel Martin) - Added wxCSConv::IsOk() (Manuel Martin)
- Added wxDateTime::GetDateOnly() - Added wxDateTime::GetDateOnly()
- Made wxTextFile work with unseekable files again (David Hart) - Made wxTextFile work with unseekable files again (David Hart)
- Added wxCONFIG_USE_SUBDIR flag to wxFileConfig (Giuseppe Bilotta)
wxMSW wxMSW

View File

@@ -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 \docparam{style}{Can be one of wxCONFIG\_USE\_LOCAL\_FILE and
wxCONFIG\_USE\_GLOBAL\_FILE. The style interpretation depends on the config wxCONFIG\_USE\_GLOBAL\_FILE. The style interpretation depends on the config
class and is ignored by some. For wxFileConfig, these styles determine whether class and is ignored by some implementations. For wxFileConfig, these styles
a local or global config file is created or used. If the flag is present but determine whether a local or global config file is created or used. If the
the parameter is empty, the parameter will be set to a default. If the flag is present but the parameter is empty, the parameter will be set to a
parameter is present but the style flag not, the relevant flag will be added default. If the parameter is present but the style flag not, the relevant flag
to the style. For wxFileConfig you can also add wxCONFIG\_USE\_RELATIVE\_PATH will be added to the style. For wxRegConfig, thie GLOBAL flag refers to HKLM
by logically or'ing it to either of the \_FILE options to tell wxFileConfig to key while LOCAL one is for the usual HKCU one.
use relative instead of absolute paths. For wxFileConfig, you can also
add wxCONFIG\_USE\_NO\_ESCAPE\_CHARACTERS which will turn off character For wxFileConfig you can also add wxCONFIG\_USE\_RELATIVE\_PATH by logically
escaping for the values of entries stored in the config file: for example or'ing it to either of the \_FILE options to tell wxFileConfig to use relative
a {\it foo} key with some backslash characters will be stored as {\tt foo=C:$\backslash$mydir} instead instead of absolute paths.
of the usual storage of {\tt foo=C:$\backslash\backslash$mydir}.
For wxRegConfig, this flag refers to HKLM, and provides read-only access. 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 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 file must be read or written to by a non-wxWidgets program (which might not

View File

@@ -56,7 +56,8 @@ enum
wxCONFIG_USE_LOCAL_FILE = 1, wxCONFIG_USE_LOCAL_FILE = 1,
wxCONFIG_USE_GLOBAL_FILE = 2, wxCONFIG_USE_GLOBAL_FILE = 2,
wxCONFIG_USE_RELATIVE_PATH = 4, wxCONFIG_USE_RELATIVE_PATH = 4,
wxCONFIG_USE_NO_ESCAPE_CHARACTERS = 8 wxCONFIG_USE_NO_ESCAPE_CHARACTERS = 8,
wxCONFIG_USE_SUBDIR = 16
}; };
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@@ -435,7 +435,13 @@ wxFileConfig::wxFileConfig(const wxString& appName, const wxString& vendorName,
{ {
// Make up names for files if empty // Make up names for files if empty
if ( m_strLocalFile.empty() && (style & wxCONFIG_USE_LOCAL_FILE) ) if ( m_strLocalFile.empty() && (style & wxCONFIG_USE_LOCAL_FILE) )
{
m_strLocalFile = GetLocalFileName(GetAppName()); 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) ) if ( m_strGlobalFile.empty() && (style & wxCONFIG_USE_GLOBAL_FILE) )
m_strGlobalFile = GetGlobalFileName(GetAppName()); m_strGlobalFile = GetGlobalFileName(GetAppName());