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 par2script
::systemactions
;
36 use par2script
::exiter
;
37 use par2script
::globals
;
39 ######################################################
40 # Creating a new direcotory
41 ######################################################
51 $returnvalue = mkdir($directory, 0775);
55 $infoline = "Created directory: $directory\n";
56 push(@par2script::globals
::logfileinfo
, $infoline);
58 if ($par2script::globals
::isunix
)
60 my $localcall = "chmod 775 $directory \>\/dev\/null 2\>\&1";
66 par2script
::exiter
::exit_program
("Error: Could not create directory: $directory", "create_directory");
71 #######################################################################
72 # Creating the directories, in which files are generated or unzipped
73 #######################################################################
75 sub create_directories
77 my ($directory, $languagesref) =@_;
79 $par2script::globals
::unpackpath
=~ s/\Q$par2script::globals::separator\E\s*$//; # removing ending slashes and backslashes
81 my $path = $par2script::globals
::unpackpath
; # this path already exists
83 $path = $path . $par2script::globals
::separator
. $par2script::globals
::build
. $par2script::globals
::separator
;
84 create_directory
($path);
86 $path = $path . $par2script::globals
::minor
. $par2script::globals
::separator
;
87 create_directory
($path);
89 if ($directory eq "unzip" )
91 $path = $path . "common" . $par2script::globals
::productextension
. $par2script::globals
::separator
;
92 create_directory
($path);
94 $path = $path . $directory . $par2script::globals
::separator
;
95 create_directory
($path);
99 $path = $path . $par2script::globals
::compiler
. $par2script::globals
::productextension
. $par2script::globals
::separator
;
100 create_directory
($path);
102 $path = $path . $par2script::globals
::product
. $par2script::globals
::separator
;
103 create_directory
($path);
105 $path = $path . $directory . $par2script::globals
::separator
;
106 create_directory
($path);
108 if (!($$languagesref eq "" )) # this will be a path like "01_49", for Profiles and ConfigurationFiles, idt-Files
110 $path = $path . $$languagesref . $par2script::globals
::separator
;
111 create_directory
($path);
115 $path =~ s/\Q$par2script::globals::separator\E\s*$//;
120 ########################
122 ########################
126 my ($source, $dest) = @_;
128 my ($copyreturn, $returnvalue);
131 $copyreturn = copy
($source, $dest);
135 $infoline = "Copy: $source to $dest\n";
140 $infoline = "Error: Could not copy $source to $dest\n";
144 push(@par2script::globals
::logfileinfo
, $infoline);
149 ##########################################
150 # Copying all files from one directory
151 # to another directory
152 ##########################################
156 my ($sourcedir, $destdir) = @_;
158 my ($onefile, $sourcefile, $destfile);
159 my @sourcefiles = ();
161 $sourcedir =~ s/\Q$par2script::globals::separator\E\s*$//;
162 $destdir =~ s/\Q$par2script::globals::separator\E\s*$//;
165 push(@par2script::globals
::logfileinfo
, $infoline);
166 $infoline = "Copying files from directory $sourcedir to directory $destdir\n";
167 push(@par2script::globals
::logfileinfo
, $infoline);
169 opendir(DIR
, $sourcedir);
170 @sourcefiles = readdir(DIR
);
173 foreach $onefile (@sourcefiles)
175 if ((!($onefile eq ".")) && (!($onefile eq "..")))
177 $sourcefile = $sourcedir . $par2script::globals
::separator
. $onefile;
178 $destfile = $destdir . $par2script::globals
::separator
. $onefile;
179 if ( -f
$sourcefile ) # only files, no directories
181 copy_one_file
($sourcefile, $destfile);