diff --git a/uppsrc/Core/LocalProcess.cpp b/uppsrc/Core/LocalProcess.cpp index 4a8618f23..9c2612dbd 100644 --- a/uppsrc/Core/LocalProcess.cpp +++ b/uppsrc/Core/LocalProcess.cpp @@ -105,16 +105,22 @@ bool LocalProcess::DoStart(const char *command, const Vector *arg, bool HANDLE hp = GetCurrentProcess(); - CreatePipe(&hInputRead, &hInputWriteTmp, NULL, 0); + SECURITY_ATTRIBUTES sa; + + sa.nLength = sizeof(SECURITY_ATTRIBUTES); + sa.lpSecurityDescriptor = NULL; + sa.bInheritHandle = TRUE; + + CreatePipe(&hInputRead, &hInputWriteTmp, &sa, 0); DuplicateHandle(hp, hInputWriteTmp, hp, &hInputWrite, 0, FALSE, DUPLICATE_SAME_ACCESS); CloseHandle(hInputWriteTmp); - CreatePipe(&hOutputReadTmp, &hOutputWrite, NULL, 0); + CreatePipe(&hOutputReadTmp, &hOutputWrite, &sa, 0); DuplicateHandle(hp, hOutputReadTmp, hp, &hOutputRead, 0, FALSE, DUPLICATE_SAME_ACCESS); CloseHandle(hOutputReadTmp); if(spliterr) { - CreatePipe(&hErrorReadTmp, &hErrorWrite, NULL, 0); + CreatePipe(&hErrorReadTmp, &hErrorWrite, &sa, 0); DuplicateHandle(hp, hErrorReadTmp, hp, &hErrorRead, 0, FALSE, DUPLICATE_SAME_ACCESS); CloseHandle(hErrorReadTmp); } @@ -167,15 +173,7 @@ bool LocalProcess::DoStart(const char *command, const Vector *arg, bool } command = cmdh; } -#if 0 - int n = (int)strlen(command) + 1; - Buffer cmd(n); - memcpy(cmd, command, n); - bool h = CreateProcess(NULL, cmd, NULL, NULL /*&sa, &sa*/, TRUE, - NORMAL_PRIORITY_CLASS, (void *)envptr, NULL, &si, &pi); -#else bool h = Win32CreateProcess(command, envptr, si, pi); -#endif LLOG("CreateProcess " << (h ? "succeeded" : "failed")); CloseHandle(hErrorWrite); CloseHandle(hInputRead); @@ -511,6 +509,8 @@ bool LocalProcess::Read2(String& reso, String& rese) ReadFile(hErrorRead, buffer, sizeof(buffer), &n, NULL) && n) rese.Cat(buffer, n); + DDUMPHEX(reso); + DDUMPHEX(rese); if(convertcharset) { reso = FromOEMCharset(reso); rese = FromOEMCharset(rese); diff --git a/uppsrc/ide/Upgrade.cpp b/uppsrc/ide/Upgrade.cpp new file mode 100644 index 000000000..efd24f7ce --- /dev/null +++ b/uppsrc/ide/Upgrade.cpp @@ -0,0 +1,45 @@ +#include "ide.h" + +void Ide::UpgradeTheIDE() +{ + String idepath = GetExeFilePath(); + String newpath = idepath + ".new"; + String bakpath(~idepath, GetFileExtPos(idepath)); + bakpath << ".bak.exe"; + + int tbak = targetmode; + String tmbak = StoreAsString(release); + + release.target_override = true; + release.target = newpath; +#ifdef PLATFORM_WIN32 + release.linkmode = 0; +#else + release.linkmode = 1; +#endif + release.createmap = false; + release.version.Clear(); + release.def.blitz = false; + release.def.debug = false; + release.package.Clear(); + + targetmode = 1; + + Clean(); + if(!Build()) + return; + + FileDelete(bakpath); + if(FileExists(bakpath)) + Exclamation("Unable to delete&" + bakpath); + else { + PutVerbose("Moving " + idepath + " to " + bakpath); + FileMove(idepath, bakpath); + PutVerbose("Moving " + newpath + " to " + idepath); + FileMove(newpath, idepath); + PutConsole("Upgrade finished, please restart theide."); + } + + LoadFromString(release, tmbak); + targetmode = tbak; +} diff --git a/uppsrc/ide/ide.h b/uppsrc/ide/ide.h index eacd520ff..ffc022d03 100644 --- a/uppsrc/ide/ide.h +++ b/uppsrc/ide/ide.h @@ -903,6 +903,7 @@ public: void SetUpdateTimer(int period); void Abbreviations(); void DoMacroManager(); + void UpgradeTheIDE(); void SetupMobilePlatforms(Bar& bar); void SetupAndroidMobilePlatform(Bar& bar, const AndroidSDK& androidSDK); diff --git a/uppsrc/ide/ide.upp b/uppsrc/ide/ide.upp index f792f622a..89834cd99 100644 --- a/uppsrc/ide/ide.upp +++ b/uppsrc/ide/ide.upp @@ -85,6 +85,7 @@ file Json.cpp, MacroManager.cpp, SetupSVN.cpp, + Upgrade.cpp, Compile readonly separator, MethodsCtrls.h, MethodsCtrls.cpp, diff --git a/uppsrc/ide/idebar.cpp b/uppsrc/ide/idebar.cpp index 5d6fd6cd8..205715a69 100644 --- a/uppsrc/ide/idebar.cpp +++ b/uppsrc/ide/idebar.cpp @@ -394,6 +394,13 @@ void Ide::Setup(Bar& menu) IdeAgain = true; Break(); }); + + const Workspace& wspc = IdeWorkspace(); + if(wspc[0] == "ide") + for(int i = 0; i < wspc.GetCount(); i++) + if(wspc[i] == "ide/Core") + menu.Add("Upgrade theide..", [=] { UpgradeTheIDE(); }); + if(menu.IsMenuBar()) SetupMobilePlatforms(menu); }