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
::files
;
24 use installer
::exiter
;
25 use installer
::logger
;
27 ############################################
29 ############################################
37 installer
::exiter
::exit_program
("ERROR: Cannot find file $arg", "check_file");
46 open( IN
, "<$localfile" ) || installer
::exiter
::exit_program
("ERROR: Cannot open file $localfile for reading", "read_file");
48 # Don't use "my @localfile = <IN>" here, because
49 # perl has a problem with the internal "large_and_huge_malloc" function
50 # when calling perl using MacOS 10.5 with a perl built with MacOS 10.4
51 while ( my $line = <IN
> ) {
52 push @localfile, $line;
60 ###########################################
61 # Saving files, arrays and hashes
62 ###########################################
66 my ($savefile, $savecontent) = @_;
68 if ( open( OUT
, ">$savefile" ) )
70 print OUT @
{$savecontent};
75 # it is useless to save a log file, if there is no write access
77 if ( $savefile =~ /\.log/ )
79 print "\n*************************************************\n";
80 print "ERROR: Cannot write log file $savefile, $!";
81 print "\n*************************************************\n";
82 exit(-1); # exiting the program to avoid endless loops
85 installer
::exiter
::exit_program
("ERROR: Cannot open file $savefile for writing", "save_file");
89 ###########################################
90 # Binary file operations
91 ###########################################
99 open( IN
, "<$filename" ) || installer
::exiter
::exit_program
("ERROR: Cannot open file $filename for reading", "read_binary_file");
102 my $length = tell IN
;
104 read IN
, $file, $length;
112 my ($file, $filename) = @_;
114 open( OUT
, ">$filename" ) || installer
::exiter
::exit_program
("ERROR: Cannot open file $filename for writing", "save_binary_file");