19780544fSAndrew Rist#**************************************************************
29780544fSAndrew Rist#
39780544fSAndrew Rist#  Licensed to the Apache Software Foundation (ASF) under one
49780544fSAndrew Rist#  or more contributor license agreements.  See the NOTICE file
59780544fSAndrew Rist#  distributed with this work for additional information
69780544fSAndrew Rist#  regarding copyright ownership.  The ASF licenses this file
79780544fSAndrew Rist#  to you under the Apache License, Version 2.0 (the
89780544fSAndrew Rist#  "License"); you may not use this file except in compliance
99780544fSAndrew Rist#  with the License.  You may obtain a copy of the License at
109780544fSAndrew Rist#
119780544fSAndrew Rist#    http://www.apache.org/licenses/LICENSE-2.0
129780544fSAndrew Rist#
139780544fSAndrew Rist#  Unless required by applicable law or agreed to in writing,
149780544fSAndrew Rist#  software distributed under the License is distributed on an
159780544fSAndrew Rist#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
169780544fSAndrew Rist#  KIND, either express or implied.  See the License for the
179780544fSAndrew Rist#  specific language governing permissions and limitations
189780544fSAndrew Rist#  under the License.
199780544fSAndrew Rist#
209780544fSAndrew Rist#**************************************************************
219780544fSAndrew Rist
229780544fSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweirpackage installer::windows::createfolder;
25cdf0e10cSrcweir
26cdf0e10cSrcweiruse installer::existence;
27cdf0e10cSrcweiruse installer::exiter;
28cdf0e10cSrcweiruse installer::files;
29cdf0e10cSrcweiruse installer::globals;
30cdf0e10cSrcweiruse installer::windows::idtglobal;
31cdf0e10cSrcweir
32cdf0e10cSrcweir##############################################################
33cdf0e10cSrcweir# Returning directory for createfolder table.
34cdf0e10cSrcweir##############################################################
35cdf0e10cSrcweir
36cdf0e10cSrcweirsub get_createfolder_directory
37cdf0e10cSrcweir{
38cdf0e10cSrcweir	my ($onedir) = @_;
39cdf0e10cSrcweir
40cdf0e10cSrcweir	my $uniquename = $onedir->{'uniquename'};
41cdf0e10cSrcweir
42cdf0e10cSrcweir	return $uniquename;
43cdf0e10cSrcweir}
44cdf0e10cSrcweir
45cdf0e10cSrcweir##############################################################
46cdf0e10cSrcweir# Searching the correct file for language pack directories.
47cdf0e10cSrcweir##############################################################
48cdf0e10cSrcweir
49cdf0e10cSrcweirsub get_languagepack_file
50cdf0e10cSrcweir{
51cdf0e10cSrcweir	my ($filesref, $onedir) = @_;
52cdf0e10cSrcweir
53cdf0e10cSrcweir	my $language = $onedir->{'specificlanguage'};
54cdf0e10cSrcweir	my $foundfile = 0;
55cdf0e10cSrcweir	my $onefile = "";
56cdf0e10cSrcweir
57cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$filesref}; $i++ )
58cdf0e10cSrcweir	{
59cdf0e10cSrcweir		$onefile = ${$filesref}[$i];
60cdf0e10cSrcweir
61cdf0e10cSrcweir		if ( $onefile->{'specificlanguage'} eq $onedir->{'specificlanguage'} )
62cdf0e10cSrcweir		{
63cdf0e10cSrcweir			$foundfile = 1;
64cdf0e10cSrcweir			last;
65cdf0e10cSrcweir		}
66cdf0e10cSrcweir	}
67cdf0e10cSrcweir
68cdf0e10cSrcweir	if ( ! $foundfile ) { installer::exiter::exit_program("ERROR: No file with correct language found (language pack build)!", "get_languagepack_file"); }
69cdf0e10cSrcweir
70cdf0e10cSrcweir	return $onefile;
71cdf0e10cSrcweir}
72cdf0e10cSrcweir
73cdf0e10cSrcweir##############################################################
74cdf0e10cSrcweir# Returning component for createfolder table.
75cdf0e10cSrcweir##############################################################
76cdf0e10cSrcweir
77cdf0e10cSrcweirsub get_createfolder_component
78cdf0e10cSrcweir{
79cdf0e10cSrcweir	my ($onedir, $filesref, $allvariableshashref) = @_;
80cdf0e10cSrcweir
81cdf0e10cSrcweir	# Directories do not belong to a module.
82cdf0e10cSrcweir	# Therefore they can only belong to the root module and
83cdf0e10cSrcweir	# will be added to a component at the root module.
84cdf0e10cSrcweir	# All directories will be added to the component
85cdf0e10cSrcweir	# containing the file $allvariableshashref->{'GLOBALFILEGID'}
86cdf0e10cSrcweir
87cdf0e10cSrcweir	if ( ! $allvariableshashref->{'GLOBALFILEGID'} ) { installer::exiter::exit_program("ERROR: GLOBALFILEGID must be defined in list file!", "get_createfolder_component"); }
88cdf0e10cSrcweir	if (( $installer::globals::patch ) && ( ! $allvariableshashref->{'GLOBALFILEGID'} )) { installer::exiter::exit_program("ERROR: GLOBALPATCHFILEGID must be defined in list file!", "get_createfolder_component"); }
89cdf0e10cSrcweir
90cdf0e10cSrcweir	my $globalfilegid = $allvariableshashref->{'GLOBALFILEGID'};
91cdf0e10cSrcweir	if ( $installer::globals::patch ) { $globalfilegid = $allvariableshashref->{'GLOBALPATCHFILEGID'}; }
92cdf0e10cSrcweir
93cdf0e10cSrcweir	my $onefile = "";
94cdf0e10cSrcweir	if ( $installer::globals::languagepack ) { $onefile = get_languagepack_file($filesref, $onedir); }
95cdf0e10cSrcweir	else { $onefile = installer::existence::get_specified_file($filesref, $globalfilegid); }
96cdf0e10cSrcweir
97cdf0e10cSrcweir	return $onefile->{'componentname'};
98cdf0e10cSrcweir}
99cdf0e10cSrcweir
100cdf0e10cSrcweir####################################################################################
101cdf0e10cSrcweir# Creating the file CreateFo.idt dynamically for creation of empty directories
102cdf0e10cSrcweir# Content:
103cdf0e10cSrcweir# Directory_ Component_
104cdf0e10cSrcweir####################################################################################
105cdf0e10cSrcweir
106cdf0e10cSrcweirsub create_createfolder_table
107cdf0e10cSrcweir{
108cdf0e10cSrcweir	my ($dirref, $filesref, $basedir, $allvariableshashref) = @_;
109cdf0e10cSrcweir
110cdf0e10cSrcweir	my @createfoldertable = ();
111cdf0e10cSrcweir
112cdf0e10cSrcweir	my $infoline;
113cdf0e10cSrcweir
114cdf0e10cSrcweir	installer::windows::idtglobal::write_idt_header(\@createfoldertable, "createfolder");
115cdf0e10cSrcweir
116cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$dirref}; $i++ )
117cdf0e10cSrcweir	{
118cdf0e10cSrcweir		my $onedir = ${$dirref}[$i];
119cdf0e10cSrcweir
120cdf0e10cSrcweir		# language packs get only language dependent directories
121cdf0e10cSrcweir		if (( $installer::globals::languagepack ) && ( $onedir->{'specificlanguage'} eq "" )) { next };
122cdf0e10cSrcweir
123cdf0e10cSrcweir		my $styles = "";
124cdf0e10cSrcweir
125cdf0e10cSrcweir		if ( $onedir->{'Styles'} ) { $styles = $onedir->{'Styles'}; }
126cdf0e10cSrcweir
127cdf0e10cSrcweir		if ( $styles =~ /\bCREATE\b/ )
128cdf0e10cSrcweir		{
129cdf0e10cSrcweir			my %directory = ();
130cdf0e10cSrcweir
131cdf0e10cSrcweir			$directory{'Directory_'} = get_createfolder_directory($onedir);
132cdf0e10cSrcweir			$directory{'Component_'} = get_createfolder_component($onedir, $filesref, $allvariableshashref);
133cdf0e10cSrcweir
134cdf0e10cSrcweir			my $oneline = $directory{'Directory_'} . "\t" . $directory{'Component_'} . "\n";
135cdf0e10cSrcweir
136cdf0e10cSrcweir			push(@createfoldertable, $oneline);
137cdf0e10cSrcweir		}
138cdf0e10cSrcweir	}
139cdf0e10cSrcweir
140cdf0e10cSrcweir	# Saving the file
141cdf0e10cSrcweir
142cdf0e10cSrcweir	my $createfoldertablename = $basedir . $installer::globals::separator . "CreateFo.idt";
143cdf0e10cSrcweir	installer::files::save_file($createfoldertablename ,\@createfoldertable);
144*b274bc22SAndre Fischer    $installer::logger::Lang->printf("Created idt file: %s\n", $createfoldertablename);
145cdf0e10cSrcweir}
146cdf0e10cSrcweir
147*b274bc22SAndre Fischer1;
148