Debian Codegraph @

Modules/Internal/CPack/ISComponents.pas

raw
1 { Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2 file LICENSE.rst or https://cmake.org/licensing for details. }
3
4 function CPackGetCustomInstallationMessage(Param: String): String;
5 begin
6 Result := SetupMessage(msgCustomInstallation);
7 end;
8
9 { Downloaded components }
10 #ifdef CPackDownloadCount
11 const
12 NO_PROGRESS_BOX = 4;
13 RESPOND_YES_TO_ALL = 16;
14 var
15 CPackDownloadPage: TDownloadWizardPage;
16 CPackShell: Variant;
17
18 <event('InitializeWizard')>
19 procedure CPackInitializeWizard();
20 begin
21 CPackDownloadPage := CreateDownloadPage(SetupMessage(msgWizardPreparing), SetupMessage(msgPreparingDesc), nil);
22 CPackShell := CreateOleObject('Shell.Application');
23 end;
24
25 <event('NextButtonClick')>
26 function CPackNextButtonClick(CurPageID: Integer): Boolean;
27 begin
28 if CurPageID = wpReady then
29 begin
30 CPackDownloadPage.Clear;
31 CPackDownloadPage.Show;
32
33 #sub AddDownload
34 if WizardIsComponentSelected('{#CPackDownloadComponents[i]}') then
35 #emit "CPackDownloadPage.Add('" + CPackDownloadUrls[i] + "', '" + CPackDownloadArchives[i] + ".zip', '" + CPackDownloadHashes[i] + "');"
36 #endsub
37 #define i
38 #for {i = 0; i < CPackDownloadCount; i++} AddDownload
39 #undef i
40
41 try
42 try
43 CPackDownloadPage.Download;
44 Result := True;
45 except
46 if not CPackDownloadPage.AbortedByUser then
47 SuppressibleMsgBox(AddPeriod(GetExceptionMessage), mbCriticalError, MB_OK, IDOK);
48
49 Result := False;
50 end;
51 finally
52 CPackDownloadPage.Hide;
53 end;
54 end else
55 Result := True;
56 end;
57
58 procedure CPackExtractFile(ArchiveName, FileName: String);
59 var
60 ZipFileName: String;
61 ZipFile: Variant;
62 Item: Variant;
63 TargetFolderName: String;
64 TargetFolder: Variant;
65 begin
66 TargetFolderName := RemoveBackslashUnlessRoot(ExpandConstant('{tmp}\' + ArchiveName + '\' + ExtractFileDir(FileName)));
67 ZipFileName := ExpandConstant('{tmp}\' + ArchiveName + '.zip');
68
69 if not DirExists(TargetFolderName) then
70 if not ForceDirectories(TargetFolderName) then
71 RaiseException(Format('Target path "%s" cannot be created', [TargetFolderName]));
72
73 ZipFile := CPackShell.NameSpace(ZipFileName);
74 if VarIsClear(ZipFile) then
75 RaiseException(Format('Cannot open ZIP file "%s" or does not exist', [ZipFileName]));
76
77 Item := ZipFile.ParseName(FileName);
78 if VarIsClear(Item) then
79 RaiseException(Format('Cannot find "%s" in "%s" ZIP file', [FileName, ZipFileName]));
80
81 TargetFolder := CPackShell.NameSpace(TargetFolderName);
82 if VarIsClear(TargetFolder) then
83 RaiseException(Format('Target path "%s" does not exist', [TargetFolderName]));
84
85 TargetFolder.CopyHere(Item, NO_PROGRESS_BOX or RESPOND_YES_TO_ALL);
86 end;
87
88 #endif