| 1 |
cycrow |
1 |
// AutoUpdater.cpp : main project file.
|
|
|
2 |
|
|
|
3 |
#include "stdafx.h"
|
|
|
4 |
#include "Forms/Form1.h"
|
|
|
5 |
|
|
|
6 |
using namespace AutoUpdater;
|
|
|
7 |
|
|
|
8 |
[STAThreadAttribute]
|
|
|
9 |
int main(array<System::String ^> ^args)
|
|
|
10 |
{
|
|
|
11 |
// Enabling Windows XP visual effects before any controls are created
|
|
|
12 |
Application::EnableVisualStyles();
|
|
|
13 |
Application::SetCompatibleTextRenderingDefault(false);
|
|
|
14 |
|
|
|
15 |
if ( args->Length < 1 )
|
|
|
16 |
{
|
|
|
17 |
MessageBox::Show("Invalid Arguments, Missing filename", "Auto Updater", MessageBoxButtons::OK, MessageBoxIcon::Stop);
|
|
|
18 |
return 1;
|
|
|
19 |
}
|
|
|
20 |
|
|
|
21 |
System::String ^downloadFile = args[0];
|
|
|
22 |
while ( downloadFile->EndsWith("\r") )
|
|
|
23 |
downloadFile = downloadFile->Substring(0, downloadFile->Length - 1);
|
|
|
24 |
System::String ^runFile;
|
|
|
25 |
|
|
|
26 |
if ( args->Length > 1 )
|
|
|
27 |
runFile = args[1];
|
|
|
28 |
|
|
|
29 |
// Create the main window and run it
|
|
|
30 |
bool updated = true;
|
|
|
31 |
if ( downloadFile->Contains("|") )
|
|
|
32 |
{
|
|
|
33 |
System::String ^file;
|
|
|
34 |
int pos = 0;
|
|
|
35 |
|
|
|
36 |
while ( pos < downloadFile->Length )
|
|
|
37 |
{
|
|
|
38 |
int start = pos;
|
|
|
39 |
pos = downloadFile->IndexOf("|", pos);
|
|
|
40 |
if ( pos == -1 )
|
|
|
41 |
file = downloadFile->Substring(start);
|
|
|
42 |
else
|
|
|
43 |
file = downloadFile->Substring(start, pos - start);
|
|
|
44 |
|
|
|
45 |
int checkPos = file->IndexOf('\r');
|
|
|
46 |
while ( checkPos != -1 )
|
|
|
47 |
{
|
|
|
48 |
file = file->Remove(checkPos, 1);
|
|
|
49 |
checkPos = file->IndexOf('\r', checkPos);
|
|
|
50 |
}
|
|
|
51 |
|
|
|
52 |
Form1 ^f = gcnew Form1(file);
|
|
|
53 |
Application::Run(f);
|
|
|
54 |
|
|
|
55 |
if ( !f->IsUpdated() )
|
|
|
56 |
updated = false;
|
|
|
57 |
|
|
|
58 |
if ( pos == -1 )
|
|
|
59 |
break;
|
|
|
60 |
pos++;
|
|
|
61 |
}
|
|
|
62 |
}
|
|
|
63 |
else
|
|
|
64 |
{
|
|
|
65 |
updated = false;
|
|
|
66 |
Form1 ^f = gcnew Form1(downloadFile);
|
|
|
67 |
Application::Run(f);
|
|
|
68 |
if ( f->IsUpdated() )
|
|
|
69 |
updated = true;
|
|
|
70 |
}
|
|
|
71 |
|
|
|
72 |
if ( updated )
|
|
|
73 |
MessageBox::Show("Plugin Manager has now been updated", "Auto Updater", MessageBoxButtons::OK, MessageBoxIcon::Exclamation);
|
|
|
74 |
|
|
|
75 |
if ( runFile )
|
|
|
76 |
{
|
|
|
77 |
System::Diagnostics::ProcessStartInfo ^info = gcnew System::Diagnostics::ProcessStartInfo(runFile);
|
|
|
78 |
info->WorkingDirectory = System::IO::FileInfo(runFile).DirectoryName;
|
|
|
79 |
info->UseShellExecute = false;
|
|
|
80 |
info->WindowStyle = System::Diagnostics::ProcessWindowStyle::Normal;
|
|
|
81 |
System::Diagnostics::Process ^process = System::Diagnostics::Process::Start(info);
|
|
|
82 |
}
|
|
|
83 |
|
|
|
84 |
return 0;
|
|
|
85 |
}
|