View Single Post
  #1501  
Old 15-11-2021, 06:40
Cesar82's Avatar
Cesar82 Cesar82 is online now
Registered User
 
Join Date: May 2011
Location: Brazil
Posts: 799
Thanks: 1,309
Thanked 1,702 Times in 580 Posts
Cesar82 is on a distinguished road
Quote:
Originally Posted by BYRedex View Post
Hi all.
Could you please help me with the following:
I have an installer for a mod, but if a person uninstalls a mod, the whole game is uninstalled as well.
How can I make it so that only the mod files are deleted?

I was thinking of keeping an install log and taking files from it to delete, but damn, that doesn't work right.
(It doesn't delete files from the list and it doesn't log small files)
I'll attach a sample code)

Thank you in advance.

Code:
Function InitializeUninstall(): Boolean;
begin
  ULog := FileExists(ExpandConstant('{app}\INSTALL.LOG')); // you need to get the log now, it might not exist later
  if ULog then // if there is a log file, create a sheet where we load the list of files
  begin
    unins_list := TStringList.Create;
    unins_list.LoadFromFile(ExpandConstant('{app}\INSTALL.LOG'));
  end;
  Result := True;
end;

Procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
  var
    i : Integer;
begin
  If CurUninstallStep = usPostUninstall then
    if ULog then
    begin
      for i := 0 to unins_list.Count-1 do DeleteFile(unins_list:[i]); // delete files from the list - It doesn't work
      unins_list.Free;
    end;
end;
Example here
The IsDone callback function (ProgressCallback) does not display the names of all files.
This function is called 4 times per second and only the current filename is shown in the output.

If you use a native installation of Inno Setup (No UnArc/ISDone) it will only remove the installed files.

But for you to continue using your script you can create a list using FindFirst and FindNext of all the files that are in the game folder right after the ISDoneInit function.
After the ISDoneStop function you do a new check using FindFirst and FindNext and compare the names with the previous list using:
if oldfileslist.IndexOf(<fullfilename>) < 0 then ins_log.Append(<fullfilename>);
Reply With Quote
Sponsored Links