cid#1607171 Data race condition
[LibreOffice.git] / solenv / bin / modules / installer / windows / createfolder.pm
blob4669ddd4acf4cecf5cbe2a1e6310d90c8243bfa2
2 # This file is part of the LibreOffice project.
4 # This Source Code Form is subject to the terms of the Mozilla Public
5 # License, v. 2.0. If a copy of the MPL was not distributed with this
6 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 # This file incorporates work covered by the following license notice:
10 # Licensed to the Apache Software Foundation (ASF) under one or more
11 # contributor license agreements. See the NOTICE file distributed
12 # with this work for additional information regarding copyright
13 # ownership. The ASF licenses this file to you under the Apache
14 # License, Version 2.0 (the "License"); you may not use this file
15 # except in compliance with the License. You may obtain a copy of
16 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 package installer::windows::createfolder;
21 use strict;
22 use warnings;
24 use installer::exiter;
25 use installer::files;
26 use installer::globals;
27 use installer::windows::idtglobal;
29 ##############################################################
30 # Returning directory for createfolder table.
31 ##############################################################
33 sub get_createfolder_directory
35 my ($onedir) = @_;
37 my $uniquename = $onedir->{'uniquename'};
39 return $uniquename;
42 ##############################################################
43 # Searching the correct file for language pack directories.
44 ##############################################################
46 sub get_languagepack_file
48 my ($filesref, $onedir) = @_;
50 my $language = $onedir->{'specificlanguage'};
51 my $foundfile = 0;
52 my $onefile = "";
54 for ( my $i = 0; $i <= $#{$filesref}; $i++ )
56 $onefile = ${$filesref}[$i];
58 if ( $onefile->{'specificlanguage'} eq $onedir->{'specificlanguage'} )
60 $foundfile = 1;
61 last;
65 if ( ! $foundfile ) { installer::exiter::exit_program("ERROR: No file with correct language found (language pack build)!", "get_languagepack_file"); }
67 return $onefile;
70 ##############################################################
71 # Returning component for createfolder table.
72 ##############################################################
74 sub get_createfolder_component
76 my ($onedir, $filesref, $allvariableshashref) = @_;
78 # Directories do not belong to a module.
79 # Therefore they can only belong to the root module and
80 # will be added to a component at the root module.
81 # All directories will be added to the component
82 # $allvariableshashref->{'ROOTMODULEGID'}
84 if ( ! $allvariableshashref->{'ROOTMODULEGID'} ) { installer::exiter::exit_program("ERROR: ROOTMODULEGID must be defined in list file!", "get_createfolder_component"); }
86 my $rootmodulegid = $allvariableshashref->{'ROOTMODULEGID'};
88 my $onefile;
89 if ( $installer::globals::languagepack ) { $onefile = get_languagepack_file($filesref, $onedir); }
90 elsif ( $installer::globals::helppack ) { ($onefile) = grep {$_->{gid} eq 'gid_File_Help_Common_Zip'} @{$filesref} }
91 else {
92 foreach my $file (@{$filesref}) {
93 if ($file->{'modules'} eq $rootmodulegid)
95 $onefile = $file;
96 last;
101 if (! defined $onefile) {
102 installer::exiter::exit_program("ERROR: Could not find file!", "get_createfolder_component");
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 and help packs get only language dependent directories
129 if (( $installer::globals::languagepack ) || ( $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);