Add wxFileConfig::MigrateLocalFile()

This can be useful for the existing applications switching to using
XDG-compliant config files location as they can just call this function
on startup to keep using the existing file.
This commit is contained in:
Vadim Zeitlin 2024-01-04 03:05:44 +01:00
parent ebe0847932
commit 486865b446
4 changed files with 208 additions and 1 deletions

View file

@ -123,6 +123,22 @@ public:
return GetLocalFile(szFile, style).GetFullPath();
}
// Function to migrate, i.e. move, an existing local config file to another
// location. Old and new style determine the existing and new file paths.
struct MigrationResult
{
// If empty, it means the old file wasn't found and nothing was done.
wxString oldPath;
// The name of the new file.
wxString newPath;
// If empty, means the file was successfully migrated.
wxString error;
};
static MigrationResult
MigrateLocalFile(const wxString& name, int newStyle, int oldStyle = 0);
// ctor & dtor
// New constructor: one size fits all. Specify wxCONFIG_USE_LOCAL_FILE or
// wxCONFIG_USE_GLOBAL_FILE to say which files should be used.