Former-commit-id: f217f78e8085a81df68b9899513e547e148fca0d
This commit is contained in:
fbsanchez 2019-04-12 13:45:13 +02:00
parent f5088299f3
commit 15cd02a49b
1 changed files with 23 additions and 0 deletions

View File

@ -120,6 +120,7 @@ our @EXPORT = qw(
month_have_days
translate_obj
valid_regex
read_file
set_file_permissions
uri_encode
check_server_threads
@ -330,6 +331,28 @@ my @ServerThreads;
# Keep threads running.
our $THRRUN :shared = 1;
##########################################################################
## Reads a file and returns entire content or undef if error.
##########################################################################
sub read_file {
my $path = shift;
my $_FILE;
if( !open($_FILE, "<", $path) ) {
# failed to open, return undef
return undef;
}
# Slurp configuration file content.
my $content = do { local $/; <$_FILE> };
# Close file
close($_FILE);
return $content;
}
###############################################################################
# Sets user:group owner for the given file
###############################################################################