Update ooo320-m1
[ooovba.git] / solenv / bin / modules / installer / windows / removefile.pm
blob9b4cb70cab97f55b9e11ec07057c54ab7b2d5072
1 #*************************************************************************
3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 #
5 # Copyright 2008 by Sun Microsystems, Inc.
7 # OpenOffice.org - a multi-platform office productivity suite
9 # $RCSfile: removefile.pm,v $
11 # $Revision: 1.4 $
13 # This file is part of OpenOffice.org.
15 # OpenOffice.org is free software: you can redistribute it and/or modify
16 # it under the terms of the GNU Lesser General Public License version 3
17 # only, as published by the Free Software Foundation.
19 # OpenOffice.org is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU Lesser General Public License version 3 for more details
23 # (a copy is included in the LICENSE file that accompanied this code).
25 # You should have received a copy of the GNU Lesser General Public License
26 # version 3 along with OpenOffice.org. If not, see
27 # <http://www.openoffice.org/license.html>
28 # for a copy of the LGPLv3 License.
30 #*************************************************************************
32 package installer::windows::removefile;
34 use installer::files;
35 use installer::globals;
36 use installer::windows::idtglobal;
38 ########################################################################
39 # Returning the FileKey for a folderitem for removefile table.
40 ########################################################################
42 sub get_removefile_filekey
44 my ($folderitem) = @_;
46 # returning the unique identifier
48 my $identifier = "remove_" . $folderitem->{'directory'};
50 $identifier = lc($identifier);
52 return $identifier;
55 ########################################################################
56 # Returning the Component for a folderitem for removefile table.
57 ########################################################################
59 sub get_removefile_component
61 my ($folderitem) = @_;
63 return $folderitem->{'component'};
66 ########################################################################
67 # Returning the FileName for a folderitem for removefile table.
68 ########################################################################
70 sub get_removefile_filename
72 my ($folderitem) = @_;
74 # return nothing: The assigned directory will be removed
76 return "";
79 ########################################################################
80 # Returning the DirProperty for a folderitem for removefile table.
81 ########################################################################
83 sub get_removefile_dirproperty
85 my ($folderitem) = @_;
87 return $folderitem->{'directory'};
90 ########################################################################
91 # Returning the InstallMode for a folderitem for removefile table.
92 ########################################################################
94 sub get_removefile_installmode
96 my ($folderitem) = @_;
98 # always returning "2": The file is only removed, if the assigned
99 # component is removed. Name: msidbRemoveFileInstallModeOnRemove
101 return 2;
104 ###########################################################################################################
105 # Creating the file RemoveFi.idt dynamically
106 # Content:
107 # FileKey Component_ FileName DirProperty InstallMode
108 ###########################################################################################################
110 sub create_removefile_table
112 my ($folderitemsref, $basedir) = @_;
114 my @removefiletable = ();
116 installer::windows::idtglobal::write_idt_header(\@removefiletable, "removefile");
118 # Only the directories created for the FolderItems have to be deleted
119 # with the information in the table RemoveFile
121 my @directorycollector = ();
123 for ( my $i = 0; $i <= $#{$folderitemsref}; $i++ )
125 my $onelink = ${$folderitemsref}[$i];
127 if ( $onelink->{'used'} == 0 ) { next; }
129 if ( installer::existence::exists_in_array($onelink->{'directory'}, \@directorycollector)) { next; }
131 push(@directorycollector, $onelink->{'directory'});
133 my %removefile = ();
135 $removefile{'FileKey'} = get_removefile_filekey($onelink);
136 $removefile{'Component_'} = get_removefile_component($onelink);
137 $removefile{'FileName'} = get_removefile_filename($onelink);
138 $removefile{'DirProperty'} = get_removefile_dirproperty($onelink);
139 $removefile{'InstallMode'} = get_removefile_installmode($onelink);
141 my $oneline = $removefile{'FileKey'} . "\t" . $removefile{'Component_'} . "\t" . $removefile{'FileName'} . "\t"
142 . $removefile{'DirProperty'} . "\t" . $removefile{'InstallMode'} . "\n";
144 push(@removefiletable, $oneline);
147 # Saving the file
149 my $removefiletablename = $basedir . $installer::globals::separator . "RemoveFi.idt";
150 installer::files::save_file($removefiletablename ,\@removefiletable);
151 my $infoline = "Created idt file: $removefiletablename\n";
152 push(@installer::globals::logfileinfo, $infoline);