[Meta-diff-devel] SF.net SVN: meta-diff: [113] trunk/setup/metadiff.iss
Brought to you by:
undees
From: <ey...@us...> - 2007-10-11 00:01:36
|
Revision: 113 http://meta-diff.svn.sourceforge.net/meta-diff/?rev=113&view=rev Author: eyebex Date: 2007-10-10 17:01:17 -0700 (Wed, 10 Oct 2007) Log Message: ----------- Copy any existing config files from a previous installation to the user's app data directory. Modified Paths: -------------- trunk/setup/metadiff.iss Modified: trunk/setup/metadiff.iss =================================================================== --- trunk/setup/metadiff.iss 2007-10-10 22:36:04 UTC (rev 112) +++ trunk/setup/metadiff.iss 2007-10-11 00:01:17 UTC (rev 113) @@ -26,7 +26,20 @@ Result:=GetShellFolderByCSIDL(CSIDL_APPDATA,False); end; +function GetPathInstalled(AppID:string):string; var + PrevPath,Key,Value:string; +begin + Result:=''; + Key:='Software\Microsoft\Windows\CurrentVersion\Uninstall\'+AppID+'_is1'; + Value:='Inno Setup: App Path'; + if RegQueryStringValue(HKLM,Key,Value,PrevPath) or RegQueryStringValue(HKCU,Key,Value,PrevPath) then begin + Result:=PrevPath; + end; +end; + +var + ConfigExisted:Boolean; ProgramPage:TInputFileWizardPage; procedure InitializeWizard; @@ -34,26 +47,6 @@ // Use a mono spaced font in the license dialog. WizardForm.LicenseMemo.Font.Name:='Lucida Console'; WizardForm.LicenseMemo.Font.Size:=7; - - // Create a custom page to specify comparison programs. - ProgramPage:=CreateInputFilePage( - wpInstalling, - 'Specify comparison programs', - 'One this page you can browse for comparison programs you want meta-diff to launch.', - 'You can skip this step by leaving the boxes blank and editing the ".metadiff" configuration file manually afterwards, which gives you access to more options and examples.' - ); - - ProgramPage.Add( - 'Program to use for directory comparisons:', - 'Executable files (*.exe)|*.exe|All files (*.*)|*.*', - '*.exe' - ); - - ProgramPage.Add( - 'Program to use for file comparisons:', - 'Executable files (*.exe)|*.exe|All files (*.*)|*.*', - '*.exe' - ); end; procedure CurStepChanged(CurStep:TSetupStep); @@ -64,31 +57,60 @@ // ssInstall - Just before the actual installation starts // ssPostInstall - Just after the actual installation finishes // ssDone - Just before Setup terminates after a successful install - if CurStep<>ssDone then begin - Exit; - end; ConfigFile:=ExpandConstant('{userappdata}\.metadiff'); - // Add the programs to the configuration file. - DirProgram:=RemoveQuotes(Trim(ProgramPage.Values[0])); - if Length(DirProgram)>0 then begin - SaveStringToFile(ConfigFile,#13#10+'/ '+DirProgram+#13#10,True); - end; + if CurStep=ssInstall then begin + // Copy any previous configuration files. + ConfigData:=GetPathInstalled('{#emit APP_NAME}'); - FileProgram:=RemoveQuotes(Trim(ProgramPage.Values[1])); - if Length(FileProgram)>0 then begin - SaveStringToFile(ConfigFile,#13#10+'*.* '+FileProgram+#13#10,True); - end; + ConfigExisted:=FileExists(ConfigFile) + or FileCopy(ConfigData+'\.metadiff',ConfigFile,True); + FileCopy(ConfigData+'\.lvdiff',ExpandConstant('{userappdata}\.lvdiff'),True); - // Only add '*.vi ' to the config file if there is no such entry yet. - if LoadStringFromFile(ConfigFile,ConfigData) and (Pos('*.vi ',ConfigData)>0) then begin - Exit; - end; + // Only offer to add programs for newly created config files. + if not ConfigExisted then begin + // Create a custom page to specify comparison programs. + ProgramPage:=CreateInputFilePage( + wpInstalling, + 'Specify comparison programs', + 'One this page you can browse for comparison programs you want meta-diff to launch.', + 'You can skip this step by leaving the boxes blank and editing the ".metadiff" configuration file manually afterwards, which gives you access to more options and examples.' + ); - lvdiff:=ExpandConstant('{app}\lvdiff.exe'); - if FileExists(lvdiff) then begin - SaveStringToFile(ConfigFile,#13#10+'*.vi '+lvdiff+#13#10,True); + ProgramPage.Add( + 'Program to use for directory comparisons:', + 'Executable files (*.exe)|*.exe|All files (*.*)|*.*', + '*.exe' + ); + + ProgramPage.Add( + 'Program to use for file comparisons:', + 'Executable files (*.exe)|*.exe|All files (*.*)|*.*', + '*.exe' + ); + end; + end else if (CurStep=ssDone) and (not ConfigExisted) then begin + // Add the programs to the configuration file. + DirProgram:=RemoveQuotes(Trim(ProgramPage.Values[0])); + if Length(DirProgram)>0 then begin + SaveStringToFile(ConfigFile,#13#10+'/ '+DirProgram+#13#10,True); + end; + + FileProgram:=RemoveQuotes(Trim(ProgramPage.Values[1])); + if Length(FileProgram)>0 then begin + SaveStringToFile(ConfigFile,#13#10+'*.* '+FileProgram+#13#10,True); + end; + + // Only add '*.vi ' to the config file if there is no such entry yet. + if LoadStringFromFile(ConfigFile,ConfigData) and (Pos('*.vi ',ConfigData)>0) then begin + Exit; + end; + + lvdiff:=ExpandConstant('{app}\lvdiff.exe'); + if FileExists(lvdiff) then begin + SaveStringToFile(ConfigFile,#13#10+'*.vi '+lvdiff+#13#10,True); + end; end; end; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |