xref: /trunk/main/solenv/bin/modules/installer/windows/createfolder.pm (revision 0a407c2a85aa3a829e52a449aa13b6528fbe055e)
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
22package installer::windows::createfolder;
23
24use installer::existence;
25use installer::exiter;
26use installer::files;
27use installer::globals;
28use installer::windows::idtglobal;
29
30##############################################################
31# Returning directory for createfolder table.
32##############################################################
33
34sub get_createfolder_directory
35{
36    my ($onedir) = @_;
37
38    my $uniquename = $onedir->{'uniquename'};
39
40    return $uniquename;
41}
42
43##############################################################
44# Searching the correct file for language pack directories.
45##############################################################
46
47sub get_languagepack_file
48{
49    my ($filesref, $onedir) = @_;
50
51    my $language = $onedir->{'specificlanguage'};
52    my $foundfile = 0;
53    my $onefile = "";
54
55    for ( my $i = 0; $i <= $#{$filesref}; $i++ )
56    {
57        $onefile = ${$filesref}[$i];
58
59        if ( $onefile->{'specificlanguage'} eq $onedir->{'specificlanguage'} )
60        {
61            $foundfile = 1;
62            last;
63        }
64    }
65
66    if ( ! $foundfile ) { installer::exiter::exit_program("ERROR: No file with correct language found (language pack build)!", "get_languagepack_file"); }
67
68    return $onefile;
69}
70
71##############################################################
72# Returning component for createfolder table.
73##############################################################
74
75sub get_createfolder_component
76{
77    my ($onedir, $filesref, $allvariableshashref) = @_;
78
79    # Directories do not belong to a module.
80    # Therefore they can only belong to the root module and
81    # will be added to a component at the root module.
82    # All directories will be added to the component
83    # containing the file $allvariableshashref->{'GLOBALFILEGID'}
84
85    if ( ! $allvariableshashref->{'GLOBALFILEGID'} ) { installer::exiter::exit_program("ERROR: GLOBALFILEGID must be defined in list file!", "get_createfolder_component"); }
86    if (( $installer::globals::patch ) && ( ! $allvariableshashref->{'GLOBALFILEGID'} )) { installer::exiter::exit_program("ERROR: GLOBALPATCHFILEGID must be defined in list file!", "get_createfolder_component"); }
87
88    my $globalfilegid = $allvariableshashref->{'GLOBALFILEGID'};
89    if ( $installer::globals::patch ) { $globalfilegid = $allvariableshashref->{'GLOBALPATCHFILEGID'}; }
90
91    my $onefile = "";
92    if ( $installer::globals::languagepack ) { $onefile = get_languagepack_file($filesref, $onedir); }
93    else { $onefile = installer::existence::get_specified_file($filesref, $globalfilegid); }
94
95    return $onefile->{'componentname'};
96}
97
98####################################################################################
99# Creating the file CreateFo.idt dynamically for creation of empty directories
100# Content:
101# Directory_ Component_
102####################################################################################
103
104sub create_createfolder_table
105{
106    my ($dirref, $filesref, $basedir, $allvariableshashref) = @_;
107
108    my @createfoldertable = ();
109
110    my $infoline;
111
112    installer::windows::idtglobal::write_idt_header(\@createfoldertable, "createfolder");
113
114    for ( my $i = 0; $i <= $#{$dirref}; $i++ )
115    {
116        my $onedir = ${$dirref}[$i];
117
118        # language packs get only language dependent directories
119        if (( $installer::globals::languagepack ) && ( $onedir->{'specificlanguage'} eq "" )) { next };
120
121        my $styles = "";
122
123        if ( $onedir->{'Styles'} ) { $styles = $onedir->{'Styles'}; }
124
125        if ( $styles =~ /\bCREATE\b/ )
126        {
127            my %directory = ();
128
129            $directory{'Directory_'} = get_createfolder_directory($onedir);
130            $directory{'Component_'} = get_createfolder_component($onedir, $filesref, $allvariableshashref);
131
132            my $oneline = $directory{'Directory_'} . "\t" . $directory{'Component_'} . "\n";
133
134            push(@createfoldertable, $oneline);
135        }
136    }
137
138    # Saving the file
139
140    my $createfoldertablename = $basedir . $installer::globals::separator . "CreateFo.idt";
141    installer::files::save_file($createfoldertablename ,\@createfoldertable);
142    $installer::logger::Lang->printf("Created idt file: %s\n", $createfoldertablename);
143}
144
1451;
146