2 # This file is part of the LibreOffice project.
4 # This Source Code Form is subject to the terms of the Mozilla Public
5 # License, v. 2.0. If a copy of the MPL was not distributed with this
6 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 # This file incorporates work covered by the following license notice:
10 # Licensed to the Apache Software Foundation (ASF) under one or more
11 # contributor license agreements. See the NOTICE file distributed
12 # with this work for additional information regarding copyright
13 # ownership. The ASF licenses this file to you under the Apache
14 # License, Version 2.0 (the "License"); you may not use this file
15 # except in compliance with the License. You may obtain a copy of
16 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 package installer
::windows
::removefile
;
22 use installer
::globals
;
23 use installer
::windows
::idtglobal
;
25 ########################################################################
26 # Returning the FileKey for a folderitem for removefile table.
27 ########################################################################
29 sub get_removefile_filekey
31 my ($folderitem) = @_;
33 # returning the unique identifier
35 my $identifier = "remove_" . $folderitem->{'directory'};
37 $identifier = lc($identifier);
42 ########################################################################
43 # Returning the Component for a folderitem for removefile table.
44 ########################################################################
46 sub get_removefile_component
48 my ($folderitem) = @_;
50 return $folderitem->{'component'};
53 ########################################################################
54 # Returning the FileName for a folderitem for removefile table.
55 ########################################################################
57 sub get_removefile_filename
59 my ($folderitem) = @_;
61 # return nothing: The assigned directory will be removed
66 ########################################################################
67 # Returning the DirProperty for a folderitem for removefile table.
68 ########################################################################
70 sub get_removefile_dirproperty
72 my ($folderitem) = @_;
74 return $folderitem->{'directory'};
77 ########################################################################
78 # Returning the InstallMode for a folderitem for removefile table.
79 ########################################################################
81 sub get_removefile_installmode
83 my ($folderitem) = @_;
85 # always returning "2": The file is only removed, if the assigned
86 # component is removed. Name: msidbRemoveFileInstallModeOnRemove
91 ###########################################################################################################
92 # Creating the file RemoveFi.idt dynamically
94 # FileKey Component_ FileName DirProperty InstallMode
95 ###########################################################################################################
97 sub create_removefile_table
99 my ($folderitemsref, $basedir) = @_;
101 # Only the directories created for the FolderItems have to be deleted
102 # with the information in the table RemoveFile
104 my @directorycollector = ();
106 for ( my $i = 0; $i <= $#{$folderitemsref}; $i++ )
108 my $onelink = ${$folderitemsref}[$i];
110 if ( $onelink->{'used'} == 0 ) { next; }
112 next if grep {$_ eq $onelink->{'directory'}} @directorycollector;
114 push(@directorycollector, $onelink->{'directory'});
118 $removefile{'FileKey'} = get_removefile_filekey
($onelink);
119 $removefile{'Component_'} = get_removefile_component
($onelink);
120 $removefile{'FileName'} = get_removefile_filename
($onelink);
121 $removefile{'DirProperty'} = get_removefile_dirproperty
($onelink);
122 # fdo#44565 do not remove empty Desktop folder
123 if ( $removefile{'DirProperty'} eq $installer::globals
::desktopfolder
) { next; }
124 $removefile{'InstallMode'} = get_removefile_installmode
($onelink);
126 my $oneline = $removefile{'FileKey'} . "\t" . $removefile{'Component_'} . "\t" . $removefile{'FileName'} . "\t"
127 . $removefile{'DirProperty'} . "\t" . $removefile{'InstallMode'} . "\n";
129 push(@installer::globals
::removefiletable
, $oneline);
134 my $removefiletablename = $basedir . $installer::globals
::separator
. "RemoveFi.idt";
135 installer
::files
::save_file
($removefiletablename ,\
@installer::globals
::removefiletable
);
136 my $infoline = "Created idt file: $removefiletablename\n";
137 push(@installer::globals
::logfileinfo
, $infoline);