Skip to content

Commit 0c53439

Browse files
Updater and mvUtil modified to handle deletion of updater dependencies during uninstall on windows
1 parent 9a9cd4e commit 0c53439

File tree

4 files changed

+64
-21
lines changed

4 files changed

+64
-21
lines changed

Updater/FEBioStudioUpdater.cpp

+25-4
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,12 @@ void uninstall()
134134
get_app_path(updaterDir, 1023);
135135
sprintf(updaterPath, "%sautoUpdate.xml", updaterDir);
136136

137+
QStringList files;
138+
QStringList dirs;
139+
QStringList cmds;
140+
137141
if(QFileInfo::exists(updaterPath))
138142
{
139-
QStringList files;
140-
QStringList dirs;
141-
QStringList cmds;
142-
143143
readXML(files, dirs, cmds);
144144

145145
files.append("autoUpdate.xml");
@@ -160,6 +160,27 @@ void uninstall()
160160
std::system(cmd.toStdString().c_str());
161161
}
162162
}
163+
164+
// Ugly fix for deleting updater dependencies on Windows
165+
#ifdef WIN32
166+
QString command = QString("%1 -rm ").arg(QApplication::applicationDirPath() + MVUTIL);
167+
168+
int runMvUtil = false;
169+
for(auto file : files)
170+
{
171+
if(QFileInfo::exists(file))
172+
{
173+
command = command + QString("\"%1\" ").arg(file);
174+
175+
runMvUtil = true;
176+
}
177+
}
178+
179+
if(runMvUtil)
180+
{
181+
std::system(command.toStdString().c_str());
182+
}
183+
#endif
163184
}
164185

165186
CMainWindow* getMainWindow()

Updater/MainWindow.cpp

-17
Original file line numberDiff line numberDiff line change
@@ -38,23 +38,6 @@
3838

3939
#include <iostream>
4040

41-
#ifdef WIN32
42-
#define FEBIOBINARY "\\febio4.exe"
43-
#define FBSBINARY "\\FEBioStudio2.exe"
44-
#define FBSUPDATERBINARY "\\FEBioStudioUpdater.exe"
45-
#define MVUTIL "\\mvUtil.exe"
46-
#elif __APPLE__
47-
#define FEBIOBINARY "/febio4"
48-
#define FBSBINARY "/FEBioStudio"
49-
#define FBSUPDATERBINARY "/FEBioStudioUpdater"
50-
#define MVUTIL "/mvUtil"
51-
#else
52-
#define FEBIOBINARY "/febio4"
53-
#define FBSBINARY "/FEBioStudio"
54-
#define FBSUPDATERBINARY "/FEBioStudioUpdater"
55-
#define MVUTIL "/mvUtil"
56-
#endif
57-
5841
namespace Ui
5942
{
6043
class MyWizardPage : public QWizardPage

Updater/MainWindow.h

+17
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,23 @@
22
#include <QWizard>
33
#include <QSslError>
44

5+
#ifdef WIN32
6+
#define FEBIOBINARY "\\febio4.exe"
7+
#define FBSBINARY "\\FEBioStudio2.exe"
8+
#define FBSUPDATERBINARY "\\FEBioStudioUpdater.exe"
9+
#define MVUTIL "\\mvUtil.exe"
10+
#elif __APPLE__
11+
#define FEBIOBINARY "/febio4"
12+
#define FBSBINARY "/FEBioStudio"
13+
#define FBSUPDATERBINARY "/FEBioStudioUpdater"
14+
#define MVUTIL "/mvUtil"
15+
#else
16+
#define FEBIOBINARY "/febio4"
17+
#define FBSBINARY "/FEBioStudio"
18+
#define FBSUPDATERBINARY "/FEBioStudioUpdater"
19+
#define MVUTIL "/mvUtil"
20+
#endif
21+
522
namespace Ui{
623
class CMainWindow;
724
}

Updater/mvUtil.cpp

+22
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,28 @@ int main(int argc, char* argv[])
1212
{
1313
if(argc < 3) return -1;
1414

15+
// Ugly fix for deleting updater dependencies on Windows
16+
#ifdef WIN32
17+
if(strcmp(argv[1], "-rm") == 0)
18+
{
19+
for (int index = 2; index < argc; index++)
20+
{
21+
int n = 0;
22+
while (std::remove(argv[index]) != 0)
23+
{
24+
// If the file just doesn't exist, break
25+
if(errno == ENOENT) break;
26+
27+
_sleep(100);
28+
n++;
29+
if (n > 10) break;
30+
}
31+
}
32+
33+
return 0;
34+
}
35+
#endif
36+
1537
int start = 2;
1638
bool dev = false;
1739

0 commit comments

Comments
 (0)