issue with wxCONFIG_USE_SUBDIR
Carsten A. Arnholm
arnholm at offline.no
Mon Feb 25 14:09:35 PST 2008
Vadim Zeitlin wrote:
> Actually wxCONFIG_USE_SUBDIR is used (unless I'm misreading the code)
> under Windows too. It's just that by default wxFileConfig itself is
> not used under Windows.
>
> I guess the best way to handle this problem would be to add a virtual
> wxConfigBase::InitializeStorage() method which would be overridden in
> wxFileConfig to create the directory it needs. If you can create a
> patch implementing this, it would be definitely welcome. Otherwise
> I'm afraid you're limited to doing
>
> #if !defined(__WXMSW__) || wxUSE_CONFIG_NATIVE
> wxMkdir(config.GetLocalDir());
> #endif
Thank you for the detailed reply, Vadim.
I think I understand it now. It is true I use the subdir for other purposes
than just the config file. Before seing your reply, I experimented with this
addition in my applications OnInit() function, i.e. before my wxConfig
object is created:
// make sure the wxStandardPaths::GetUserDataDir() folder actually
exists.
// It is *not* created automaticially by wxConfig!
wxStandardPaths sp;
wxString config_dir = sp.GetUserDataDir();
if(!wxDir::Exists(config_dir)) {
::wxMkdir(config_dir);
}
Obviously, it makes the directory also on Windows (but that is ok I found).
I noticed that a nasty error will occur if I try to call wxMkdir on an
already existing directory, so I test for its existance. Btw. I cannot find
the GetLocalDir() you are using for wxConfigBase nor wxFileConfig?
I am still in the dark wrt. making patches for things like this..... I may
get to that stage one day.
Regards
Carsten A. Arnholm
http://arnholm.org/
N59.776 E10.457
More information about the wx-users
mailing list