Skip to content

installer: test any custom editor on a _writable_ file #618

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 22, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion installer/install.iss
Original file line number Diff line number Diff line change
Expand Up @@ -1731,7 +1731,10 @@ begin
Exit;
end;

TmpFile:=ExpandConstant('{tmp}\editor-test.txt');
// We are _not_ writing into the `{tmp}` directory, because it is private to the
// elevated process and cannot be written to by the non-elevated editor.
// Instead, we write _next_ to the `{tmp}` directory.
TmpFile:=ExpandConstant('{tmp}-editor-test.txt');
InputText:='Please modify this text, e.g. delete it, then save it and exit the editor.'
SaveStringToFile(TmpFile,InputText,False);

Expand All @@ -1744,17 +1747,20 @@ begin
if not ShellExecAsOriginalUser('',CustomEditorPath,CustomEditorOptions+' "'+TmpFile+'"','',Show,ewWaitUntilTerminated,Res) then begin
Wizardform.NextButton.Enabled:=False;
SuppressibleMsgBox('Could not launch: "'+CustomEditorPath+'"',mbError,MB_OK,IDOK);
DeleteFile(TmpFile); // ignore errors, if any
Exit;
end;
if (Res<>0) then begin
Wizardform.NextButton.Enabled:=False;
SuppressibleMsgBox('Exited with failure: "'+CustomEditorPath+'"',mbError,MB_OK,IDOK);
DeleteFile(TmpFile); // ignore errors, if any
Exit;
end;

if not LoadStringFromFile(TmpFile,OutputText) then begin
Wizardform.NextButton.Enabled:=False;
SuppressibleMsgBox('Could not read "'+TmpFile+'"',mbError,MB_OK,IDOK);
DeleteFile(TmpFile); // ignore errors, if any
Exit;
end;

Expand Down