Merge branch 'ent-5744-pandora_ux-pl-con-pandorafms-webdriver' into 'develop'

added missing function read_file

See merge request artica/pandorafms!3193
This commit is contained in:
Daniel Rodriguez 2020-05-25 18:18:28 +02:00
commit bab85bcc5e
1 changed files with 22 additions and 0 deletions

View File

@ -87,6 +87,7 @@ our @EXPORT = qw(
print_warning
print_stderror
read_configuration
read_file
simple_decode_json
snmp_data_switcher
snmp_get
@ -1263,6 +1264,27 @@ sub read_configuration {
return $config;
}
################################################################################
## 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;
}
################################################################################
# General arguments parser
################################################################################