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
;
25 use installer
::globals
;
26 use installer
::windows
::idtglobal
;
28 ########################################################################
29 # Returning the FileKey for a folderitem for removefile table.
30 ########################################################################
32 sub get_removefile_filekey
34 my ($folderitem) = @_;
36 # returning the unique identifier
38 my $identifier = "remove_" . $folderitem->{'directory'};
40 $identifier = lc($identifier);
45 ########################################################################
46 # Returning the Component for a folderitem for removefile table.
47 ########################################################################
49 sub get_removefile_component
51 my ($folderitem) = @_;
53 return $folderitem->{'component'};
56 ########################################################################
57 # Returning the FileName for a folderitem for removefile table.
58 ########################################################################
60 sub get_removefile_filename
62 my ($folderitem) = @_;
64 # return nothing: The assigned directory will be removed
69 ########################################################################
70 # Returning the DirProperty for a folderitem for removefile table.
71 ########################################################################
73 sub get_removefile_dirproperty
75 my ($folderitem) = @_;
77 return $folderitem->{'directory'};
80 ########################################################################
81 # Returning the InstallMode for a folderitem for removefile table.
82 ########################################################################
84 sub get_removefile_installmode
86 my ($folderitem) = @_;
88 # always returning "2": The file is only removed, if the assigned
89 # component is removed. Name: msidbRemoveFileInstallModeOnRemove
94 ###########################################################################################################
95 # Creating the file RemoveFi.idt dynamically
97 # FileKey Component_ FileName DirProperty InstallMode
98 ###########################################################################################################
100 sub create_removefile_table
102 my ($folderitemsref, $basedir) = @_;
104 # Only the directories created for the FolderItems have to be deleted
105 # with the information in the table RemoveFile
107 my @directorycollector = ();
109 for ( my $i = 0; $i <= $#{$folderitemsref}; $i++ )
111 my $onelink = ${$folderitemsref}[$i];
113 if ( $onelink->{'used'} == 0 ) { next; }
115 next if grep {$_ eq $onelink->{'directory'}} @directorycollector;
117 push(@directorycollector, $onelink->{'directory'});
121 $removefile{'FileKey'} = get_removefile_filekey
($onelink);
122 $removefile{'Component_'} = get_removefile_component
($onelink);
123 $removefile{'FileName'} = get_removefile_filename
($onelink);
124 $removefile{'DirProperty'} = get_removefile_dirproperty
($onelink);
125 # fdo#44565 do not remove empty Desktop folder
126 if ( $removefile{'DirProperty'} eq $installer::globals
::desktopfolder
) { next; }
127 $removefile{'InstallMode'} = get_removefile_installmode
($onelink);
129 my $oneline = $removefile{'FileKey'} . "\t" . $removefile{'Component_'} . "\t" . $removefile{'FileName'} . "\t"
130 . $removefile{'DirProperty'} . "\t" . $removefile{'InstallMode'} . "\n";
132 push(@installer::globals
::removefiletable
, $oneline);
137 my $removefiletablename = $basedir . $installer::globals
::separator
. "RemoveFi.idt";
138 installer
::files
::save_file
($removefiletablename ,\
@installer::globals
::removefiletable
);
139 my $infoline = "Created idt file: $removefiletablename\n";
140 push(@installer::globals
::logfileinfo
, $infoline);