1 #*************************************************************************
3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 # Copyright 2000, 2010 Oracle and/or its affiliates.
7 # OpenOffice.org - a multi-platform office productivity suite
9 # This file is part of OpenOffice.org.
11 # OpenOffice.org is free software: you can redistribute it and/or modify
12 # it under the terms of the GNU Lesser General Public License version 3
13 # only, as published by the Free Software Foundation.
15 # OpenOffice.org is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU Lesser General Public License version 3 for more details
19 # (a copy is included in the LICENSE file that accompanied this code).
21 # You should have received a copy of the GNU Lesser General Public License
22 # version 3 along with OpenOffice.org. If not, see
23 # <http://www.openoffice.org/license.html>
24 # for a copy of the LGPLv3 License.
26 #*************************************************************************
29 package par2script
::systemactions
;
32 use par2script
::exiter
;
33 use par2script
::globals
;
35 ######################################################
36 # Creating a new direcotory
37 ######################################################
47 $returnvalue = mkdir($directory, 0775);
51 $infoline = "Created directory: $directory\n";
52 push(@par2script::globals
::logfileinfo
, $infoline);
54 if ($par2script::globals
::isunix
)
56 my $localcall = "chmod 775 $directory \>\/dev\/null 2\>\&1";
62 par2script
::exiter
::exit_program
("Error: Could not create directory: $directory", "create_directory");
67 #######################################################################
68 # Creating the directories, in which files are generated or unzipped
69 #######################################################################
71 sub create_directories
73 my ($directory, $languagesref) =@_;
75 $par2script::globals
::unpackpath
=~ s/\Q$par2script::globals::separator\E\s*$//; # removing ending slashes and backslashes
77 my $path = $par2script::globals
::unpackpath
; # this path already exists
79 $path = $path . $par2script::globals
::separator
. $par2script::globals
::build
. $par2script::globals
::separator
;
80 create_directory
($path);
82 $path = $path . $par2script::globals
::minor
. $par2script::globals
::separator
;
83 create_directory
($path);
85 if ($directory eq "unzip" )
87 $path = $path . "common" . $par2script::globals
::productextension
. $par2script::globals
::separator
;
88 create_directory
($path);
90 $path = $path . $directory . $par2script::globals
::separator
;
91 create_directory
($path);
95 $path = $path . $par2script::globals
::compiler
. $par2script::globals
::productextension
. $par2script::globals
::separator
;
96 create_directory
($path);
98 $path = $path . $par2script::globals
::product
. $par2script::globals
::separator
;
99 create_directory
($path);
101 $path = $path . $directory . $par2script::globals
::separator
;
102 create_directory
($path);
104 if (!($$languagesref eq "" )) # this will be a path like "01_49", for Profiles and ConfigurationFiles, idt-Files
106 $path = $path . $$languagesref . $par2script::globals
::separator
;
107 create_directory
($path);
111 $path =~ s/\Q$par2script::globals::separator\E\s*$//;
116 ########################
118 ########################
122 my ($source, $dest) = @_;
124 my ($copyreturn, $returnvalue);
127 $copyreturn = copy
($source, $dest);
131 $infoline = "Copy: $source to $dest\n";
136 $infoline = "Error: Could not copy $source to $dest $!\n";
140 push(@par2script::globals
::logfileinfo
, $infoline);
145 ##########################################
146 # Copying all files from one directory
147 # to another directory
148 ##########################################
152 my ($sourcedir, $destdir) = @_;
154 my ($onefile, $sourcefile, $destfile);
155 my @sourcefiles = ();
157 $sourcedir =~ s/\Q$par2script::globals::separator\E\s*$//;
158 $destdir =~ s/\Q$par2script::globals::separator\E\s*$//;
161 push(@par2script::globals
::logfileinfo
, $infoline);
162 $infoline = "Copying files from directory $sourcedir to directory $destdir\n";
163 push(@par2script::globals
::logfileinfo
, $infoline);
165 opendir(DIR
, $sourcedir);
166 @sourcefiles = readdir(DIR
);
169 foreach $onefile (@sourcefiles)
171 if ((!($onefile eq ".")) && (!($onefile eq "..")))
173 $sourcefile = $sourcedir . $par2script::globals
::separator
. $onefile;
174 $destfile = $destdir . $par2script::globals
::separator
. $onefile;
175 if ( -f
$sourcefile ) # only files, no directories
177 copy_one_file
($sourcefile, $destfile);