Implement MakeConfigFileName
This commit is contained in:
committed by
Vadim Zeitlin
parent
1bcb30f6d7
commit
8d5d00db9d
@@ -247,26 +247,6 @@ public:
|
||||
// static functions
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// this function modifies in place the given wxFileName object if it doesn't
|
||||
// already have an extension
|
||||
//
|
||||
// note that it's slightly misnamed under Mac as there it doesn't add an
|
||||
// extension but modifies the file name instead, so you shouldn't suppose that
|
||||
// fn.HasExt() is true after it returns
|
||||
static void AddConfFileExtIfNeeded(wxFileName& fn)
|
||||
{
|
||||
if ( !fn.HasExt() )
|
||||
{
|
||||
#if defined( __WXMAC__ )
|
||||
fn.SetName(fn.GetName() + wxT(" Preferences"));
|
||||
#elif defined( __UNIX__ )
|
||||
fn.SetExt(wxT("conf"));
|
||||
#else // Windows
|
||||
fn.SetExt(wxT("ini"));
|
||||
#endif // UNIX/Win
|
||||
}
|
||||
}
|
||||
|
||||
wxString wxFileConfig::GetGlobalDir()
|
||||
{
|
||||
return wxStandardPaths::Get().GetConfigDir();
|
||||
@@ -286,30 +266,13 @@ wxString wxFileConfig::GetLocalDir(int style)
|
||||
|
||||
wxFileName wxFileConfig::GetGlobalFile(const wxString& szFile)
|
||||
{
|
||||
wxFileName fn(GetGlobalDir(), szFile);
|
||||
|
||||
AddConfFileExtIfNeeded(fn);
|
||||
|
||||
wxFileName fn(GetGlobalDir(), wxStandardPaths::Get().MakeConfigFileName(szFile, wxCONFIG_USE_SUBDIR));
|
||||
return fn;
|
||||
}
|
||||
|
||||
wxFileName wxFileConfig::GetLocalFile(const wxString& szFile, int style)
|
||||
{
|
||||
wxFileName fn(GetLocalDir(style), szFile);
|
||||
|
||||
#if defined( __UNIX__ ) && !defined( __WXMAC__ )
|
||||
if ( !(style & wxCONFIG_USE_SUBDIR) )
|
||||
{
|
||||
// dot-files under Unix start with, well, a dot (but OTOH they usually
|
||||
// don't have any specific extension)
|
||||
fn.SetName(wxT('.') + fn.GetName());
|
||||
}
|
||||
else // we do append ".conf" extension to config files in subdirectories
|
||||
#endif // defined( __UNIX__ ) && !defined( __WXMAC__ )
|
||||
{
|
||||
AddConfFileExtIfNeeded(fn);
|
||||
}
|
||||
|
||||
wxFileName fn(GetLocalDir(style), wxStandardPaths::Get().MakeConfigFileName(szFile, style));
|
||||
return fn;
|
||||
}
|
||||
|
||||
|
||||
@@ -369,6 +369,14 @@ wxString wxStandardPaths::GetPluginsDir() const
|
||||
return GetAppDir();
|
||||
}
|
||||
|
||||
|
||||
wxString wxStandardPaths::MakeConfigFileName(const wxString& basename, int WXUNUSED(style)) const
|
||||
{
|
||||
wxFileName fn(wxEmptyString, basename);
|
||||
fn.SetExt(wxT("ini"));
|
||||
return fn.GetFullName();
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// wxStandardPathsWin16 implementation
|
||||
// ============================================================================
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#if wxUSE_STDPATHS
|
||||
|
||||
#include "wx/filename.h"
|
||||
#include "wx/stdpaths.h"
|
||||
#include "wx/osx/private.h"
|
||||
#include "wx/osx/core/cfstring.h"
|
||||
@@ -129,4 +130,11 @@ wxString wxStandardPaths::GetUserDir(Dir userDir) const
|
||||
return GetFMDirectory(dirType, NSUserDomainMask);
|
||||
}
|
||||
|
||||
wxString wxStandardPaths::MakeConfigFileName(const wxString& basename, int WXUNUSED(style)) const
|
||||
{
|
||||
wxFileName fn(wxEmptyString, basename);
|
||||
fn.SetName(fn.GetName() + wxT(" Preferences"));
|
||||
return fn.GetFullName();
|
||||
}
|
||||
|
||||
#endif // wxUSE_STDPATHS
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include "wx/utils.h"
|
||||
#endif //WX_PRECOMP
|
||||
|
||||
#include "wx/fileconf.h"
|
||||
#include "wx/filename.h"
|
||||
#include "wx/log.h"
|
||||
#include "wx/textfile.h"
|
||||
@@ -308,4 +309,14 @@ wxString wxStandardPaths::GetUserDir(Dir userDir) const
|
||||
|
||||
#endif // __VMS/!__VMS
|
||||
|
||||
wxString wxStandardPaths::MakeConfigFileName(const wxString& basename, int style) const
|
||||
{
|
||||
wxFileName fn(wxEmptyString, basename);
|
||||
if (style & wxCONFIG_USE_SUBDIR)
|
||||
fn.SetExt(wxT("conf"));
|
||||
else
|
||||
fn.SetName(wxT('.') + fn.GetName());
|
||||
return fn.GetFullName();
|
||||
}
|
||||
|
||||
#endif // wxUSE_STDPATHS
|
||||
|
||||
Reference in New Issue
Block a user