Branch libreoffice-5-0-4
[LibreOffice.git] / solenv / bin / modules / installer / windows / createfolder.pm
bloba5c534c43637f2ae91349dd9896f039ad6261046
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 installer::exiter;
22 use installer::files;
23 use installer::globals;
24 use installer::windows::idtglobal;
26 ##############################################################
27 # Returning directory for createfolder table.
28 ##############################################################
30 sub get_createfolder_directory
32 my ($onedir) = @_;
34 my $uniquename = $onedir->{'uniquename'};
36 return $uniquename;
39 ##############################################################
40 # Searching the correct file for language pack directories.
41 ##############################################################
43 sub get_languagepack_file
45 my ($filesref, $onedir) = @_;
47 my $language = $onedir->{'specificlanguage'};
48 my $foundfile = 0;
49 my $onefile = "";
51 for ( my $i = 0; $i <= $#{$filesref}; $i++ )
53 $onefile = ${$filesref}[$i];
55 if ( $onefile->{'specificlanguage'} eq $onedir->{'specificlanguage'} )
57 $foundfile = 1;
58 last;
62 if ( ! $foundfile ) { installer::exiter::exit_program("ERROR: No file with correct language found (language pack build)!", "get_languagepack_file"); }
64 return $onefile;
67 ##############################################################
68 # Returning component for createfolder table.
69 ##############################################################
71 sub get_createfolder_component
73 my ($onedir, $filesref, $allvariableshashref) = @_;
75 # Directories do not belong to a module.
76 # Therefore they can only belong to the root module and
77 # will be added to a component at the root module.
78 # All directories will be added to the component
79 # $allvariableshashref->{'ROOTMODULEGID'}
81 if ( ! $allvariableshashref->{'ROOTMODULEGID'} ) { installer::exiter::exit_program("ERROR: ROOTMODULEGID must be defined in list file!", "get_createfolder_component"); }
83 my $rootmodulegid = $allvariableshashref->{'ROOTMODULEGID'};
85 my $onefile;
86 if ( $installer::globals::languagepack ) { $onefile = get_languagepack_file($filesref, $onedir); }
87 elsif ( $installer::globals::helppack ) { ($onefile) = grep {$_->{gid} eq 'gid_File_Help_Common_Zip'} @{$filesref} }
88 else {
89 foreach my $file (@{$filesref}) {
90 if ($file->{'modules'} eq $rootmodulegid)
92 $onefile = $file;
93 last;
98 if (! defined $onefile) {
99 installer::exiter::exit_program("ERROR: Could not find file!", "get_createfolder_component");
102 return $onefile->{'componentname'};
105 ####################################################################################
106 # Creating the file CreateFo.idt dynamically for creation of empty directories
107 # Content:
108 # Directory_ Component_
109 ####################################################################################
111 sub create_createfolder_table
113 my ($dirref, $filesref, $basedir, $allvariableshashref) = @_;
115 my @createfoldertable = ();
117 my $infoline;
119 installer::windows::idtglobal::write_idt_header(\@createfoldertable, "createfolder");
121 for ( my $i = 0; $i <= $#{$dirref}; $i++ )
123 my $onedir = ${$dirref}[$i];
125 # language packs and help packs get only language dependent directories
126 if (( $installer::globals::languagepack ) || ( $installer::globals::languagepack ) && ( $onedir->{'specificlanguage'} eq "" )) { next };
128 my $styles = "";
130 if ( $onedir->{'Styles'} ) { $styles = $onedir->{'Styles'}; }
132 if ( $styles =~ /\bCREATE\b/ )
134 my %directory = ();
136 $directory{'Directory_'} = get_createfolder_directory($onedir);
137 $directory{'Component_'} = get_createfolder_component($onedir, $filesref, $allvariableshashref);
139 my $oneline = $directory{'Directory_'} . "\t" . $directory{'Component_'} . "\n";
141 push(@createfoldertable, $oneline);
145 # Saving the file
147 my $createfoldertablename = $basedir . $installer::globals::separator . "CreateFo.idt";
148 installer::files::save_file($createfoldertablename ,\@createfoldertable);
149 $infoline = "Created idt file: $createfoldertablename\n";
150 push(@installer::globals::logfileinfo, $infoline);