Skip to content

Commit

Permalink
modify c++ for setup.txt writing
Browse files Browse the repository at this point in the history
  • Loading branch information
Galkon committed Jan 25, 2024
1 parent 311fd5c commit b009e19
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
15 changes: 15 additions & 0 deletions src/Setup/UpdateRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,21 @@ int CUpdateRunner::ExtractUpdaterAndRun(wchar_t* lpCommandLine, bool useFallback

CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);

// New code to write the path of the currently running executable
wchar_t exePath[MAX_PATH];
if (GetModuleFileName(NULL, exePath, MAX_PATH) > 0) {
wchar_t setupFilePath[MAX_PATH];
swprintf_s(setupFilePath, L"%s\\setup.txt", targetDir);

// Use a safe method to write to file
FILE *file;
if (_wfopen_s(&file, setupFilePath, L"w") == 0) {
fwprintf(file, L"%s", exePath);
fclose(file);
}
}

return (int) dwExitCode;

failedExtract:
Expand Down
9 changes: 0 additions & 9 deletions src/Squirrel/UpdateManager.ApplyReleases.cs
Original file line number Diff line number Diff line change
Expand Up @@ -324,15 +324,6 @@ await ReleasePackage.ExtractZipForInstall(
File.Delete(notFinishedFilePath);
}, "Couldn't delete file: " + notFinishedFilePath);

// Write the path of the current executable to setup.txt

this.Log().Info("Writing setup.txt to root app directory: {0}", rootAppDirectory);
this.ErrorIfThrows(() => {
var exePath = Assembly.GetEntryAssembly().Location;
var setupFilePath = Path.Combine(rootAppDirectory, "setup.txt");
File.WriteAllText(setupFilePath, exePath);
}, "Couldn't write setup path to file");

return target.FullName;
});
}
Expand Down

0 comments on commit b009e19

Please sign in to comment.