Initial attempt at —-uninstall mode for FGFS
This is a headless mode, designed to be invoked from an installer, not used directly by users. It doesn’t touch the ‘normal’ installation, but rather removes the other files FG typically creates or downloads.
This commit is contained in:
parent
0855f0414f
commit
af6611d7f6
3 changed files with 49 additions and 0 deletions
|
@ -63,6 +63,7 @@
|
|||
#include "main.hxx"
|
||||
#include <Include/version.h>
|
||||
#include <Main/globals.hxx>
|
||||
#include <Main/fg_init.hxx>
|
||||
#include <Main/options.hxx>
|
||||
#include <Main/fg_props.hxx>
|
||||
#include <GUI/MessageBox.hxx>
|
||||
|
@ -312,6 +313,10 @@ int main ( int argc, char **argv )
|
|||
setlocale(LC_NUMERIC, "C");
|
||||
setlocale(LC_COLLATE, "C");
|
||||
|
||||
if (flightgear::Options::checkForArg(argc, argv, "uninstall")) {
|
||||
return fgUninstall();
|
||||
}
|
||||
|
||||
bool fgviewer = flightgear::Options::checkForArg(argc, argv, "fgviewer");
|
||||
int exitStatus = EXIT_FAILURE;
|
||||
try {
|
||||
|
|
|
@ -1195,3 +1195,43 @@ void fgInitPackageRoot()
|
|||
globals->setPackageRoot(pkgRoot);
|
||||
|
||||
}
|
||||
|
||||
int fgUninstall()
|
||||
{
|
||||
SGPath dataPath = SGPath::fromEnv("FG_HOME", platformDefaultDataPath());
|
||||
simgear::Dir fgHome(dataPath);
|
||||
if (fgHome.exists()) {
|
||||
if (!fgHome.remove(true /* recursive */)) {
|
||||
fprintf(stderr, "Errors occurred trying to remove FG_HOME");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
if (fgHome.exists()) {
|
||||
fprintf(stderr, "unable to remove FG_HOME");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
#if defined(SG_WINDOWS)
|
||||
SGPath p = flightgear::defaultDownloadDir();
|
||||
// we don't want to remove the whole dir, let's nuke specific
|
||||
// subdirs which are (hopefully) safe
|
||||
|
||||
SGPath terrasyncPath = p / "TerraSync";
|
||||
if (terrasyncPath.exists()) {
|
||||
simgear::Dir dir(terrasyncPath);
|
||||
if (!dir.remove(true /*recursive*/)) {
|
||||
fprintf(stderr, "Errors occurred trying to remove Documents/FlightGear/TerraSync");
|
||||
}
|
||||
}
|
||||
|
||||
SGPath packagesPath = p / "Aircraft";
|
||||
if (packagesPath.exists()) {
|
||||
simgear::Dir dir(packagesPath);
|
||||
if (!dir.remove(true /*recursive*/)) {
|
||||
fprintf(stderr, "Errors occurred trying to remove Documents/FlightGear/Aircraft");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -74,6 +74,10 @@ void fgStartNewReset();
|
|||
// setup the package system including the global root
|
||||
void fgInitPackageRoot();
|
||||
|
||||
// wipe FG_HOME. (The removing of the program data is assumed to be done
|
||||
// by the real installer).
|
||||
int fgUninstall();
|
||||
|
||||
#endif // _FG_INIT_HXX
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue