1 #*************************************************************************
3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 # Copyright 2008 by Sun Microsystems, Inc.
7 # OpenOffice.org - a multi-platform office productivity suite
9 # $RCSfile: systemactions.pm,v $
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 #*************************************************************************
33 package pre2par
::systemactions
;
39 ######################################################
40 # Creating a new direcotory
41 ######################################################
50 if ($directory eq "" )
57 $returnvalue = mkdir($directory, 0775);
61 $infoline = "Created directory: $directory\n";
62 push(@pre2par::globals
::logfileinfo
, $infoline);
64 if ($pre2par::globals
::isunix
)
66 my $localcall = "chmod 775 $directory \>\/dev\/null 2\>\&1";
72 # New solution in parallel packing: It is possible, that the directory now exists, although it
73 # was not created in this process. There is only an important error, if the directory does not
78 pre2par
::exiter
::exit_program
("Error: Could not create directory: $directory", "create_directory");
82 $infoline = "\nAnother process created this directory in exactly this moment :-) : $directory\n";
83 push(@pre2par::globals
::logfileinfo
, $infoline);
89 $infoline = "\nAlready existing directory, did not create: $directory\n";
90 push(@pre2par::globals
::logfileinfo
, $infoline);
94 #######################################################################
95 # Creating the directories, in which files are generated or unzipped
96 #######################################################################
98 sub create_directories
100 my ($directory, $languagesref) =@_;
102 $pre2par::globals
::unpackpath
=~ s/\Q$pre2par::globals::separator\E\s*$//; # removing ending slashes and backslashes
104 my $path = $pre2par::globals
::unpackpath
; # this path already exists
106 $path = $path . $pre2par::globals
::separator
. $pre2par::globals
::build
. $pre2par::globals
::separator
;
107 create_directory
($path);
109 $path = $path . $pre2par::globals
::minor
. $pre2par::globals
::separator
;
110 create_directory
($path);
112 if ($directory eq "unzip" )
114 $path = $path . "common" . $pre2par::globals
::productextension
. $pre2par::globals
::separator
;
115 create_directory
($path);
117 $path = $path . $directory . $pre2par::globals
::separator
;
118 create_directory
($path);
122 $path = $path . $pre2par::globals
::compiler
. $pre2par::globals
::productextension
. $pre2par::globals
::separator
;
123 create_directory
($path);
125 $path = $path . $pre2par::globals
::product
. $pre2par::globals
::separator
;
126 create_directory
($path);
128 $path = $path . $directory . $pre2par::globals
::separator
;
129 create_directory
($path);
131 if (!($$languagesref eq "" )) # this will be a path like "01_49", for Profiles and ConfigurationFiles, idt-Files
133 $path = $path . $$languagesref . $pre2par::globals
::separator
;
134 create_directory
($path);
138 $path =~ s/\Q$pre2par::globals::separator\E\s*$//;
143 ########################
145 ########################
149 my ($source, $dest) = @_;
151 my ($copyreturn, $returnvalue, $infoline);
153 $copyreturn = copy
($source, $dest);
157 $infoline = "Copy: $source to $dest\n";
162 $infoline = "Error: Could not copy $source to $dest\n";
166 push(@pre2par::globals
::logfileinfo
, $infoline);
171 ##########################################
172 # Copying all files from one directory
173 # to another directory
174 ##########################################
178 my ($sourcedir, $destdir) = @_;
180 my ($onefile, $sourcefile, $destfile);
181 my @sourcefiles = ();
183 $sourcedir =~ s/\Q$pre2par::globals::separator\E\s*$//;
184 $destdir =~ s/\Q$pre2par::globals::separator\E\s*$//;
187 push(@pre2par::globals
::logfileinfo
, $infoline);
188 $infoline = "Copying files from directory $sourcedir to directory $destdir\n";
189 push(@pre2par::globals
::logfileinfo
, $infoline);
191 opendir(DIR
, $sourcedir);
192 @sourcefiles = readdir(DIR
);
195 foreach $onefile (@sourcefiles)
197 if ((!($onefile eq ".")) && (!($onefile eq "..")))
199 $sourcefile = $sourcedir . $pre2par::globals
::separator
. $onefile;
200 $destfile = $destdir . $pre2par::globals
::separator
. $onefile;
201 if ( -f
$sourcefile ) # only files, no directories
203 copy_one_file
($sourcefile, $destfile);