1#************************************************************** 2# 3# Licensed to the Apache Software Foundation (ASF) under one 4# or more contributor license agreements. See the NOTICE file 5# distributed with this work for additional information 6# regarding copyright ownership. The ASF licenses this file 7# to you under the Apache License, Version 2.0 (the 8# "License"); you may not use this file except in compliance 9# with the License. You may obtain a copy of the License at 10# 11# http://www.apache.org/licenses/LICENSE-2.0 12# 13# Unless required by applicable law or agreed to in writing, 14# software distributed under the License is distributed on an 15# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16# KIND, either express or implied. See the License for the 17# specific language governing permissions and limitations 18# under the License. 19# 20#************************************************************** 21 22 23 24package installer::windows::removefile; 25 26use installer::files; 27use installer::globals; 28use installer::windows::idtglobal; 29 30######################################################################## 31# Returning the FileKey for a folderitem for removefile table. 32######################################################################## 33 34sub get_removefile_filekey 35{ 36 my ($folderitem) = @_; 37 38 # returning the unique identifier 39 40 my $identifier = "remove_" . $folderitem->{'directory'}; 41 42 $identifier = lc($identifier); 43 44 return $identifier; 45} 46 47######################################################################## 48# Returning the Component for a folderitem for removefile table. 49######################################################################## 50 51sub get_removefile_component 52{ 53 my ($folderitem) = @_; 54 55 return $folderitem->{'component'}; 56} 57 58######################################################################## 59# Returning the FileName for a folderitem for removefile table. 60######################################################################## 61 62sub get_removefile_filename 63{ 64 my ($folderitem) = @_; 65 66 # return nothing: The assigned directory will be removed 67 68 return ""; 69} 70 71######################################################################## 72# Returning the DirProperty for a folderitem for removefile table. 73######################################################################## 74 75sub get_removefile_dirproperty 76{ 77 my ($folderitem) = @_; 78 79 return $folderitem->{'directory'}; 80} 81 82######################################################################## 83# Returning the InstallMode for a folderitem for removefile table. 84######################################################################## 85 86sub get_removefile_installmode 87{ 88 my ($folderitem) = @_; 89 90 # always returning "2": The file is only removed, if the assigned 91 # component is removed. Name: msidbRemoveFileInstallModeOnRemove 92 93 return 2; 94} 95 96########################################################################################################### 97# Creating the file RemoveFi.idt dynamically 98# Content: 99# FileKey Component_ FileName DirProperty InstallMode 100########################################################################################################### 101 102sub create_removefile_table 103{ 104 my ($folderitemsref, $basedir) = @_; 105 106 my @removefiletable = (); 107 108 installer::windows::idtglobal::write_idt_header(\@removefiletable, "removefile"); 109 110 # Only the directories created for the FolderItems have to be deleted 111 # with the information in the table RemoveFile 112 113 my @directorycollector = (); 114 115 for ( my $i = 0; $i <= $#{$folderitemsref}; $i++ ) 116 { 117 my $onelink = ${$folderitemsref}[$i]; 118 119 if ( $onelink->{'used'} == 0 ) { next; } 120 121 if ( installer::existence::exists_in_array($onelink->{'directory'}, \@directorycollector)) { next; } 122 123 push(@directorycollector, $onelink->{'directory'}); 124 125 my %removefile = (); 126 127 $removefile{'FileKey'} = get_removefile_filekey($onelink); 128 $removefile{'Component_'} = get_removefile_component($onelink); 129 $removefile{'FileName'} = get_removefile_filename($onelink); 130 $removefile{'DirProperty'} = get_removefile_dirproperty($onelink); 131 $removefile{'InstallMode'} = get_removefile_installmode($onelink); 132 133 my $oneline = $removefile{'FileKey'} . "\t" . $removefile{'Component_'} . "\t" . $removefile{'FileName'} . "\t" 134 . $removefile{'DirProperty'} . "\t" . $removefile{'InstallMode'} . "\n"; 135 136 push(@removefiletable, $oneline); 137 } 138 139 # Saving the file 140 141 my $removefiletablename = $basedir . $installer::globals::separator . "RemoveFi.idt"; 142 installer::files::save_file($removefiletablename ,\@removefiletable); 143 my $infoline = "Created idt file: $removefiletablename\n"; 144 push(@installer::globals::logfileinfo, $infoline); 145 146} 147 1481;