1#************************************************************************* 2# 3# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4# 5# Copyright 2000, 2010 Oracle and/or its affiliates. 6# 7# OpenOffice.org - a multi-platform office productivity suite 8# 9# This file is part of OpenOffice.org. 10# 11# OpenOffice.org is free software: you can redistribute it and/or modify 12# it under the terms of the GNU Lesser General Public License version 3 13# only, as published by the Free Software Foundation. 14# 15# OpenOffice.org is distributed in the hope that it will be useful, 16# but WITHOUT ANY WARRANTY; without even the implied warranty of 17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18# GNU Lesser General Public License version 3 for more details 19# (a copy is included in the LICENSE file that accompanied this code). 20# 21# You should have received a copy of the GNU Lesser General Public License 22# version 3 along with OpenOffice.org. If not, see 23# <http://www.openoffice.org/license.html> 24# for a copy of the LGPLv3 License. 25# 26#************************************************************************* 27 28package installer::windows::removefile; 29 30use installer::files; 31use installer::globals; 32use installer::windows::idtglobal; 33 34######################################################################## 35# Returning the FileKey for a folderitem for removefile table. 36######################################################################## 37 38sub get_removefile_filekey 39{ 40 my ($folderitem) = @_; 41 42 # returning the unique identifier 43 44 my $identifier = "remove_" . $folderitem->{'directory'}; 45 46 $identifier = lc($identifier); 47 48 return $identifier; 49} 50 51######################################################################## 52# Returning the Component for a folderitem for removefile table. 53######################################################################## 54 55sub get_removefile_component 56{ 57 my ($folderitem) = @_; 58 59 return $folderitem->{'component'}; 60} 61 62######################################################################## 63# Returning the FileName for a folderitem for removefile table. 64######################################################################## 65 66sub get_removefile_filename 67{ 68 my ($folderitem) = @_; 69 70 # return nothing: The assigned directory will be removed 71 72 return ""; 73} 74 75######################################################################## 76# Returning the DirProperty for a folderitem for removefile table. 77######################################################################## 78 79sub get_removefile_dirproperty 80{ 81 my ($folderitem) = @_; 82 83 return $folderitem->{'directory'}; 84} 85 86######################################################################## 87# Returning the InstallMode for a folderitem for removefile table. 88######################################################################## 89 90sub get_removefile_installmode 91{ 92 my ($folderitem) = @_; 93 94 # always returning "2": The file is only removed, if the assigned 95 # component is removed. Name: msidbRemoveFileInstallModeOnRemove 96 97 return 2; 98} 99 100########################################################################################################### 101# Creating the file RemoveFi.idt dynamically 102# Content: 103# FileKey Component_ FileName DirProperty InstallMode 104########################################################################################################### 105 106sub create_removefile_table 107{ 108 my ($folderitemsref, $basedir) = @_; 109 110 my @removefiletable = (); 111 112 installer::windows::idtglobal::write_idt_header(\@removefiletable, "removefile"); 113 114 # Only the directories created for the FolderItems have to be deleted 115 # with the information in the table RemoveFile 116 117 my @directorycollector = (); 118 119 for ( my $i = 0; $i <= $#{$folderitemsref}; $i++ ) 120 { 121 my $onelink = ${$folderitemsref}[$i]; 122 123 if ( $onelink->{'used'} == 0 ) { next; } 124 125 if ( installer::existence::exists_in_array($onelink->{'directory'}, \@directorycollector)) { next; } 126 127 push(@directorycollector, $onelink->{'directory'}); 128 129 my %removefile = (); 130 131 $removefile{'FileKey'} = get_removefile_filekey($onelink); 132 $removefile{'Component_'} = get_removefile_component($onelink); 133 $removefile{'FileName'} = get_removefile_filename($onelink); 134 $removefile{'DirProperty'} = get_removefile_dirproperty($onelink); 135 $removefile{'InstallMode'} = get_removefile_installmode($onelink); 136 137 my $oneline = $removefile{'FileKey'} . "\t" . $removefile{'Component_'} . "\t" . $removefile{'FileName'} . "\t" 138 . $removefile{'DirProperty'} . "\t" . $removefile{'InstallMode'} . "\n"; 139 140 push(@removefiletable, $oneline); 141 } 142 143 # Saving the file 144 145 my $removefiletablename = $basedir . $installer::globals::separator . "RemoveFi.idt"; 146 installer::files::save_file($removefiletablename ,\@removefiletable); 147 my $infoline = "Created idt file: $removefiletablename\n"; 148 push(@installer::globals::logfileinfo, $infoline); 149 150} 151 1521;