Update ooo320-m1
[ooovba.git] / solenv / bin / modules / installer / windows / createfolder.pm
blob1f31bac12d4cbca2c63e8bf3e4774fab53602e98
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: createfolder.pm,v $
11 # $Revision: 1.7 $
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::createfolder;
34 use installer::existence;
35 use installer::exiter;
36 use installer::files;
37 use installer::globals;
38 use installer::windows::idtglobal;
40 ##############################################################
41 # Returning directory for createfolder table.
42 ##############################################################
44 sub get_createfolder_directory
46 my ($onedir) = @_;
48 my $uniquename = $onedir->{'uniquename'};
50 return $uniquename;
53 ##############################################################
54 # Searching the correct file for language pack directories.
55 ##############################################################
57 sub get_languagepack_file
59 my ($filesref, $onedir) = @_;
61 my $language = $onedir->{'specificlanguage'};
62 my $foundfile = 0;
63 my $onefile = "";
65 for ( my $i = 0; $i <= $#{$filesref}; $i++ )
67 $onefile = ${$filesref}[$i];
69 if ( $onefile->{'specificlanguage'} eq $onedir->{'specificlanguage'} )
71 $foundfile = 1;
72 last;
76 if ( ! $foundfile ) { installer::exiter::exit_program("ERROR: No file with correct language found (language pack build)!", "get_languagepack_file"); }
78 return $onefile;
81 ##############################################################
82 # Returning component for createfolder table.
83 ##############################################################
85 sub get_createfolder_component
87 my ($onedir, $filesref, $allvariableshashref) = @_;
89 # Directories do not belong to a module.
90 # Therefore they can only belong to the root module and
91 # will be added to a component at the root module.
92 # All directories will be added to the component
93 # containing the file $allvariableshashref->{'GLOBALFILEGID'}
95 if ( ! $allvariableshashref->{'GLOBALFILEGID'} ) { installer::exiter::exit_program("ERROR: GLOBALFILEGID must be defined in list file!", "get_createfolder_component"); }
96 if (( $installer::globals::patch ) && ( ! $allvariableshashref->{'GLOBALFILEGID'} )) { installer::exiter::exit_program("ERROR: GLOBALPATCHFILEGID must be defined in list file!", "get_createfolder_component"); }
98 my $globalfilegid = $allvariableshashref->{'GLOBALFILEGID'};
99 if ( $installer::globals::patch ) { $globalfilegid = $allvariableshashref->{'GLOBALPATCHFILEGID'}; }
101 my $onefile = "";
102 if ( $installer::globals::languagepack ) { $onefile = get_languagepack_file($filesref, $onedir); }
103 else { $onefile = installer::existence::get_specified_file($filesref, $globalfilegid); }
105 return $onefile->{'componentname'};
108 ####################################################################################
109 # Creating the file CreateFo.idt dynamically for creation of empty directories
110 # Content:
111 # Directory_ Component_
112 ####################################################################################
114 sub create_createfolder_table
116 my ($dirref, $filesref, $basedir, $allvariableshashref) = @_;
118 my @createfoldertable = ();
120 my $infoline;
122 installer::windows::idtglobal::write_idt_header(\@createfoldertable, "createfolder");
124 for ( my $i = 0; $i <= $#{$dirref}; $i++ )
126 my $onedir = ${$dirref}[$i];
128 # language packs get only language dependent directories
129 if (( $installer::globals::languagepack ) && ( $onedir->{'specificlanguage'} eq "" )) { next };
131 my $styles = "";
133 if ( $onedir->{'Styles'} ) { $styles = $onedir->{'Styles'}; }
135 if ( $styles =~ /\bCREATE\b/ )
137 my %directory = ();
139 $directory{'Directory_'} = get_createfolder_directory($onedir);
140 $directory{'Component_'} = get_createfolder_component($onedir, $filesref, $allvariableshashref);
142 my $oneline = $directory{'Directory_'} . "\t" . $directory{'Component_'} . "\n";
144 push(@createfoldertable, $oneline);
148 # Saving the file
150 my $createfoldertablename = $basedir . $installer::globals::separator . "CreateFo.idt";
151 installer::files::save_file($createfoldertablename ,\@createfoldertable);
152 $infoline = "Created idt file: $createfoldertablename\n";
153 push(@installer::globals::logfileinfo, $infoline);