Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to move existing directories/files with an INNO script?

Tags:

inno-setup

We've recently had an application which installs using an INNO script undergo a significant restructuring.

Unfortunately the application requires certain files to persist from version to version.

Even more unfortunately, the location of these files has changed during this restructuring.

Most unfortunately, it now falls to me to craft an INNO script fragment which will look to see if those files exist, and to move them from their former location to their new location.

Is it possible to have an INNO script check to see if files (which have nothing to do with the INNO script itself in any capacity) exist, and if they do, to move them to a new location before/after the install is completed?

EDIT 1 : For Clarity

I say that these files have nothing to do with the INNO script because they are user-generated content.

like image 237
Will Avatar asked Oct 23 '15 14:10

Will


1 Answers

Yes, it is possible. The code below is a copy and delete (instead of a raw move or rename).

Use the [Code] section to implement this logic.

The documentation about supported functions and the events you can handle is pretty good.

How to react on a beginning installation:

procedure CurStepChanged(CurStep: TSetupStep);
begin

  case CurStep of
    ssInstall:
    begin
      { will be executed just before the actual installation starts }
    end; 

   ssPostInstall:
    begin
      { will be executed just after the actual installation finishes }
    end; 
  end;

end;

How to know whether a file exists or not

if FileExists(FileName) then
begin
  { do something when the file exists }
end; 

Copy a file (overwrite exisiting file)

if not FileCopy(ExistingFileName, NewFileName: String, false) then
begin
  { handle copy error }
end;

Delete a file

if not DeleteFile(FileName) then
begin
  { handle delete error }
end;
like image 198
Wosi Avatar answered Sep 23 '22 02:09

Wosi